1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/// The canvas 2D rendering context type identifier.
pub const RENDERER_CONTEXT_TYPE_2D: &str = "2d";
/// The default font family used for text rendering.
pub const RENDERER_DEFAULT_FONT_FAMILY: &str = "sans-serif";
/// The default font size in pixels.
pub const RENDERER_DEFAULT_FONT_SIZE: f64 = 16.0;
/// The canvas context property name for fill style.
pub const RENDERER_PROPERTY_FILL_STYLE: &str = "fillStyle";
/// The canvas context property name for stroke style.
pub const RENDERER_PROPERTY_STROKE_STYLE: &str = "strokeStyle";
/// The canvas context property name for line width.
pub const RENDERER_PROPERTY_LINE_WIDTH: &str = "lineWidth";
/// The canvas context property name for font.
pub const RENDERER_PROPERTY_FONT: &str = "font";
/// The canvas context property name for global alpha.
pub const RENDERER_PROPERTY_GLOBAL_ALPHA: &str = "globalAlpha";
/// The canvas context property name for global composite operation (blend mode).
pub const RENDERER_PROPERTY_GLOBAL_COMPOSITE_OPERATION: &str = "globalCompositeOperation";
/// The canvas context property name for shadow color.
pub const RENDERER_PROPERTY_SHADOW_COLOR: &str = "shadowColor";
/// The canvas context property name for shadow blur.
pub const RENDERER_PROPERTY_SHADOW_BLUR: &str = "shadowBlur";
/// The canvas context property name for shadow offset x.
pub const RENDERER_PROPERTY_SHADOW_OFFSET_X: &str = "shadowOffsetX";
/// The canvas context property name for shadow offset y.
pub const RENDERER_PROPERTY_SHADOW_OFFSET_Y: &str = "shadowOffsetY";
/// The default camera zoom level.
pub const RENDERER_DEFAULT_CAMERA_ZOOM: f64 = 1.0;
/// The default camera rotation in radians.
pub const RENDERER_DEFAULT_CAMERA_ROTATION: f64 = 0.0;
/// The canvas context property name for text rendering.
pub const RENDERER_PROPERTY_TEXT_RENDERING: &str = "textRendering";
/// The high-quality text rendering value for geometric precision.
pub const RENDERER_TEXT_RENDERING_GEOMETRIC_PRECISION: &str = "geometricPrecision";
/// The window property name for device pixel ratio (HiDPI scale factor).
pub const RENDERER_PROPERTY_DEVICE_PIXEL_RATIO: &str = "devicePixelRatio";
/// The fallback device pixel ratio when window detection fails.
pub const RENDERER_DEFAULT_DEVICE_PIXEL_RATIO: f64 = 1.0;
/// The canvas context property name for image smoothing enabled.
pub const RENDERER_PROPERTY_IMAGE_SMOOTHING_ENABLED: &str = "imageSmoothingEnabled";
/// The canvas context property name for image smoothing quality.
pub const RENDERER_PROPERTY_IMAGE_SMOOTHING_QUALITY: &str = "imageSmoothingQuality";
/// The low-quality image smoothing value (fastest, pixelated-friendly).
pub const RENDERER_IMAGE_SMOOTHING_QUALITY_LOW: &str = "low";
/// The medium-quality image smoothing value.
pub const RENDERER_IMAGE_SMOOTHING_QUALITY_MEDIUM: &str = "medium";
/// The high-quality image smoothing value.
pub const RENDERER_IMAGE_SMOOTHING_QUALITY_HIGH: &str = "high";
/// The HTML element tag name for creating a canvas element.
pub const RENDERER_ELEMENT_CANVAS: &str = "canvas";
/// The default SSAA scale factor (2.0 means 4x supersampling).
pub const RENDERER_DEFAULT_SSAA_SCALE_FACTOR: f64 = 2.0;
/// The CSS composite operation string for the `Normal` blend mode.
pub const BLEND_MODE_NORMAL: &str = "source-over";
/// The CSS composite operation string for the `Multiply` blend mode.
pub const BLEND_MODE_MULTIPLY: &str = "multiply";
/// The CSS composite operation string for the `Screen` blend mode.
pub const BLEND_MODE_SCREEN: &str = "screen";
/// The CSS composite operation string for the `Lighter` blend mode.
pub const BLEND_MODE_LIGHTER: &str = "lighter";
/// The CSS composite operation string for the `Overlay` blend mode.
pub const BLEND_MODE_OVERLAY: &str = "overlay";
/// The CSS composite operation string for the `Darken` blend mode.
pub const BLEND_MODE_DARKEN: &str = "darken";
/// The CSS composite operation string for the `Lighten` blend mode.
pub const BLEND_MODE_LIGHTEN: &str = "lighten";
/// The CSS composite operation string for the `ColorDodge` blend mode.
pub const BLEND_MODE_COLOR_DODGE: &str = "color-dodge";
/// The CSS composite operation string for the `ColorBurn` blend mode.
pub const BLEND_MODE_COLOR_BURN: &str = "color-burn";
/// The CSS composite operation string for the `HardLight` blend mode.
pub const BLEND_MODE_HARD_LIGHT: &str = "hard-light";
/// The CSS composite operation string for the `SoftLight` blend mode.
pub const BLEND_MODE_SOFT_LIGHT: &str = "soft-light";
/// The CSS composite operation string for the `Difference` blend mode.
pub const BLEND_MODE_DIFFERENCE: &str = "difference";
/// The CSS composite operation string for the `Exclusion` blend mode.
pub const BLEND_MODE_EXCLUSION: &str = "exclusion";
/// The CSS composite operation string for the `Hue` blend mode.
pub const BLEND_MODE_HUE: &str = "hue";
/// The CSS composite operation string for the `Saturation` blend mode.
pub const BLEND_MODE_SATURATION: &str = "saturation";
/// The CSS composite operation string for the `Color` blend mode.
pub const BLEND_MODE_COLOR: &str = "color";
/// The CSS composite operation string for the `Luminosity` blend mode.
pub const BLEND_MODE_LUMINOSITY: &str = "luminosity";
/// The default shadow color used when no explicit color is provided.
pub const RENDERER_DEFAULT_SHADOW_COLOR: &str = "rgba(0, 0, 0, 0.5)";
/// The default shadow blur radius in pixels.
pub const RENDERER_DEFAULT_SHADOW_BLUR: f64 = 4.0;
/// The default render layer z-index for background elements.
pub const RENDERER_LAYER_BACKGROUND: i32 = 0;
/// The default render layer z-index for foreground game objects.
pub const RENDERER_LAYER_FOREGROUND: i32 = 100;
/// The default render layer z-index for UI overlay elements.
pub const RENDERER_LAYER_UI: i32 = 1000;
/// The JavaScript property name for `powerPreference` on `GpuRequestAdapterOptions`.
pub const WEBGPU_PROPERTY_POWER_PREFERENCE: &str = "powerPreference";
/// The WebGPU context type string used to obtain a `GpuCanvasContext` from a canvas element.
pub const WEBGPU_CONTEXT_TYPE: &str = "webgpu";
/// The JavaScript method name `requestAdapter` on `Gpu`.
pub const WEBGPU_METHOD_REQUEST_ADAPTER: &str = "requestAdapter";
/// The JavaScript method name `requestDevice` on `GpuAdapter`.
pub const WEBGPU_METHOD_REQUEST_DEVICE: &str = "requestDevice";
/// The JavaScript method name `getPreferredCanvasFormat` on `Gpu`.
pub const WEBGPU_METHOD_GET_PREFERRED_FORMAT: &str = "getPreferredCanvasFormat";
/// Error message used when the WebGPU init promise race loses to the
/// `INIT_PROMISE_TIMEOUT_MILLIS` timer. Surfaced to `JsFuture::await` as
/// `Err`, which causes the caller to fall into its `WebGPU Not Supported`
/// branch instead of leaving the UI stuck on `Initializing...`.
pub const RENDERER_TIMEOUT_ERROR_MESSAGE: &str = "WebGPU initialization timed out";
/// The JavaScript method name `configure` on `GpuCanvasContext`.
pub const WEBGPU_METHOD_CONFIGURE: &str = "configure";
/// The JavaScript property name `queue` on `GpuDevice`.
pub const WEBGPU_PROPERTY_QUEUE: &str = "queue";
/// The JavaScript property name `device` on `GpuCanvasConfiguration`.
pub const WEBGPU_PROPERTY_DEVICE: &str = "device";
/// The JavaScript property name `format` on `GpuCanvasConfiguration`.
pub const WEBGPU_PROPERTY_FORMAT: &str = "format";
/// The JavaScript method name `createShaderModule` on `GpuDevice`.
pub const WEBGPU_METHOD_CREATE_SHADER_MODULE: &str = "createShaderModule";
/// The JavaScript property name `code` on `GpuShaderModuleDescriptor`.
pub const WEBGPU_PROPERTY_CODE: &str = "code";
/// The JavaScript method name `createCommandEncoder` on `GpuDevice`.
pub const WEBGPU_METHOD_CREATE_COMMAND_ENCODER: &str = "createCommandEncoder";
/// The JavaScript method name `getCurrentTexture` on `GpuCanvasContext`.
pub const WEBGPU_METHOD_GET_CURRENT_TEXTURE: &str = "getCurrentTexture";
/// The JavaScript method name `createView` on `GpuTexture`.
pub const WEBGPU_METHOD_CREATE_VIEW: &str = "createView";
/// The JavaScript method name `beginRenderPass` on `GpuCommandEncoder`.
pub const WEBGPU_METHOD_BEGIN_RENDER_PASS: &str = "beginRenderPass";
/// The JavaScript method name `end` on `GpuRenderPassEncoder`.
pub const WEBGPU_METHOD_END: &str = "end";
/// The JavaScript method name `finish` on `GpuCommandEncoder`.
pub const WEBGPU_METHOD_FINISH: &str = "finish";
/// The JavaScript method name `submit` on `GpuQueue`.
pub const WEBGPU_METHOD_SUBMIT: &str = "submit";
/// The JavaScript property name `view` on `GpuRenderPassColorAttachment`.
pub const WEBGPU_PROPERTY_VIEW: &str = "view";
/// The JavaScript property name `loadOp` on `GpuRenderPassColorAttachment`.
pub const WEBGPU_PROPERTY_LOAD_OP: &str = "loadOp";
/// The JavaScript property name `storeOp` on `GpuRenderPassColorAttachment`.
pub const WEBGPU_PROPERTY_STORE_OP: &str = "storeOp";
/// The JavaScript property name `clearValue` on `GpuRenderPassColorAttachment`.
pub const WEBGPU_PROPERTY_CLEAR_VALUE: &str = "clearValue";
/// The JavaScript property name `colorAttachments` on `GpuRenderPassDescriptor`.
pub const WEBGPU_PROPERTY_COLOR_ATTACHMENTS: &str = "colorAttachments";
/// The JavaScript property name `r` on `GpuColorDict`.
pub const WEBGPU_PROPERTY_R: &str = "r";
/// The JavaScript property name `g` on `GpuColorDict`.
pub const WEBGPU_PROPERTY_G: &str = "g";
/// The JavaScript property name `b` on `GpuColorDict`.
pub const WEBGPU_PROPERTY_B: &str = "b";
/// The JavaScript property name `a` on `GpuColorDict`.
pub const WEBGPU_PROPERTY_A: &str = "a";
/// The WebGPU `clear` load operation string.
pub const WEBGPU_LOAD_OP_CLEAR: &str = "clear";
/// The WebGPU `store` store operation string.
pub const WEBGPU_STORE_OP_STORE: &str = "store";
/// The JavaScript method name `createRenderPipeline` on `GpuDevice`.
pub const WEBGPU_METHOD_CREATE_RENDER_PIPELINE: &str = "createRenderPipeline";
/// The JavaScript method name `setPipeline` on `GpuRenderPassEncoder`.
pub const WEBGPU_METHOD_SET_PIPELINE: &str = "setPipeline";
/// The JavaScript method name `draw` on `GpuRenderPassEncoder`.
pub const WEBGPU_METHOD_DRAW: &str = "draw";
/// The JavaScript property name `vertex` on `GpuRenderPipelineDescriptor`.
pub const WEBGPU_PROPERTY_VERTEX: &str = "vertex";
/// The JavaScript property name `fragment` on `GpuRenderPipelineDescriptor`.
pub const WEBGPU_PROPERTY_FRAGMENT: &str = "fragment";
/// The JavaScript property name `module` on `GpuVertexState` / `GpuFragmentState`.
pub const WEBGPU_PROPERTY_MODULE: &str = "module";
/// The JavaScript property name `entryPoint` on `GpuVertexState` / `GpuFragmentState`.
pub const WEBGPU_PROPERTY_ENTRY_POINT: &str = "entryPoint";
/// The JavaScript property name `buffers` on `GpuVertexState`.
pub const WEBGPU_PROPERTY_BUFFERS: &str = "buffers";
/// The JavaScript property name `targets` on `GpuFragmentState`.
pub const WEBGPU_PROPERTY_TARGETS: &str = "targets";
/// The JavaScript property name `primitive` on `GpuRenderPipelineDescriptor`.
pub const WEBGPU_PROPERTY_PRIMITIVE: &str = "primitive";
/// The JavaScript property name `topology` on `GpuPrimitiveState`.
pub const WEBGPU_PROPERTY_TOPOLOGY: &str = "topology";
/// The JavaScript property name `layout` on `GpuRenderPipelineDescriptor`.
pub const WEBGPU_PROPERTY_LAYOUT: &str = "layout";
/// The vertex shader entry point name used in WGSL shaders.
pub const WEBGPU_VERTEX_ENTRY_POINT: &str = "vs_main";
/// The fragment shader entry point name used in WGSL shaders.
pub const WEBGPU_FRAGMENT_ENTRY_POINT: &str = "fs_main";
/// The WebGPU primitive topology string for triangle lists.
pub const WEBGPU_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: &str = "triangle-list";
pub const INIT_PROMISE_TIMEOUT_MILLIS: i32 = 3000;