@zephyr3d/device 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base_types.js.map +1 -1
- package/dist/builder/programbuilder.js +5 -3
- package/dist/builder/programbuilder.js.map +1 -1
- package/dist/builder/types.js +2 -2
- package/dist/builder/types.js.map +1 -1
- package/dist/device.js +26 -19
- package/dist/device.js.map +1 -1
- package/dist/helpers/drawtext.js +204 -40
- package/dist/helpers/drawtext.js.map +1 -1
- package/dist/helpers/textureatlas.js +21 -6
- package/dist/helpers/textureatlas.js.map +1 -1
- package/dist/index.d.ts +71 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Nullable, Immutable, TypedArray, IDisposable, CubeFace, VectorBase, MaybeArray, IEventTarget, Vector4, Observable } from '@zephyr3d/base';
|
|
1
|
+
import { Nullable, Immutable, TypedArray, IDisposable, CubeFace, VectorBase, MaybeArray, IEventTarget, Vector3, Vector4, Rect, Observable } from '@zephyr3d/base';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Struct layout types
|
|
@@ -1572,7 +1572,7 @@ interface ProgramBuilder {
|
|
|
1572
1572
|
* @param options - The build options
|
|
1573
1573
|
* @returns a tuple made by vertex shader source, fragment shader source, bind group layouts and vertex attributes used, or null if build faild
|
|
1574
1574
|
*/
|
|
1575
|
-
buildRender(options: PBRenderOptions): readonly [string, string, BindGroupLayout[], number[]];
|
|
1575
|
+
buildRender(options: PBRenderOptions): readonly [string, string, BindGroupLayout[], number[], number];
|
|
1576
1576
|
/**
|
|
1577
1577
|
* Generates shader code for a compute program
|
|
1578
1578
|
* @param options - The build programs
|
|
@@ -3290,6 +3290,8 @@ interface RenderProgramConstructParams {
|
|
|
3290
3290
|
vs: string;
|
|
3291
3291
|
/** The fragment shader source code */
|
|
3292
3292
|
fs: string;
|
|
3293
|
+
/** Number of fragment color outputs declared by the shader */
|
|
3294
|
+
fragmentOutputCount?: number;
|
|
3293
3295
|
/** Bind group layouts for the program */
|
|
3294
3296
|
bindGroupLayouts: BindGroupLayout[];
|
|
3295
3297
|
/** Vertex attributes used in the program */
|
|
@@ -3359,6 +3361,28 @@ type DeviceViewport = {
|
|
|
3359
3361
|
*/
|
|
3360
3362
|
default: boolean;
|
|
3361
3363
|
};
|
|
3364
|
+
/**
|
|
3365
|
+
* Horizontal alignment for text layout
|
|
3366
|
+
* @public
|
|
3367
|
+
*/
|
|
3368
|
+
type TextHorizontalAlignment = 'left' | 'center' | 'right';
|
|
3369
|
+
/**
|
|
3370
|
+
* Vertical alignment for text layout
|
|
3371
|
+
* @public
|
|
3372
|
+
*/
|
|
3373
|
+
type TextVerticalAlignment = 'top' | 'center' | 'bottom';
|
|
3374
|
+
/**
|
|
3375
|
+
* Layout options for drawing text inside a rectangle
|
|
3376
|
+
* @public
|
|
3377
|
+
*/
|
|
3378
|
+
interface DrawTextLayoutOptions {
|
|
3379
|
+
/** Horizontal alignment of each line */
|
|
3380
|
+
halign?: TextHorizontalAlignment;
|
|
3381
|
+
/** Vertical alignment of the text block */
|
|
3382
|
+
valign?: TextVerticalAlignment;
|
|
3383
|
+
/** Whether to wrap text automatically to fit the rectangle width */
|
|
3384
|
+
wordWrap?: boolean;
|
|
3385
|
+
}
|
|
3362
3386
|
/**
|
|
3363
3387
|
* Abstract interface for the rendering device.
|
|
3364
3388
|
* @public
|
|
@@ -3397,7 +3421,9 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3397
3421
|
/** Cancel schedule next frame */
|
|
3398
3422
|
cancelNextFrame(handle: number): void;
|
|
3399
3423
|
/** Set font for drawText function */
|
|
3400
|
-
setFont(fontName: string): void;
|
|
3424
|
+
setFont(fontName: Nullable<string>): void;
|
|
3425
|
+
/** Set render states to be used when drawing text. If not set, default states will be used. */
|
|
3426
|
+
setTextRenderStates(states: Nullable<RenderStateSet>): void;
|
|
3401
3427
|
/**
|
|
3402
3428
|
* Draw a string
|
|
3403
3429
|
* @param text - The string that will be drawn
|
|
@@ -3405,7 +3431,15 @@ interface AbstractDevice extends IEventTarget<DeviceEventMap> {
|
|
|
3405
3431
|
* @param y - y coordinate in pixels related to the viewport origin
|
|
3406
3432
|
* @param color - A CSS color value
|
|
3407
3433
|
*/
|
|
3408
|
-
drawText(text: string, x: number, y: number, color: string
|
|
3434
|
+
drawText(text: string, x: number, y: number, color: string | Vector3 | Vector4): void;
|
|
3435
|
+
/**
|
|
3436
|
+
* Draw a string inside a rectangle with layout and clipping
|
|
3437
|
+
* @param text - The string that will be drawn
|
|
3438
|
+
* @param rect - Layout rectangle in pixels related to the viewport origin
|
|
3439
|
+
* @param color - A CSS color value
|
|
3440
|
+
* @param options - Text layout options
|
|
3441
|
+
*/
|
|
3442
|
+
drawText(text: string, rect: Immutable<Rect>, color: string | Vector3 | Vector4, options?: DrawTextLayoutOptions): void;
|
|
3409
3443
|
/**
|
|
3410
3444
|
* Clears the current frame buffer
|
|
3411
3445
|
* @param clearColor - If not null, the color buffer will be cleared to this value.
|
|
@@ -3986,8 +4020,10 @@ declare abstract class BaseDevice extends Observable<DeviceEventMap> {
|
|
|
3986
4020
|
get programBuilder(): ProgramBuilder;
|
|
3987
4021
|
poolExists(key: string | symbol): boolean;
|
|
3988
4022
|
getPool(key: string | symbol): Pool;
|
|
3989
|
-
setFont(fontName: string): void;
|
|
3990
|
-
|
|
4023
|
+
setFont(fontName: Nullable<string>): void;
|
|
4024
|
+
setTextRenderStates(renderStates: Nullable<RenderStateSet>): void;
|
|
4025
|
+
drawText(text: string, x: number, y: number, color: string | Vector3 | Vector4): void;
|
|
4026
|
+
drawText(text: string, rect: Immutable<Rect>, color: string | Vector3 | Vector4, options?: DrawTextLayoutOptions): void;
|
|
3991
4027
|
setFramebuffer(rt: Nullable<FrameBuffer>): void;
|
|
3992
4028
|
setFramebuffer(color: BaseTexture[], depth?: BaseTexture, sampleCount?: number): void;
|
|
3993
4029
|
disposeObject(obj: GPUObject, remove?: boolean): void;
|
|
@@ -4078,6 +4114,18 @@ declare class TextureAtlasManager {
|
|
|
4078
4114
|
* @returns Atlas texture for given index
|
|
4079
4115
|
*/
|
|
4080
4116
|
getAtlasTexture(index: number): Texture2D<unknown> | undefined;
|
|
4117
|
+
/**
|
|
4118
|
+
* Width of each atlas bin in texels.
|
|
4119
|
+
*/
|
|
4120
|
+
get binWidth(): number;
|
|
4121
|
+
/**
|
|
4122
|
+
* Height of each atlas bin in texels.
|
|
4123
|
+
*/
|
|
4124
|
+
get binHeight(): number;
|
|
4125
|
+
/**
|
|
4126
|
+
* Border reserved around each packed rectangle in texels.
|
|
4127
|
+
*/
|
|
4128
|
+
get rectBorderWidth(): number;
|
|
4081
4129
|
/**
|
|
4082
4130
|
* Gets the information about specified atlas
|
|
4083
4131
|
* @param key - Key of the atlas
|
|
@@ -4214,7 +4262,12 @@ declare class DrawText {
|
|
|
4214
4262
|
* @param device - The render device
|
|
4215
4263
|
* @param name - The font name
|
|
4216
4264
|
*/
|
|
4217
|
-
static setFont(device: AbstractDevice, name: string): void;
|
|
4265
|
+
static setFont(device: AbstractDevice, name: Nullable<string>): void;
|
|
4266
|
+
/**
|
|
4267
|
+
* Set render states to be used when drawing text. If not set, default states will be used.
|
|
4268
|
+
* @param renderStates - The render states to use when drawing text. If null, default states will be used.
|
|
4269
|
+
*/
|
|
4270
|
+
static setRenderStates(renderStates: Nullable<RenderStateSet>): void;
|
|
4218
4271
|
/**
|
|
4219
4272
|
* Draw text onto the screen
|
|
4220
4273
|
* @param device - The render device
|
|
@@ -4223,7 +4276,16 @@ declare class DrawText {
|
|
|
4223
4276
|
* @param x - X coordinate of the text
|
|
4224
4277
|
* @param y - Y coordinate of the text
|
|
4225
4278
|
*/
|
|
4226
|
-
static drawText(device: AbstractDevice, text: string, color: string, x: number, y: number
|
|
4279
|
+
static drawText(device: AbstractDevice, text: string, color: string | Vector3 | Vector4, x: number, y: number): void;
|
|
4280
|
+
/**
|
|
4281
|
+
* Draw text inside a rectangle with layout and clipping
|
|
4282
|
+
* @param device - The render device
|
|
4283
|
+
* @param text - The text to be drawn
|
|
4284
|
+
* @param color - The text color
|
|
4285
|
+
* @param rect - The layout rectangle
|
|
4286
|
+
* @param options - Layout options
|
|
4287
|
+
*/
|
|
4288
|
+
static drawText(device: AbstractDevice, text: string, color: string | Vector3 | Vector4, rect: Immutable<Rect>, options?: DrawTextLayoutOptions): void;
|
|
4227
4289
|
}
|
|
4228
4290
|
|
|
4229
4291
|
/**
|
|
@@ -4251,4 +4313,4 @@ declare class StructuredBufferData {
|
|
|
4251
4313
|
set(name: string, value: StructuredValue): void;
|
|
4252
4314
|
}
|
|
4253
4315
|
|
|
4254
|
-
export { type AbstractDevice, type ArrayTypeDetail, type AtlasInfo, type AtomicTypeInfoDetail, type BaseCreationOptions, BaseDevice, type BaseTexture, type BindGroup, type BindGroupLayout, type BindGroupLayoutEntry, type BindPointInfo, type BlendEquation, type BlendFunc, type BlendingState, type BufferBindingLayout, type BufferCreationOptions, type BufferUsage, CPUTimer, type ColorState, type CompareFunc, type ComputeProgramConstructParams, type DataType, type DepthState, type DeviceBackend, type DeviceCaps, type DeviceEventMap, type DeviceOptions, type DeviceViewport, DrawText, type ExpValueNonArrayType, type ExpValueType, type ExternalTextureBindingLayout, type FaceMode, type FaceWinding, Font, type FrameBuffer, type FrameBufferOptions, type FrameBufferTextureAttachment, type FrameInfo, type FramebufferCaps, type FunctionTypeDetail, type GPUDataBuffer, type GPUObject, type GPUObjectList, type GPUProgram, type GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, type ITimer, type IndexBuffer, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, type MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, type PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, type PBReflectionTagGetter, type PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, type PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, type PointerTypeDetail, Pool, type PrimitiveType, type PrimitiveTypeDetail, ProgramBuilder, Proxiable, type RasterizerState, type RenderBundle, type RenderProgramConstructParams, type RenderStateSet, type SamplerBindingLayout, type SamplerOptions, type SamplerTypeDetail, type ShaderCaps, type ShaderExpTagRecord, type ShaderExpTagValue, type ShaderKind, ShaderType, type ShaderTypeFunc, type StencilOp, type StencilState, type StorageTextureBindingLayout, type StructTypeDetail, type StructuredBuffer, StructuredBufferData, type StructuredValue, type Texture2D, type Texture2DArray, type Texture3D, type TextureAddressMode, TextureAtlasManager, type TextureBindingLayout, type TextureCaps, type TextureColorSpace, type TextureCreationOptions, type TextureCube, type TextureFilterMode, type TextureFormat, type TextureFormatInfo, type TextureImageElement, type TextureMipmapData, type TextureMipmapLevelData, type TextureSampler, type TextureType, type TextureTypeDetail, type TextureVideo, type TypeDetailInfo, type UniformBufferLayout, type UniformLayout, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, type VertexAttribFormat, type VertexBufferInfo, VertexData, type VertexLayout, type VertexLayoutOptions, type VertexSemantic, type VertexStepMode, type WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexAttributeFormat, getVertexAttributeIndex, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, matchVertexBuffer, semanticList };
|
|
4316
|
+
export { type AbstractDevice, type ArrayTypeDetail, type AtlasInfo, type AtomicTypeInfoDetail, type BaseCreationOptions, BaseDevice, type BaseTexture, type BindGroup, type BindGroupLayout, type BindGroupLayoutEntry, type BindPointInfo, type BlendEquation, type BlendFunc, type BlendingState, type BufferBindingLayout, type BufferCreationOptions, type BufferUsage, CPUTimer, type ColorState, type CompareFunc, type ComputeProgramConstructParams, type DataType, type DepthState, type DeviceBackend, type DeviceCaps, type DeviceEventMap, type DeviceOptions, type DeviceViewport, DrawText, type DrawTextLayoutOptions, type ExpValueNonArrayType, type ExpValueType, type ExternalTextureBindingLayout, type FaceMode, type FaceWinding, Font, type FrameBuffer, type FrameBufferOptions, type FrameBufferTextureAttachment, type FrameInfo, type FramebufferCaps, type FunctionTypeDetail, type GPUDataBuffer, type GPUObject, type GPUObjectList, type GPUProgram, type GPUProgramConstructParams, GPUResourceUsageFlags, GlyphManager, type ITimer, type IndexBuffer, MAX_BINDING_GROUPS, MAX_TEXCOORD_INDEX_COUNT, MAX_VERTEX_ATTRIBUTES, type MiscCaps, PBAddressSpace, PBAnyTypeInfo, PBArrayTypeInfo, PBAtomicI32TypeInfo, PBAtomicU32TypeInfo, PBBuiltinScope, type PBComputeOptions, PBDoWhileScope, PBForScope, PBFunctionScope, PBFunctionTypeInfo, PBGlobalScope, PBIfScope, PBInputScope, PBInsideFunctionScope, PBLocalScope, PBNakedScope, PBOutputScope, PBPointerTypeInfo, PBPrimitiveType, PBPrimitiveTypeInfo, PBReflection, type PBReflectionTagGetter, type PBRenderOptions, PBSamplerAccessMode, PBSamplerTypeInfo, PBScope, PBShaderExp, type PBStructLayout, PBStructTypeInfo, PBTextureType, PBTextureTypeInfo, PBTypeInfo, PBVoidTypeInfo, PBWhileScope, type PointerTypeDetail, Pool, type PrimitiveType, type PrimitiveTypeDetail, ProgramBuilder, Proxiable, type RasterizerState, type RenderBundle, type RenderProgramConstructParams, type RenderStateSet, type SamplerBindingLayout, type SamplerOptions, type SamplerTypeDetail, type ShaderCaps, type ShaderExpTagRecord, type ShaderExpTagValue, type ShaderKind, ShaderType, type ShaderTypeFunc, type StencilOp, type StencilState, type StorageTextureBindingLayout, type StructTypeDetail, type StructuredBuffer, StructuredBufferData, type StructuredValue, type TextHorizontalAlignment, type TextVerticalAlignment, type Texture2D, type Texture2DArray, type Texture3D, type TextureAddressMode, TextureAtlasManager, type TextureBindingLayout, type TextureCaps, type TextureColorSpace, type TextureCreationOptions, type TextureCube, type TextureFilterMode, type TextureFormat, type TextureFormatInfo, type TextureImageElement, type TextureMipmapData, type TextureMipmapLevelData, type TextureSampler, type TextureType, type TextureTypeDetail, type TextureVideo, type TypeDetailInfo, type UniformBufferLayout, type UniformLayout, VERTEX_ATTRIB_BLEND_INDICES, VERTEX_ATTRIB_BLEND_WEIGHT, VERTEX_ATTRIB_DIFFUSE, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TANGENT, VERTEX_ATTRIB_TEXCOORD0, VERTEX_ATTRIB_TEXCOORD1, VERTEX_ATTRIB_TEXCOORD2, VERTEX_ATTRIB_TEXCOORD3, VERTEX_ATTRIB_TEXCOORD4, VERTEX_ATTRIB_TEXCOORD5, VERTEX_ATTRIB_TEXCOORD6, VERTEX_ATTRIB_TEXCOORD7, type VertexAttribFormat, type VertexBufferInfo, VertexData, type VertexLayout, type VertexLayoutOptions, type VertexSemantic, type VertexStepMode, type WebGLContext, genDefaultName, getTextureFormatBlockHeight, getTextureFormatBlockSize, getTextureFormatBlockWidth, getVertexAttribByName, getVertexAttribFormat, getVertexAttribName, getVertexAttributeFormat, getVertexAttributeIndex, getVertexBufferAttribType, getVertexBufferAttribTypeBySemantic, getVertexBufferLength, getVertexBufferStride, getVertexFormatComponentCount, getVertexFormatSize, hasAlphaChannel, hasBlueChannel, hasDepthChannel, hasGreenChannel, hasRedChannel, hasStencilChannel, isCompressedTextureFormat, isFloatTextureFormat, isIntegerTextureFormat, isSRGBTextureFormat, isSignedTextureFormat, linearTextureFormatToSRGB, makeVertexBufferType, matchVertexBuffer, semanticList };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zephyr3d/device",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Device API for zephyr3d",
|
|
5
5
|
"homepage": "https://github.com/gavinyork/zephyr3d#readme",
|
|
6
6
|
"type": "module",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@rollup/plugin-commonjs": "~28.0.2",
|
|
69
69
|
"@types/node": "^22.12.0",
|
|
70
70
|
"@webgpu/types": "^0.1.65",
|
|
71
|
-
"@zephyr3d/base": "^0.2.
|
|
71
|
+
"@zephyr3d/base": "^0.2.7",
|
|
72
72
|
"rollup-plugin-import-css": "~3.5.8"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|