mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
add more jsb interface info && fix some types (#14628)
* add jsb interface info * mark TODO workaround * fix type * remove some new ts-expect-error * fix type in strict mode
This commit is contained in:
@@ -24,9 +24,12 @@
|
||||
import { cclegacy } from '../../core';
|
||||
import './asset';
|
||||
import { patch_cc_BufferAsset } from '../../native-binding/decorators';
|
||||
import type { BufferAsset as JsbBufferAsset } from './buffer-asset';
|
||||
|
||||
export type BufferAsset = jsb.BufferAsset;
|
||||
export const BufferAsset = jsb.BufferAsset;
|
||||
declare const jsb: any;
|
||||
|
||||
export type BufferAsset = JsbBufferAsset;
|
||||
export const BufferAsset: typeof JsbBufferAsset = jsb.BufferAsset;
|
||||
|
||||
cclegacy.BufferAsset = jsb.BufferAsset;
|
||||
|
||||
|
||||
@@ -25,9 +25,15 @@
|
||||
import{ cclegacy } from '../../core';
|
||||
import './asset';
|
||||
import { patch_cc_EffectAsset } from '../../native-binding/decorators';
|
||||
import type { EffectAsset as JsbEffectAsset } from './effect-asset';
|
||||
import type { BlendState, DepthStencilState, RasterizerState, DynamicStateFlags, PrimitiveMode, ShaderStageFlags, Type, Uniform, MemoryAccess, Format} from "../../gfx/index.jsb";
|
||||
import type { RenderPassStage } from '../../rendering/define';
|
||||
import type { MacroRecord } from '../../render-scene/core/pass-utils';
|
||||
|
||||
export type EffectAsset = jsb.EffectAsset;
|
||||
export const EffectAsset = jsb.EffectAsset;
|
||||
declare const jsb: any;
|
||||
|
||||
export type EffectAsset = JsbEffectAsset;
|
||||
export const EffectAsset: typeof JsbEffectAsset = jsb.EffectAsset;
|
||||
|
||||
cclegacy.EffectAsset = EffectAsset;
|
||||
|
||||
@@ -38,5 +44,149 @@ effectAssetProto._ctor = function () {
|
||||
this.hideInEditor = false;
|
||||
};
|
||||
|
||||
// NOTE: TS cannot merge exported type in multiple modules, so we need to declare namespace EffectAsset again here.
|
||||
export declare namespace EffectAsset {
|
||||
export interface IPropertyInfo {
|
||||
type: number; // auto-extracted from shader
|
||||
handleInfo?: [string, number, number]; // auto-generated from 'target'
|
||||
samplerHash?: number; // auto-generated from 'sampler'
|
||||
value?: number[] | string; // default value
|
||||
linear?: boolean; // whether to convert the input to linear space first before applying
|
||||
}
|
||||
// Pass instance itself are compliant to IPassStates too
|
||||
export interface IPassStates {
|
||||
priority?: number;
|
||||
primitive?: PrimitiveMode;
|
||||
stage?: RenderPassStage;
|
||||
rasterizerState?: RasterizerState;
|
||||
depthStencilState?: DepthStencilState;
|
||||
blendState?: BlendState;
|
||||
dynamicStates?: DynamicStateFlags;
|
||||
phase?: string | number;
|
||||
pass?: string;
|
||||
}
|
||||
export interface IPassInfo extends IPassStates {
|
||||
program: string; // auto-generated from 'vert' and 'frag'
|
||||
embeddedMacros?: MacroRecord;
|
||||
propertyIndex?: number;
|
||||
switch?: string;
|
||||
properties?: Record<string, IPropertyInfo>;
|
||||
shader?: IShaderInfo;
|
||||
}
|
||||
export interface ITechniqueInfo {
|
||||
passes: IPassInfo[];
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface IBlockInfo {
|
||||
binding: number;
|
||||
name: string;
|
||||
members: Uniform[];
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface ISamplerTextureInfo {
|
||||
binding: number;
|
||||
name: string;
|
||||
type: Type;
|
||||
count: number;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface ISamplerInfo {
|
||||
set: number;
|
||||
binding: number;
|
||||
name: string;
|
||||
count: number;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface ITextureInfo {
|
||||
set: number;
|
||||
binding: number;
|
||||
name: string;
|
||||
type: Type;
|
||||
count: number;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface IBufferInfo {
|
||||
binding: number;
|
||||
name: string;
|
||||
memoryAccess: MemoryAccess;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface IImageInfo {
|
||||
binding: number;
|
||||
name: string;
|
||||
type: Type;
|
||||
count: number;
|
||||
memoryAccess: MemoryAccess;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
|
||||
export interface IInputAttachmentInfo {
|
||||
set: number;
|
||||
binding: number;
|
||||
name: string;
|
||||
count: number;
|
||||
stageFlags: ShaderStageFlags;
|
||||
}
|
||||
export interface IAttributeInfo {
|
||||
name: string;
|
||||
format: Format;
|
||||
isNormalized: boolean;
|
||||
stream: number;
|
||||
isInstanced: boolean;
|
||||
location: number;
|
||||
defines: string[];
|
||||
}
|
||||
export interface IDefineInfo {
|
||||
name: string;
|
||||
type: string;
|
||||
range?: number[];
|
||||
options?: string[];
|
||||
default?: string;
|
||||
}
|
||||
export interface IBuiltin {
|
||||
name: string;
|
||||
defines: string[];
|
||||
binding?: number;
|
||||
}
|
||||
export interface IBuiltinInfo {
|
||||
buffers: IBuiltin[];
|
||||
blocks: IBuiltin[];
|
||||
samplerTextures: IBuiltin[];
|
||||
images: IBuiltin[];
|
||||
}
|
||||
export interface IDescriptorInfo {
|
||||
rate: number;
|
||||
blocks: IBlockInfo[];
|
||||
samplerTextures: ISamplerTextureInfo[];
|
||||
samplers: ISamplerInfo[];
|
||||
textures: ITextureInfo[];
|
||||
buffers: IBufferInfo[];
|
||||
images: IImageInfo[];
|
||||
subpassInputs: IInputAttachmentInfo[];
|
||||
}
|
||||
export interface IShaderInfo {
|
||||
name: string;
|
||||
hash: number;
|
||||
glsl4: { vert: string, frag: string, compute?: string };
|
||||
glsl3: { vert: string, frag: string, compute?: string };
|
||||
glsl1: { vert: string, frag: string };
|
||||
builtins: { globals: IBuiltinInfo, locals: IBuiltinInfo, statistics: Record<string, number> };
|
||||
defines: IDefineInfo[];
|
||||
attributes: IAttributeInfo[];
|
||||
blocks: IBlockInfo[];
|
||||
samplerTextures: ISamplerTextureInfo[];
|
||||
samplers: ISamplerInfo[];
|
||||
textures: ITextureInfo[];
|
||||
buffers: IBufferInfo[];
|
||||
images: IImageInfo[];
|
||||
subpassInputs: IInputAttachmentInfo[];
|
||||
descriptors: IDescriptorInfo[];
|
||||
}
|
||||
export interface IPreCompileInfo {
|
||||
[name: string]: boolean[] | number[] | string[];
|
||||
}
|
||||
}
|
||||
|
||||
// handle meta data, it is generated automatically
|
||||
patch_cc_EffectAsset({EffectAsset})
|
||||
|
||||
@@ -65,7 +65,8 @@ function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElem
|
||||
return imageSource instanceof jsbWindow.HTMLImageElement || imageSource instanceof jsbWindow.HTMLCanvasElement || isImageBitmap(imageSource);
|
||||
}
|
||||
|
||||
const imageAssetProto = ImageAsset.prototype;
|
||||
// TODO: we mark imageAssetProto as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const imageAssetProto: any = ImageAsset.prototype;
|
||||
|
||||
imageAssetProto._ctor = function (nativeAsset?: ImageSource) {
|
||||
jsb.Asset.prototype._ctor.apply(this, arguments);
|
||||
|
||||
@@ -478,7 +478,7 @@ export class ImageAsset extends Asset {
|
||||
* @zh 此图像资源的图像数据。
|
||||
*/
|
||||
get data () {
|
||||
if (this._nativeData && isNativeImage(this._nativeData)) {
|
||||
if (isNativeImage(this._nativeData)) {
|
||||
return this._nativeData;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ export interface IFlatBuffer {
|
||||
export type RenderingSubMesh = JsbRenderingSubMesh;
|
||||
export const RenderingSubMesh: typeof JsbRenderingSubMesh = jsb.RenderingSubMesh;
|
||||
|
||||
const renderingSubMeshProto = RenderingSubMesh.prototype;
|
||||
// TODO: we mark renderingSubMeshProto as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const renderingSubMeshProto: any = RenderingSubMesh.prototype;
|
||||
|
||||
renderingSubMeshProto._ctor = function (vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
|
||||
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null) {
|
||||
|
||||
@@ -77,7 +77,8 @@ texture2DProto._serialize = function (ctxForExporting: any) {
|
||||
|
||||
texture2DProto._deserialize = function (serializedData: any, handle: any) {
|
||||
const data = serializedData as ITexture2DSerializeData;
|
||||
TextureBase.prototype._deserialize.call(this, data.base);
|
||||
// NOTE: _deserialize expect 3 arguments
|
||||
TextureBase.prototype._deserialize.call(this, data.base, undefined);
|
||||
|
||||
this._mipmaps = new Array(data.mipmaps.length);
|
||||
for (let i = 0; i < data.mipmaps.length; ++i) {
|
||||
|
||||
@@ -141,7 +141,8 @@ export const getset = (() => {
|
||||
setter = undefined;
|
||||
}
|
||||
descriptor.get = getter;
|
||||
descriptor.set = setter;
|
||||
// TODO: on OH platform, strictNullCheck compiler option is false, so we need to force inferring as Setter type. @PP_Pro
|
||||
descriptor.set = setter as Setter;
|
||||
descriptor.enumerable = enumerable;
|
||||
descriptor.configurable = configurable;
|
||||
Object.defineProperty(object, propertyName, descriptor);
|
||||
|
||||
@@ -551,8 +551,10 @@ export class BlendTarget {
|
||||
}
|
||||
|
||||
export class BlendState {
|
||||
private targets: BlendTarget[];
|
||||
private _blendColor: Color;
|
||||
// NOTE: not initialize in constructor
|
||||
public targets!: BlendTarget[];
|
||||
// NOTE: not initialize in constructor
|
||||
private _blendColor!: Color;
|
||||
protected _nativeObj;
|
||||
protected _isA2C: boolean = false;
|
||||
protected _isIndepend: boolean = false;
|
||||
@@ -647,7 +649,8 @@ export class BlendState {
|
||||
for (let i = 0, len = this.targets.length; i < len; ++i) {
|
||||
this.targets[i].destroy();
|
||||
}
|
||||
this.targets = null;
|
||||
// NOTE: Type 'null' is not assignable to type 'BlendTarget[]'.
|
||||
this.targets = null as any;
|
||||
this._nativeObj = null;
|
||||
}
|
||||
}
|
||||
@@ -23,13 +23,18 @@
|
||||
*/
|
||||
import { Mat3, Vec3, _decorator } from "../../core";
|
||||
import { patch_cc_CircumSphere, patch_cc_Tetrahedron, patch_cc_Vertex } from "../../native-binding/decorators";
|
||||
import type { Vertex as JsbVertex, CircumSphere as JsbCircumSphere, Tetrahedron as JsbTetrahedron } from './delaunay';
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export const Vertex = jsb.Vertex;
|
||||
export const Vertex: typeof JsbVertex = jsb.Vertex;
|
||||
export type Vertex = JsbVertex;
|
||||
patch_cc_Vertex({Vertex, Vec3});
|
||||
|
||||
export const CircumSphere = jsb.CircumSphere;
|
||||
export const CircumSphere: typeof JsbCircumSphere = jsb.CircumSphere;
|
||||
export type CircumSphere = JsbCircumSphere;
|
||||
patch_cc_CircumSphere({CircumSphere, Vec3});
|
||||
|
||||
export const Tetrahedron = jsb.Tetrahedron;
|
||||
export const Tetrahedron: typeof JsbTetrahedron = jsb.Tetrahedron;
|
||||
export type Tetrahedron = JsbTetrahedron;
|
||||
patch_cc_Tetrahedron({Tetrahedron, Mat3, Vec3, CircumSphere});
|
||||
@@ -24,13 +24,16 @@
|
||||
import { _decorator } from '../../core';
|
||||
import { patch_cc_LightProbesData } from '../../native-binding/decorators';
|
||||
import { Tetrahedron, Vertex } from './delaunay';
|
||||
import type { LightProbes as JsbLightProbes, LightProbesData as JsbLightProbesData } from './light-probe';
|
||||
|
||||
|
||||
export const LightProbes = jsb.LightProbes;
|
||||
declare const jsb: any;
|
||||
export const LightProbes: typeof JsbLightProbes = jsb.LightProbes;
|
||||
export type LightProbes = JsbLightProbes;
|
||||
_decorator.ccclass('cc.LightProbes')(LightProbes);
|
||||
// patch_cc_LightProbes({LightProbes}); // not exists
|
||||
|
||||
export const LightProbesData = jsb.LightProbesData;
|
||||
export const LightProbesData: typeof JsbLightProbesData = jsb.LightProbesData;
|
||||
export type LightProbesData = JsbLightProbesData;
|
||||
|
||||
patch_cc_LightProbesData({LightProbesData, Vertex, Tetrahedron});
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
|
||||
import { API, } from '../../gfx';
|
||||
import { cclegacy } from '../../core';
|
||||
import type { EffectAsset } from '../../asset/assets/effect-asset';
|
||||
import type { Attribute, ShaderInfo, DescriptorSetLayout, DescriptorSetLayoutBinding, PipelineLayout } from '../../gfx';
|
||||
import type { IDefineRecord } from './program-lib';
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export interface ITemplateInfo {
|
||||
gfxAttributes: Attribute[];
|
||||
|
||||
@@ -22,9 +22,12 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
import { Vec3, Enum, cclegacy } from '../../core';
|
||||
import type { LODData as JsbLODData, LODGroup as JsbLODGroup } from './lod-group';
|
||||
|
||||
export const LODData = jsb.LODData;
|
||||
export const LODGroup = jsb.LODGroup;
|
||||
export const LODData: typeof JsbLODData = jsb.LODData;
|
||||
export type LODData = JsbLODData;
|
||||
export const LODGroup: typeof JsbLODGroup = jsb.LODGroup;
|
||||
export type LODGroup = JsbLODGroup;
|
||||
|
||||
import type {
|
||||
Ambient as JsbAmbient,
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
*/
|
||||
import { ClearFlagBit } from '../../gfx';
|
||||
import { SKYBOX_FLAG } from './camera';
|
||||
import type { ReflectionProbe as JsbReflectionProbe } from './reflection-probe';
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export enum ProbeClearFlag {
|
||||
@@ -35,7 +37,8 @@ export enum ProbeType {
|
||||
PLANAR = 1,
|
||||
}
|
||||
|
||||
export const ReflectionProbe = jsb.ReflectionProbe;
|
||||
export const ReflectionProbe: typeof JsbReflectionProbe = jsb.ReflectionProbe;
|
||||
export type ReflectionProbe = JsbReflectionProbe;
|
||||
const reflectionProbeProto: any = jsb.ReflectionProbe.prototype;
|
||||
reflectionProbeProto._ctor = function (id:number) {
|
||||
this._probeId = id;
|
||||
|
||||
@@ -21,5 +21,9 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
import type { SubModel as JsbSubModel } from './submodel';
|
||||
|
||||
export const SubModel = jsb.SubModel;
|
||||
declare const jsb: any;
|
||||
|
||||
export type SubModel = JsbSubModel;
|
||||
export const SubModel: typeof JsbSubModel = jsb.SubModel;
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
import { cclegacy } from '../core';
|
||||
import type { GeometryRenderer as JsbGeometryRenderer } from './geometry-renderer';
|
||||
|
||||
export const GeometryRenderer = jsb.GeometryRenderer;
|
||||
declare const jsb: any;
|
||||
|
||||
export const GeometryRenderer: typeof JsbGeometryRenderer = jsb.GeometryRenderer;
|
||||
export type GeometryRenderer = JsbGeometryRenderer;
|
||||
cclegacy.GeometryRenderer = jsb.GeometryRenderer;
|
||||
|
||||
|
||||
@@ -25,34 +25,71 @@
|
||||
declare const nr: any;
|
||||
declare const jsb: any;
|
||||
|
||||
import { getPhaseID } from './pass-phase';
|
||||
import { ccenum, CCString, js } from '../core';
|
||||
import * as pipeline from './define';
|
||||
import { ccclass, serializable, editable, type } from '../core/data/class-decorator';
|
||||
import { legacyCC } from '../core/global-exports';
|
||||
import * as decors from '../native-binding/decorators';
|
||||
import { RenderTexture } from '../asset/assets/render-texture';
|
||||
import type {
|
||||
RenderPipeline as NrRenderPipeline,
|
||||
RenderFlow as NrRenderFlow,
|
||||
RenderStage as NrRenderStage,
|
||||
InstancedBuffer as NrInstancedBuffer,
|
||||
PipelineStateManager as NrPipelineStateManager,
|
||||
ForwardPipeline as NrForwardPipeline,
|
||||
ForwardFlow as NrForwardFlow,
|
||||
ShadowFlow as NrShadowFlow,
|
||||
ForwardStage as NrForwardStage,
|
||||
ShadowStage as NrShadowStage,
|
||||
DeferredPipeline as NrDeferredPipeline,
|
||||
MainFlow as NrMainFlow,
|
||||
LightingStage as NrLightingStage,
|
||||
PostProcessStage as NrPostProcessStage,
|
||||
GbufferStage as NrGbufferStage,
|
||||
BloomStage as NrBloomStage,
|
||||
ReflectionProbeFlow as NrReflectionProbeFlow,
|
||||
ReflectionProbeStage as NrReflectionProbeStage,
|
||||
} from './index';
|
||||
|
||||
export { pipeline };
|
||||
|
||||
nr.getPhaseID = getPhaseID;
|
||||
|
||||
export const RenderPipeline = nr.RenderPipeline;
|
||||
export const RenderFlow = nr.RenderFlow;
|
||||
export const RenderStage = nr.RenderStage;
|
||||
export const InstancedBuffer = nr.InstancedBuffer;
|
||||
export const PipelineStateManager = nr.PipelineStateManager;
|
||||
export const ForwardPipeline = nr.ForwardPipeline;
|
||||
export const ForwardFlow = nr.ForwardFlow;
|
||||
export const ShadowFlow = nr.ShadowFlow;
|
||||
export const ForwardStage = nr.ForwardStage;
|
||||
export const ShadowStage = nr.ShadowStage;
|
||||
export const DeferredPipeline = nr.DeferredPipeline;
|
||||
export const MainFlow = nr.MainFlow;
|
||||
export const LightingStage = nr.LightingStage;
|
||||
export const PostProcessStage = nr.PostProcessStage;
|
||||
export const GbufferStage = nr.GbufferStage;
|
||||
export const BloomStage = nr.BloomStage;
|
||||
export const ReflectionProbeFlow = nr.ReflectionProbeFlow;
|
||||
export const ReflectionProbeStage = nr.ReflectionProbeStage;
|
||||
export * from './pass-phase';
|
||||
export const RenderPipeline: typeof NrRenderPipeline = nr.RenderPipeline;
|
||||
export type RenderPipeline = NrRenderPipeline;
|
||||
export const RenderFlow: typeof NrRenderFlow = nr.RenderFlow;
|
||||
export type RenderFlow = NrRenderFlow;
|
||||
export const RenderStage: typeof NrRenderStage = nr.RenderStage;
|
||||
export type RenderStage = NrRenderStage;
|
||||
export const InstancedBuffer: typeof NrInstancedBuffer = nr.InstancedBuffer;
|
||||
export type InstancedBuffer = NrInstancedBuffer;
|
||||
export const PipelineStateManager: typeof NrPipelineStateManager = nr.PipelineStateManager;
|
||||
export type PipelineStateManager = NrPipelineStateManager;
|
||||
export const ForwardPipeline: typeof NrForwardPipeline = nr.ForwardPipeline;
|
||||
export type ForwardPipeline = NrForwardPipeline;
|
||||
export const ForwardFlow: typeof NrForwardFlow = nr.ForwardFlow;
|
||||
export type ForwardFlow = NrForwardFlow;
|
||||
export const ShadowFlow: typeof NrShadowFlow = nr.ShadowFlow;
|
||||
export type ShadowFlow = NrShadowFlow;
|
||||
export const ForwardStage: typeof NrForwardStage = nr.ForwardStage;
|
||||
export type ForwardStage = NrForwardStage;
|
||||
export const ShadowStage: typeof NrShadowStage = nr.ShadowStage;
|
||||
export type ShadowStage = NrShadowStage;
|
||||
export const DeferredPipeline: typeof NrDeferredPipeline = nr.DeferredPipeline;
|
||||
export type DeferredPipeline = NrDeferredPipeline;
|
||||
export const MainFlow: typeof NrMainFlow = nr.MainFlow;
|
||||
export type MainFlow = NrMainFlow;
|
||||
export const LightingStage: typeof NrLightingStage = nr.LightingStage;
|
||||
export type LightingStage = NrLightingStage;
|
||||
export const PostProcessStage: typeof NrPostProcessStage = nr.PostProcessStage;
|
||||
export type PostProcessStage = NrPostProcessStage;
|
||||
export const GbufferStage: typeof NrGbufferStage = nr.GbufferStage;
|
||||
export type GbufferStage = NrGbufferStage;
|
||||
export const BloomStage: typeof NrBloomStage = nr.BloomStage;
|
||||
export type BloomStage = NrBloomStage;
|
||||
export const ReflectionProbeFlow: typeof NrReflectionProbeFlow = nr.ReflectionProbeFlow;
|
||||
export type ReflectionProbeFlow = NrReflectionProbeFlow;
|
||||
export const ReflectionProbeStage: typeof NrReflectionProbeStage = nr.ReflectionProbeStage;
|
||||
export type ReflectionProbeStage = NrReflectionProbeStage;
|
||||
export { PipelineEventType } from './pipeline-event';
|
||||
|
||||
interface IRenderFlowInfo {
|
||||
@@ -79,7 +116,8 @@ nr.PipelineStateManager.getOrCreatePipelineState = function (device, pass, shade
|
||||
};
|
||||
|
||||
// ForwardPipeline
|
||||
const forwardPipelineProto = ForwardPipeline.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const forwardPipelineProto: any = ForwardPipeline.prototype;
|
||||
forwardPipelineProto._ctor = function () {
|
||||
this._tag = 0;
|
||||
this._flows = [];
|
||||
@@ -104,7 +142,8 @@ forwardPipelineProto.onLoaded = function () {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const forwardFlowProto = ForwardFlow.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const forwardFlowProto: any = ForwardFlow.prototype;
|
||||
forwardFlowProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -119,7 +158,8 @@ forwardFlowProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const shadowFlowProto = ShadowFlow.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const shadowFlowProto: any = ShadowFlow.prototype;
|
||||
shadowFlowProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -134,7 +174,9 @@ shadowFlowProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const reflectionProbeFlowProto = ReflectionProbeFlow.prototype;
|
||||
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const reflectionProbeFlowProto: any = ReflectionProbeFlow.prototype;
|
||||
reflectionProbeFlowProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -149,7 +191,9 @@ reflectionProbeFlowProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const forwardStageProto = ForwardStage.prototype;
|
||||
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const forwardStageProto: any = ForwardStage.prototype;
|
||||
forwardStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -166,14 +210,17 @@ forwardStageProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const shadowStageProto = ShadowStage.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const shadowStageProto: any = ShadowStage.prototype;
|
||||
shadowStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
this._tag = 0;
|
||||
}
|
||||
|
||||
const reflectionProbeStage = ReflectionProbeStage.prototype;
|
||||
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const reflectionProbeStage: any = ReflectionProbeStage.prototype;
|
||||
reflectionProbeStage._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -235,7 +282,8 @@ export class RenderQueueDesc {
|
||||
}
|
||||
}
|
||||
|
||||
const deferredPipelineProto = DeferredPipeline.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const deferredPipelineProto: any = DeferredPipeline.prototype;
|
||||
deferredPipelineProto._ctor = function () {
|
||||
this._tag = 0;
|
||||
this._flows = [];
|
||||
@@ -255,7 +303,9 @@ deferredPipelineProto.onLoaded = function () {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const mainFlowProto = MainFlow.prototype;
|
||||
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const mainFlowProto: any = MainFlow.prototype;
|
||||
mainFlowProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -270,7 +320,8 @@ mainFlowProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const gbufferStageProto = GbufferStage.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const gbufferStageProto: any = GbufferStage.prototype;
|
||||
gbufferStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -287,8 +338,8 @@ gbufferStageProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
|
||||
const lightingStageProto = LightingStage.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const lightingStageProto: any = LightingStage.prototype;
|
||||
lightingStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -307,7 +358,8 @@ lightingStageProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const bloomStageProto = BloomStage.prototype;
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const bloomStageProto: any = BloomStage.prototype;
|
||||
bloomStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -326,7 +378,9 @@ bloomStageProto.init = function (pipeline) {
|
||||
this.initialize(info);
|
||||
}
|
||||
|
||||
const postProcessStageProto = PostProcessStage.prototype;
|
||||
|
||||
// TODO: we mark it as type of any, because here we have many dynamic injected property @dumganhar
|
||||
const postProcessStageProto: any = PostProcessStage.prototype;
|
||||
postProcessStageProto._ctor = function () {
|
||||
this._name = 0;
|
||||
this._priority = 0;
|
||||
@@ -350,8 +404,6 @@ legacyCC.RenderFlow = RenderFlow;
|
||||
legacyCC.RenderStage = RenderStage;
|
||||
legacyCC.RenderPipeline = RenderPipeline;
|
||||
|
||||
|
||||
const RenderTexture: any = jsb.RenderTexture;
|
||||
@ccclass('RenderTextureConfig')
|
||||
class RenderTextureConfig {
|
||||
@serializable
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2020-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
declare const nr: any;
|
||||
|
||||
export const getPhaseID = nr.getPhaseID;
|
||||
@@ -23,6 +23,18 @@
|
||||
*/
|
||||
|
||||
import { cclegacy } from '../core';
|
||||
export const RenderPipeline = nr.RenderPipeline;
|
||||
import { RenderPipeline as NrRenderPipeline } from './render-pipeline';
|
||||
import { Buffer, InputAssembler } from '../gfx';
|
||||
|
||||
declare const nr: any;
|
||||
|
||||
export const RenderPipeline: typeof NrRenderPipeline = nr.RenderPipeline;
|
||||
export type RenderPipeline = NrRenderPipeline;
|
||||
// Do not delete, for the class detection of editor
|
||||
cclegacy.RenderPipeline = RenderPipeline;
|
||||
|
||||
export class PipelineInputAssemblerData {
|
||||
quadIB: Buffer|null = null;
|
||||
quadVB: Buffer|null = null;
|
||||
quadIA: InputAssembler|null = null;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,20 @@
|
||||
declare var nr:any;
|
||||
|
||||
import { legacyCC } from '../core/global-exports';
|
||||
export const RenderStage = nr.RenderStage;
|
||||
import type { RenderStage as NrRenderStage } from './render-stage';
|
||||
import type { RenderQueueDesc } from './pipeline-serialization';
|
||||
export const RenderStage: typeof NrRenderStage = nr.RenderStage;
|
||||
export type RenderStage = NrRenderStage;
|
||||
// Do not delete, for the class detection of editor
|
||||
legacyCC.RenderStage = RenderStage;
|
||||
|
||||
/**
|
||||
* @en The render stage information descriptor
|
||||
* @zh 渲染阶段描述信息。
|
||||
*/
|
||||
export interface IRenderStageInfo {
|
||||
name: string;
|
||||
priority: number;
|
||||
tag?: number;
|
||||
renderQueues?: RenderQueueDesc[];
|
||||
}
|
||||
@@ -188,7 +188,8 @@ nodeProto.addComponent = function (typeOrClassName) {
|
||||
|
||||
// check requirement
|
||||
|
||||
const ReqComp = (constructor)._requireComponent;
|
||||
// TODO: `_requireComponent` is injected properties
|
||||
const ReqComp = (constructor as any)._requireComponent;
|
||||
if (ReqComp && !this.getComponent(ReqComp)) {
|
||||
this.addComponent(ReqComp);
|
||||
}
|
||||
@@ -1271,7 +1272,9 @@ nodeProto._instantiate = function (cloned: Node, isSyncedNode: boolean) {
|
||||
cloned = legacyCC.instantiate._clone(this, this);
|
||||
}
|
||||
|
||||
const newPrefabInfo = cloned._prefab;
|
||||
// TODO(PP_Pro): after we support editorOnly tag, we could remove this any type assertion.
|
||||
// Tracking issue: https://github.com/cocos/cocos-engine/issues/14613
|
||||
const newPrefabInfo = (cloned as any)._prefab;
|
||||
if (EDITOR && newPrefabInfo) {
|
||||
if (cloned === newPrefabInfo.root) {
|
||||
// newPrefabInfo.fileId = '';
|
||||
|
||||
@@ -28,6 +28,17 @@ import { Ambient, EnvironmentLightingType } from '../render-scene/scene';
|
||||
import { Material } from '../asset/assets/material';
|
||||
import { Vec2, Vec3, Color, Vec4 } from '../core/math';
|
||||
import * as decros from '../native-binding/decorators';
|
||||
import type {
|
||||
AmbientInfo as JsbAmbientInfo,
|
||||
SkyboxInfo as JsbSkyboxInfo,
|
||||
FogInfo as JsbFogInfo,
|
||||
ShadowsInfo as JsbShadowsInfo,
|
||||
OctreeInfo as JsbOctreeInfo,
|
||||
SceneGlobals as JsbSceneGlobals,
|
||||
LightProbeInfo as JsbLightProbeInfo,
|
||||
} from './scene-globals';
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export const DEFAULT_WORLD_MIN_POS = new Vec3(-1024.0, -1024.0, -1024.0);
|
||||
export const DEFAULT_WORLD_MAX_POS = new Vec3(1024.0, 1024.0, 1024.0);
|
||||
@@ -135,34 +146,34 @@ export const ShadowType = Enum({
|
||||
ShadowMap: 1,
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
export const AmbientInfo = jsb.AmbientInfo;
|
||||
export const AmbientInfo: typeof JsbAmbientInfo = jsb.AmbientInfo;
|
||||
export type AmbientInfo = JsbAmbientInfo;
|
||||
legacyCC.AmbientInfo = AmbientInfo;
|
||||
|
||||
// @ts-ignore
|
||||
export const SkyboxInfo = jsb.SkyboxInfo;
|
||||
export const SkyboxInfo: typeof JsbSkyboxInfo = jsb.SkyboxInfo;
|
||||
export type SkyboxInfo = JsbSkyboxInfo;
|
||||
legacyCC.SkyboxInfo = SkyboxInfo;
|
||||
|
||||
|
||||
// @ts-ignore
|
||||
export const FogInfo = jsb.FogInfo;
|
||||
export const FogInfo: typeof JsbFogInfo = jsb.FogInfo;
|
||||
export type FogInfo = JsbFogInfo;
|
||||
legacyCC.FogInfo = FogInfo;
|
||||
FogInfo.FogType = FogType;
|
||||
|
||||
// @ts-ignore
|
||||
export const ShadowsInfo = jsb.ShadowsInfo;
|
||||
export const ShadowsInfo: typeof JsbShadowsInfo = jsb.ShadowsInfo;
|
||||
export type ShadowsInfo = JsbShadowsInfo;
|
||||
legacyCC.ShadowsInfo = ShadowsInfo;
|
||||
|
||||
// @ts-ignore
|
||||
export const OctreeInfo = jsb.OctreeInfo;
|
||||
export const OctreeInfo: typeof JsbOctreeInfo = jsb.OctreeInfo;
|
||||
export type OctreeInfo = JsbOctreeInfo;
|
||||
legacyCC.OctreeInfo = OctreeInfo;
|
||||
|
||||
// @ts-ignore
|
||||
export const LightProbeInfo = jsb.LightProbeInfo;
|
||||
export const LightProbeInfo: typeof JsbLightProbeInfo = jsb.LightProbeInfo;
|
||||
export type LightProbeInfo = JsbLightProbeInfo;
|
||||
//legacyCC.LightProbeInfo = LightProbeInfo;
|
||||
|
||||
// @ts-ignore
|
||||
export const SceneGlobals = jsb.SceneGlobals;
|
||||
export const SceneGlobals: typeof JsbSceneGlobals = jsb.SceneGlobals;
|
||||
export type SceneGlobals = JsbSceneGlobals;
|
||||
legacyCC.SceneGlobals = SceneGlobals;
|
||||
|
||||
(function () {
|
||||
@@ -266,7 +277,7 @@ legacyCC.SceneGlobals = SceneGlobals;
|
||||
|
||||
// handle meta data, it is generated automatically
|
||||
|
||||
decros.patch_cc_SceneGlobals({SceneGlobals, AmbientInfo, SkyboxInfo, FogInfo, ShadowsInfo, LightProbeInfo, OctreeInfo, LightProbeInfo});
|
||||
decros.patch_cc_SceneGlobals({SceneGlobals, AmbientInfo, SkyboxInfo, FogInfo, ShadowsInfo, LightProbeInfo, OctreeInfo});
|
||||
|
||||
decros.patch_cc_OctreeInfo({OctreeInfo, CCInteger, Vec3, DEFAULT_WORLD_MAX_POS, DEFAULT_WORLD_MIN_POS, DEFAULT_OCTREE_DEPTH});
|
||||
|
||||
|
||||
@@ -477,7 +477,8 @@ class _Deserializer {
|
||||
case 'TypedArrayRef':
|
||||
return this._deserializeTypedArrayViewRef(serialized);
|
||||
default:
|
||||
if (serialized.__type__) { // Typed object (including CCClass)
|
||||
// NOTE: when 'strictNullCheck' is false, TS can't infer serialized as SerializedGeneralTypedObject
|
||||
if ((serialized as unknown as SerializedGeneralTypedObject).__type__) { // Typed object (including CCClass)
|
||||
return this._deserializeTypeTaggedObject(serialized, globalIndex, owner, propName);
|
||||
} else if (!Array.isArray(serialized)) { // Embedded primitive javascript object
|
||||
return this._deserializePlainObject(serialized);
|
||||
|
||||
@@ -36,7 +36,7 @@ import { BlendFactor } from '../../gfx';
|
||||
import { legacyCC } from '../../core/global-exports';
|
||||
import { StaticVBAccessor } from '../../2d/renderer/static-vb-accessor';
|
||||
import { RenderData } from '../../2d/renderer/render-data';
|
||||
import { Texture2D } from '../../../typedoc-index.js';
|
||||
import { Texture2D } from '../../asset/assets/texture-2d';
|
||||
import { director } from '../../game';
|
||||
|
||||
const _quadTriangles = [0, 1, 2, 2, 3, 0];
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { AudioType, AudioState, AudioEvent, AudioPCMDataView, AudioBufferView } from '../type';
|
||||
import { AudioType, AudioState, AudioEvent, AudioPCMDataView, AudioBufferView, AudioLoadOptions } from '../type';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
import { legacyCC } from '../../../cocos/core/global-exports';
|
||||
import { clamp, clamp01 } from '../../../cocos/core';
|
||||
@@ -157,14 +157,14 @@ export class AudioPlayer implements OperationQueueable {
|
||||
}).catch((e) => {});
|
||||
}
|
||||
}
|
||||
static load (url: string): Promise<AudioPlayer> {
|
||||
static load (url: string, opts?: AudioLoadOptions): Promise<AudioPlayer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
AudioPlayer.loadNative(url).then((url) => {
|
||||
AudioPlayer.loadNative(url, opts).then((url) => {
|
||||
resolve(new AudioPlayer(url as string));
|
||||
}).catch((err) => reject(err));
|
||||
});
|
||||
}
|
||||
static loadNative (url: string): Promise<unknown> {
|
||||
static loadNative (url: string, opts?: AudioLoadOptions): Promise<unknown> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (systemInfo.platform === Platform.WIN32) {
|
||||
// NOTE: audioEngine.preload() not works well on Win32 platform.
|
||||
@@ -184,9 +184,9 @@ export class AudioPlayer implements OperationQueueable {
|
||||
}
|
||||
});
|
||||
}
|
||||
static loadOneShotAudio (url: string, volume: number): Promise<OneShotAudio> {
|
||||
static loadOneShotAudio (url: string, volume: number, opts?: AudioLoadOptions): Promise<OneShotAudio> {
|
||||
return new Promise((resolve, reject) => {
|
||||
AudioPlayer.loadNative(url).then((url) => {
|
||||
AudioPlayer.loadNative(url, opts).then((url) => {
|
||||
// HACK: AudioPlayer should be a friend class in OneShotAudio
|
||||
resolve(new (OneShotAudio as any)(url, volume));
|
||||
}).catch(reject);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { AccelerometerCallback } from 'pal/input';
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { screenAdapter } from 'pal/screen-adapter';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
@@ -31,6 +30,8 @@ import { Orientation } from '../../screen-adapter/enum-type';
|
||||
import { Acceleration, EventAcceleration } from '../../../cocos/input/types';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
|
||||
export type AccelerometerCallback = (res: EventAcceleration) => void;
|
||||
|
||||
export class AccelerometerInputSource {
|
||||
private _intervalInSeconds = 0.2;
|
||||
private _intervalId? :number;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
*/
|
||||
|
||||
/* eslint-disable brace-style */
|
||||
import { GamepadCallback } from 'pal/input';
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
import { Feature } from '../../system-info/enum-type';
|
||||
@@ -32,6 +31,8 @@ import { EventGamepad } from '../../../cocos/input/types';
|
||||
import { InputSourceButton, InputSourceDpad, InputSourceStick } from '../input-source';
|
||||
import { js } from '../../../cocos/core';
|
||||
|
||||
export type GamepadCallback = (res: EventGamepad) => void;
|
||||
|
||||
enum Button {
|
||||
BUTTON_SOUTH,
|
||||
BUTTON_EAST,
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { HandheldCallback } from 'pal/input';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
import { EventHandheld } from '../../../cocos/input/types';
|
||||
import { InputSourcePosition, InputSourceOrientation } from '../input-source';
|
||||
import { Vec3, Quat } from '../../../cocos/core/math';
|
||||
|
||||
export type HandheldCallback = (res: EventHandheld) => void;
|
||||
|
||||
enum Pose {
|
||||
AR_MOBILE,
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { HandleCallback } from 'pal/input';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
import { EventHandle } from '../../../cocos/input/types';
|
||||
import { InputSourceButton, InputSourceStick, InputSourcePosition, InputSourceOrientation } from '../input-source';
|
||||
import { Vec3, Quat } from '../../../cocos/core/math';
|
||||
|
||||
export type HandleCallback = (res: EventHandle) => void;
|
||||
|
||||
enum Button {
|
||||
BUTTON_EAST,
|
||||
BUTTON_SOUTH,
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { HMDCallback } from 'pal/input';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
import { EventHMD } from '../../../cocos/input/types';
|
||||
import { InputSourcePosition, InputSourceOrientation } from '../input-source';
|
||||
import { Vec3, Quat } from '../../../cocos/core/math';
|
||||
|
||||
export type HMDCallback = (res: EventHMD) => void;
|
||||
|
||||
enum Pose {
|
||||
VIEW_LEFT,
|
||||
VIEW_RIGHT,
|
||||
|
||||
@@ -22,12 +22,13 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { KeyboardCallback } from 'pal/input';
|
||||
import { systemInfo } from 'pal/system-info';
|
||||
import { KeyCode, EventKeyboard } from '../../../cocos/input/types';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
|
||||
export type KeyboardCallback = (res: EventKeyboard) => void;
|
||||
|
||||
const nativeKeyCode2KeyCode: Record<number, KeyCode> = {
|
||||
12: KeyCode.NUM_LOCK,
|
||||
10048: KeyCode.NUM_0,
|
||||
|
||||
@@ -22,13 +22,14 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { MouseCallback } from 'pal/input';
|
||||
import { screenAdapter } from 'pal/screen-adapter';
|
||||
import { EventMouse } from '../../../cocos/input/types';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
import { Vec2 } from '../../../cocos/core/math';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
|
||||
export type MouseCallback = (res: EventMouse) => void;
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export class MouseInputSource {
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { TouchCallback } from 'pal/input';
|
||||
import { screenAdapter } from 'pal/screen-adapter';
|
||||
import { Size, Vec2 } from '../../../cocos/core/math';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
@@ -31,6 +30,8 @@ import { touchManager } from '../touch-manager';
|
||||
import { macro } from '../../../cocos/core/platform/macro';
|
||||
import { InputEventType } from '../../../cocos/input/types/event-enum';
|
||||
|
||||
export type TouchCallback = (res: EventTouch) => void;
|
||||
|
||||
declare const jsb: any;
|
||||
|
||||
export class TouchInputSource {
|
||||
|
||||
@@ -22,7 +22,5 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { IMiniGame } from 'pal/minigame';
|
||||
|
||||
const minigame: IMiniGame = {} as IMiniGame;
|
||||
const minigame: any = {};
|
||||
export { minigame };
|
||||
|
||||
@@ -37,8 +37,7 @@ const languageMap: Record<string, Language> = {
|
||||
|
||||
declare let my: any;
|
||||
|
||||
// @ts-expect-error can't init minigame when it's declared
|
||||
const minigame: IMiniGame = {};
|
||||
const minigame: IMiniGame = {} as IMiniGame;
|
||||
cloneObject(minigame, my);
|
||||
|
||||
// #region SystemInfo
|
||||
@@ -75,17 +74,15 @@ Object.defineProperty(minigame, 'orientation', {
|
||||
});
|
||||
// #endregion SystemInfo
|
||||
|
||||
// @ts-expect-error TODO: move into minigame.d.ts
|
||||
minigame.isSupportLandscape = function () {
|
||||
function detectLandscapeSupport () {
|
||||
const locSysInfo = minigame.getSystemInfoSync();
|
||||
if (typeof locSysInfo.deviceOrientation === 'string' && locSysInfo.deviceOrientation.startsWith('landscape')) {
|
||||
if (versionCompare(locSysInfo.version, '10.15.10') < 0) {
|
||||
console.warn('The current Taobao client version does not support Landscape, the minimum requirement is 10.15.10');
|
||||
}
|
||||
}
|
||||
};
|
||||
// @ts-expect-error TODO: Check whether the landscape screen is supported
|
||||
minigame.isSupportLandscape();
|
||||
}
|
||||
detectLandscapeSupport();
|
||||
|
||||
// #region Audio
|
||||
const polyfilledCreateInnerAudio = createInnerAudioContextPolyfill(my, {
|
||||
@@ -95,12 +92,12 @@ const polyfilledCreateInnerAudio = createInnerAudioContextPolyfill(my, {
|
||||
onSeek: false,
|
||||
}, true);
|
||||
minigame.createInnerAudioContext = function (): InnerAudioContext {
|
||||
const audio: InnerAudioContext = polyfilledCreateInnerAudio();
|
||||
// @ts-expect-error InnerAudioContext has onCanPlay
|
||||
// NOTE: `onCanPlay` is not standard minigame interface,
|
||||
// so here we mark audio as type of any
|
||||
const audio: any = polyfilledCreateInnerAudio();
|
||||
audio.onCanplay = audio.onCanPlay.bind(audio);
|
||||
// @ts-expect-error InnerAudioContext has onCanPlay
|
||||
delete audio.onCanPlay;
|
||||
return audio;
|
||||
return audio as InnerAudioContext;
|
||||
};
|
||||
// #region Audio
|
||||
|
||||
@@ -173,9 +170,10 @@ minigame.getSafeArea = function () {
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
declare const $global: any; // global variable on Taobao platform.
|
||||
|
||||
// TODO: A filpY operation will be performed after ReadPixels on Taobao.
|
||||
if (!my.isIDE) {
|
||||
// @ts-expect-error canvas defined in global
|
||||
const locCanvas = $global.screencanvas;
|
||||
if (locCanvas) {
|
||||
const originalGetContext = locCanvas.getContext.bind(locCanvas);
|
||||
|
||||
@@ -23,11 +23,35 @@
|
||||
*/
|
||||
|
||||
import { EDITOR } from 'internal:constants';
|
||||
import { ConfigOrientation, IScreenOptions, SafeAreaEdge } from 'pal/screen-adapter';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
import { Size } from '../../../cocos/core/math';
|
||||
import { Orientation } from '../enum-type';
|
||||
|
||||
export interface SafeAreaEdge {
|
||||
top: number;
|
||||
bottom: number;
|
||||
left: number;
|
||||
right: number;
|
||||
}
|
||||
|
||||
export type ConfigOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
|
||||
export interface IScreenOptions {
|
||||
/**
|
||||
* Orientation options from editor builder.
|
||||
*/
|
||||
configOrientation: ConfigOrientation;
|
||||
/**
|
||||
* Determine whether the game frame exact fits the screen.
|
||||
* Now it only works on Web platform.
|
||||
*/
|
||||
exactFitScreen: boolean,
|
||||
/**
|
||||
* Determine whether use headless renderer, which means do not support some screen operations.
|
||||
*/
|
||||
isHeadlessMode: boolean;
|
||||
}
|
||||
|
||||
// these value is defined in the native layer
|
||||
const orientationMap: Record<string, Orientation> = {
|
||||
0: Orientation.PORTRAIT,
|
||||
@@ -54,10 +78,10 @@ class ScreenAdapter extends EventTarget {
|
||||
public get windowSize (): Size {
|
||||
const dpr = this.devicePixelRatio;
|
||||
// NOTE: fix precision issue on Metal render end.
|
||||
// @ts-expect-error interface for OH only
|
||||
const width = globalThis.oh ? jsb.device.getInnerWidth() : jsb.window.innerWidth;
|
||||
// @ts-expect-error interface for OH only
|
||||
const height = globalThis.oh ? jsb.device.getInnerHeight() : jsb.window.innerHeight;
|
||||
// TODO: interface for OH only, we need a unified interface @qiuguohua
|
||||
const width = globalThis.oh ? (jsb.device as any).getInnerWidth() : jsb.window.innerWidth;
|
||||
// TODO: interface for OH only, we need a unified interface @qiuguohua
|
||||
const height = globalThis.oh ? (jsb.device as any).getInnerHeight() : jsb.window.innerHeight;
|
||||
// NOTE: fix precision issue on Metal render end.
|
||||
const roundWidth = Math.round(width);
|
||||
const roundHeight = Math.round(height);
|
||||
|
||||
@@ -22,10 +22,13 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { IFeatureMap } from 'pal/system-info';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
import { BrowserType, NetworkType, OS, Platform, Language, Feature } from '../enum-type';
|
||||
|
||||
type IFeatureMap = {
|
||||
[feature in Feature]: boolean;
|
||||
};
|
||||
|
||||
// NOTE: these methods are implemented on native.
|
||||
declare function __getPlatform(): string;
|
||||
declare function __getCurrentLanguageCode(): string;
|
||||
|
||||
Reference in New Issue
Block a user