Config is used to set some global parameters. If you need to change them, please set them before initializing the engine.

Config类用于配置一些全局参数。如需更改,请在初始化引擎之前设置。

构造函数

属性

animationInterval: number = 50

Default playback interval for 2D animation, in milliseconds.

2D动画 Animation 的默认播放时间间隔,单位为毫秒。

audioBufferCacheMaxSize: number = ...

The maximum size of the audio buffer cache in bytes. After exceeding this size, the oldest unused audio data in the cache will be cleared.

声音缓冲区缓存的最大大小(字节)。超出后将清除缓存中最久未使用的音频数据。

defaultFont: string = "Arial"

Default font, default is Arial

默认文本字体,默认为Arial

defaultFontSize: number = 12

Default text size, default is 12

默认文本大小,默认为12

destroyResourceImmediatelyDefault: boolean = true

Whether to immediately delete resources when the reference parameter is 0. If not immediate deletion, please call DestrotyUnUse

资源引用参数为0是否立即删除资源,如果不立即删除请调用DestrotyUnUse

enableUniformBufferObject: boolean = true

Whether to enable UniformBuffer

是否启用UniformBuffer

fixedFrames: boolean = true

Whether to use a fixed frame rate for rendering and updates.

  • When true: Rendering and logic updates are limited to the frame rate defined by Config.FPS. Ensures consistent application speed across different devices.
  • When false: Updates occur on every requestAnimationFrame callback. Can lead to varying application speeds on different devices.

是否使用固定帧率进行渲染和更新。

  • 当为 true 时:渲染和逻辑更新被限制在由 Config.FPS 定义的帧率内。确保在不同设备上应用程序运行速度一致。
  • 当为 false 时:在每次 requestAnimationFrame 回调时进行更新。可能导致在不同设备上应用程序运行速度不同。
fontFamilyMap: any = ...

On iOS, some fonts may not be found. The engine provides font mapping functionality. For example, by default, "黑体" is mapped to "黑体-简". More mappings can be added.

在iOS下,一些字体会找不到,引擎提供了字体映射功能,比如默认会把 "黑体" 映射为 "黑体-简",更多映射,可以自己添加

FPS: number = 60

FPS limit, the maximum frame rate of the engine, the default is 60. If the developer does not want to fix the logic frame rate limit, set Config.fixedFrames to false to close the fixed frame mode, so that the logic update follows the frequency of the platform's requestAnimationFrame call as much as possible.

定义了引擎全局的目标帧率上限(默认为 60)。如果开发者不希望固定逻辑帧率上限,可以将 Config.fixedFrames 设置为 false,关闭固定帧模式,使逻辑更新尽可能跟随平台的 requestAnimationFrame 调用频率执行。

isAlpha: boolean = false

Set whether the canvas is transparent, only effective for 2D(WebGL) and 3D.

设置画布是否透明,只对2D(WebGL)、3D有效。

isAntialias: boolean = true

Canvas setting for anti-aliasing, only effective for 2D(WebGL). 3D anti-aliasing is controlled on the camera or RT.

画布设置是否抗锯齿,只对2D(WebGL)有效,3D抗锯齿在camera或RT上面控制。

isDepth: boolean = false

Set whether the canvas contains depth

设置画布是否包含深度

isfailIfMajorPerformanceCaveat: boolean = false

Boolean value indicating whether to create this context in a system with low performance

表明在一个系统性能低的环境是否创建该上下文

isStencil: boolean = true

Set whether to enable stencil buffer for the canvas, only effective for 2D(WebGL) and 3D.

设置画布的是否开启模板缓冲,只对2D(WebGL)、3D有效。

matUseUBO: boolean = true

Whether to enable UniformBuffer

材质是否启用UniformBuffer

powerPreference: WebGLPowerPreference = "default"

Power preference for the WebGL/WebGPU context. Hints the browser about the desired GPU configuration.

  • "default": Let the browser decide. In WebGPU mode, this is automatically set to "high-performance".
  • "high-performance": Prefer high-performance GPU. Use for graphically intensive applications.
  • "low-power": Prefer low-power GPU. Suitable for energy-efficient applications.

图形(WebGL/WebGPU)上下文的电源偏好设置。向浏览器提示所需的 GPU 配置。

  • "default":让浏览器决定。在 WebGPU 模式下,default会让引擎自动设置为high-performance
  • "high-performance":倾向于高性能 GPU。用于图形密集型应用。
  • "low-power":倾向于低功耗 GPU。适用于节能的应用。
premultipliedAlpha: boolean = true

Set whether the canvas is pre-multiplied, only effective for 2D(WebGL) and 3D.

设置画布是否预乘,只对2D(WebGL)、3D有效。

preserveDrawingBuffer: boolean = false

Whether to preserve the drawing buffer.

是否保留渲染缓冲区。

printWebglOrder: boolean = false

Whether to print WebGL instructions and locate WebGL errors

是否打印WebGL指令,同时定位WebGL报错

useRetinalCanvas: boolean = false

Whether to use the retina mode. In retina mode, a larger canvas is created for finer display effects.

是否使用视网膜模式。在视网膜模式下,会创建更大的Canvas,来达到更精细的显示效果

useSPRIV: boolean = false

W

是否提供Spri-v的shader

useTextureArray: boolean = false

Whether to use TextureArray

是否使用TextureArray: 文字和自动图集使用TextureArray来优化

useWebGL2: boolean = true

Whether to use WebGL2

是否使用WebGL2

uvClipMode: "gpu" | "cpu" = "cpu"

UV clipping mode for 2D rendering.

  • "gpu": Use GPU fragment shader to clip triangles (default, lower CPU overhead)
  • "cpu": Use CPU Sutherland-Hodgman algorithm to clip triangles (higher CPU overhead, precise clipping)

2D渲染的UV裁剪模式。

  • "gpu": 使用GPU片元着色器裁剪三角形(默认,CPU开销低)
  • "cpu": 使用CPU Sutherland-Hodgman算法裁剪三角形(CPU开销高,精确裁剪)
webGL2D_MeshAllocMaxMem: boolean = true

When using WebGL to render 2D, whether to allocate enough cache for 64k vertices each time a VB is created. This can improve efficiency.

当使用WebGL渲染2D的时候,每次创建VB是否直接分配足够64k个顶点的缓存。这样可以提高效率。