melonjs 20.4.0 → 20.6.0
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/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +37 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/backend/sound.d.ts.map +1 -1
- package/build/audio/procedural.d.ts +7 -2
- package/build/audio/procedural.d.ts.map +1 -1
- package/build/audio/types.d.ts +22 -0
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +28 -0
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +24 -3
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +7 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1379 -226
- package/build/index.js.map +4 -4
- package/build/level/gltf/GLTFModel.d.ts +50 -7
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +20 -47
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +106 -6
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/renderable/animation.d.ts +21 -6
- package/build/renderable/animation.d.ts.map +1 -1
- package/build/renderable/container.d.ts +27 -5
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +34 -9
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +131 -94
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +17 -0
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +12 -2
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +32 -7
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +78 -3
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +2 -0
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/text/textstyle.d.ts.map +1 -1
- package/build/state/stage.d.ts +21 -0
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/device.d.ts +1 -1
- package/build/system/device.d.ts.map +1 -1
- package/build/system/save.d.ts +44 -1
- package/build/system/save.d.ts.map +1 -1
- package/build/video/effects/glsl_realization.d.ts.map +1 -1
- package/build/video/effects/mesh_splice.d.ts +2 -0
- package/build/video/effects/mesh_splice.d.ts.map +1 -0
- package/build/video/effects/shadereffect.d.ts +12 -128
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/wgsl_realization.d.ts.map +1 -1
- package/build/video/gradient.d.ts +19 -0
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +44 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +101 -34
- package/build/video/texture/noise_texture2d.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/glshader.d.ts +7 -2
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +6 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/effect_binding.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-3d/SKILL.md +152 -3
- package/skills/melonjs-3d-assets/SKILL.md +139 -0
- package/skills/melonjs-audio/SKILL.md +17 -0
- package/skills/melonjs-camera-and-drawing/SKILL.md +45 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +130 -1
- package/skills/melonjs-loading-assets/SKILL.md +131 -1
- package/skills/melonjs-performance/SKILL.md +83 -1
- package/skills/melonjs-physics/SKILL.md +78 -0
- package/skills/melonjs-renderables/SKILL.md +63 -1
- package/skills/melonjs-renderer-backends/SKILL.md +19 -0
- package/skills/melonjs-scenes-and-state/SKILL.md +93 -0
- package/skills/melonjs-ui-and-text/SKILL.md +124 -0
|
@@ -1,72 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A renderable object for displaying textured triangle meshes.
|
|
3
|
-
* Supports loading from Wavefront OBJ models (via `loader.preload` with type "obj")
|
|
4
|
-
* or from raw geometry data (vertices, uvs, indices).
|
|
5
|
-
* Includes a built-in perspective projection and supports 3D transforms
|
|
6
|
-
* through the standard Renderable API (`rotate`, `scale`, `translate`).
|
|
7
|
-
* Works on both GPU backends — WebGL 2 and WebGPU, with hardware depth
|
|
8
|
-
* testing — and on the Canvas renderer via the CPU-projected 2D-camera
|
|
9
|
-
* path (painter's algorithm, no depth buffer).
|
|
10
|
-
*
|
|
11
|
-
* **Retained rendering** — under a {@link Camera3d} on a GPU backend
|
|
12
|
-
* (`renderer.supportsRetainedMesh`), the mesh's model-space geometry is
|
|
13
|
-
* uploaded to GPU buffers **once** and every frame just draws it by
|
|
14
|
-
* reference: placement, camera, tint, alpha and emissive all ride
|
|
15
|
-
* per-draw uniforms, so moving, rotating, scaling or re-tinting a mesh
|
|
16
|
-
* never re-uploads geometry (near-zero per-frame allocation). Editing
|
|
17
|
-
* the geometry itself in place is still possible — signal it with
|
|
18
|
-
* {@link Mesh#needsUpdate} and the GPU copy refreshes on the next draw.
|
|
19
|
-
* Under a 2D camera (or on Canvas) the mesh instead re-projects its
|
|
20
|
-
* vertices on the CPU each frame — same API, the camera and backend
|
|
21
|
-
* decide the path.
|
|
22
|
-
*
|
|
23
|
-
* **Pivot — transforms are applied about the mesh's local origin `(0, 0, 0)`,
|
|
24
|
-
* NOT a normalized anchor point.** Unlike a {@link Sprite} (whose
|
|
25
|
-
* {@link Renderable#anchorPoint} recenters a `width`×`height` box), a mesh has
|
|
26
|
-
* real vertex coordinates, so rotation and scale pivot around the model origin
|
|
27
|
-
* the geometry is authored against — the standard convention for 3D meshes.
|
|
28
|
-
* Place the origin where you want the pivot at authoring time (or nest the
|
|
29
|
-
* mesh under a transformed parent to pivot elsewhere). Consequently, on the
|
|
30
|
-
* `Camera3d` world-space path the mesh opts out of the anchor offset entirely
|
|
31
|
-
* (see {@link Renderable#applyAnchorTransform}); the legacy 2D path still
|
|
32
|
-
* honors `anchorPoint` for backward compatibility. Subclasses that bake the
|
|
33
|
-
* anchor into their vertex data instead (e.g. {@link Sprite3d}, via the
|
|
34
|
-
* internal `_anchorBaked` flag) opt out on **both** paths — for those, the
|
|
35
|
-
* vertex bake is the single anchoring mechanism.
|
|
36
|
-
* @category Game Objects
|
|
37
|
-
*/
|
|
38
1
|
export default class Mesh extends Renderable {
|
|
39
2
|
/**
|
|
40
3
|
* @param {number} x - the x screen position of the mesh object
|
|
41
4
|
* @param {number} y - the y screen position of the mesh object
|
|
42
|
-
* @param {
|
|
43
|
-
* @param {string} [settings.model] - name of a preloaded OBJ model (via loader.preload with type "obj"). Vertex normals come with it — authored `vn` when the file has them, generated from face geometry when it does not — so an OBJ model can be `lit`.
|
|
44
|
-
* @param {Float32Array|number[]} [settings.vertices] - vertex positions as x,y,z triplets (alternative to settings.model)
|
|
45
|
-
* @param {Float32Array|number[]} [settings.uvs] - texture coordinates as u,v pairs (alternative to settings.model)
|
|
46
|
-
* @param {Uint16Array|number[]} [settings.indices] - triangle vertex indices (alternative to settings.model)
|
|
47
|
-
* @param {HTMLImageElement|TextureAtlas|string} [settings.texture] - the texture to apply (image name, HTMLImageElement, or TextureAtlas). If omitted and settings.material is provided, the texture is resolved from the MTL material's map_Kd. Passing this pins ONE binding over the whole model, which on a multi-material model suppresses the per-material texture split — see {@link Mesh#textureGroups}.
|
|
48
|
-
* @param {string} [settings.material] - name of a preloaded MTL material (via loader.preload with type "mtl"). When provided, the diffuse texture (map_Kd), tint color (Kd), and opacity (d) are automatically applied. On a multi-material model each material's own `map_Kd` is bound for its own slice of the geometry (#1573) and each `Kd` is baked per-vertex, so one `Mesh` renders the whole model.
|
|
49
|
-
* @param {number} settings.width - display width in pixels. With normalization on (the default) the model is scaled to fit this size; with `normalize: false` this is the uniform pixels-per-unit scale applied to the raw geometry.
|
|
50
|
-
* @param {number} [settings.height] - display height in pixels (normalized models only; ignored when `normalize: false`)
|
|
51
|
-
* @param {boolean} [settings.cullBackFaces=true] - enable backface culling
|
|
52
|
-
* @param {boolean} [settings.normalize=true] - fit the source geometry into a `[-0.5, 0.5]` unit cube before scaling, so `width`/`height` behave like a Sprite. Set `false` to keep the geometry's real-world coordinates — required when several meshes share one coordinate space (e.g. nodes of an imported glTF scene) so their relative scale and layout are preserved.
|
|
53
|
-
* @param {number} [settings.scale] - world-space scale (pixels per source unit) for the Camera3d path; defaults to `width`. Set this when `width`/`height` describe the renderable's world bounds (frustum culling) rather than the geometry scale — see {@link Mesh#meshScale}.
|
|
54
|
-
* @param {boolean} [settings.rightHanded=false] - treat the source as right-handed (Y-up, e.g. glTF) under the `Camera3d` world path. The default Y-up→Y-down bridge negates Y only (a reflection, which mirrors the scene left/right); `true` negates Y **and** Z (a rotation) so chirality is preserved and the result matches the authoring tool. See {@link Mesh#rightHanded}.
|
|
55
|
-
* @param {string} [settings.textureRepeat] - texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"` / `"no-repeat"`) this mesh samples its texture with (per-mesh — it does not modify the shared texture, so other meshes/sprites using the same image are unaffected). Use `"repeat"` when the geometry's UVs fall outside the `[0, 1]` range and rely on the texture tiling (e.g. glTF assets, whose default sampler wrap is REPEAT) — otherwise the texture clamps to its edge texels and looks flat. Ignored for the white-pixel fallback. Note: REPEAT on a non-power-of-two texture requires WebGL 2.
|
|
56
|
-
* @param {string} [settings.textureFilter] - texture magnification filter (`"nearest"` for crisp pixel-art upscaling, `"linear"` for smooth) applied to the resolved texture. Omit to keep the renderer's global `antiAlias` default. On the mesh path, linear filtering also samples a generated mip chain with trilinear minification and 4× anisotropy (distant geometry stops shimmering) — `"nearest"` opts out, keeping crisp pixel-art models on hard level-0 sampling. GPU backends only (ignored by the Canvas renderer).
|
|
57
|
-
* @param {number} [settings.alphaCutoff=0] - alpha cutout threshold. Fragments whose final alpha is below this value are discarded (hard-edged cutout — foliage, fences, decals — with no blending or sorting). `0` disables the cutout. Set automatically by the glTF loader from a material's `alphaMode: "MASK"`. GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).
|
|
58
|
-
* @param {number[]|Float32Array} [settings.emissive] - emissive (self-illumination) color `[r, g, b]` (0..1, may exceed 1 for HDR glow) added on top of the lit/unlit color so the surface glows regardless of scene lights (neon, lava, screens). Omit / all-zero for no emission. Set automatically by the glTF loader (`emissiveFactor`) and OBJ loader (MTL `Ke`). GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).
|
|
59
|
-
* @param {boolean} [settings.lit=false] - shade this mesh with the scene's {@link Light3d} lights (the lit mesh pipeline) instead of rendering fullbright. Set automatically by the glTF importer when the scene carries a directional, point or spot light. With `lit` on and no lights present the batcher uploads a white ambient, so the result is indistinguishable from unlit.
|
|
60
|
-
* @param {Uint32Array|Color[]|number[]} [settings.vertexColors] - per-vertex colour, one entry per vertex, multiplied into {@link Mesh#tint}. Either packed RGBA8 (`Uint32Array`, the form the batchers read — no conversion) or one {@link Color} per vertex. Omit for plain white. Lets a single mesh carry a gradient — fading a terrain toward the sky with distance, darkening a crease — which a per-object `tint` cannot express. An explicit value wins over the colours a multi-material OBJ bakes from its MTL.
|
|
61
|
-
* @param {number[]|Float32Array} [settings.normals] - per-vertex normals for the lit path. An explicit value wins over the ones an OBJ or glTF source supplies; omit it and they are taken from the model, or generated from the geometry when the mesh is `lit`. Generated normals average per vertex where faces share vertices (smooth shading) and equal the face normal where they do not (flat shading) — the geometry decides, not a flag.
|
|
62
|
-
* @param {number[]|Float32Array} [settings.specular] - specular color `[r, g, b]` (0..1) for the lit path. Set by the OBJ loader from MTL `Ks`, and derived from glTF metallic/roughness.
|
|
63
|
-
* @param {number} [settings.shininess=0] - specular exponent for the lit path (MTL `Ns`). `0` for a fully diffuse surface.
|
|
64
|
-
* @param {string|TextureAtlas|HTMLImageElement} [settings.alphaMap] - per-texel opacity map, sampled in addition to the diffuse texture (MTL `map_d`).
|
|
65
|
-
* @param {boolean} [settings.castGroundShadow] - give this mesh a blob ground shadow, overriding the application's `castGroundShadow` setting in both directions. Omit to inherit. Needs a GPU backend and a `Camera3d`.
|
|
66
|
-
* @param {boolean} [settings.transparent] - draw in the transparent pass (blended, back-to-front, no depth write). Omit and a mesh goes transparent whenever its draw alpha is fractional; `true` for soft-alpha textures; `false` to stay opaque however faded
|
|
67
|
-
* @param {boolean} [settings.fog] - set `false` to exempt this mesh from the camera's distance fog ({@link Camera3d#setFog}); omit to fog whenever the camera does
|
|
68
|
-
* @param {number} [settings.shadowGroundY] - world Y of the floor the shadow lands on. Omit and the blob sits at the object's own base at full strength; set it and the blob shrinks and fades as the object rises. Render space is Y-down, so the floor is a **greater** Y than the object above it.
|
|
69
|
-
* @param {number} [settings.shadowOpacity=0.45] - opacity of the shadow directly beneath the object, before any height fade.
|
|
5
|
+
* @param {MeshSettings} settings - Configuration parameters for the Mesh object
|
|
70
6
|
* @example
|
|
71
7
|
* // create from OBJ + MTL (texture auto-resolved from material)
|
|
72
8
|
* let mesh = new me.Mesh(0, 0, {
|
|
@@ -112,35 +48,7 @@ export default class Mesh extends Renderable {
|
|
|
112
48
|
* // 2D rotation (Z axis, same as Sprite)
|
|
113
49
|
* mesh.rotate(Math.PI / 4);
|
|
114
50
|
*/
|
|
115
|
-
constructor(x: number, y: number, settings:
|
|
116
|
-
model?: string | undefined;
|
|
117
|
-
vertices?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
118
|
-
uvs?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
119
|
-
indices?: number[] | Uint16Array<ArrayBufferLike> | undefined;
|
|
120
|
-
texture?: string | HTMLImageElement | TextureAtlas | undefined;
|
|
121
|
-
material?: string | undefined;
|
|
122
|
-
width: number;
|
|
123
|
-
height?: number | undefined;
|
|
124
|
-
cullBackFaces?: boolean | undefined;
|
|
125
|
-
normalize?: boolean | undefined;
|
|
126
|
-
scale?: number | undefined;
|
|
127
|
-
rightHanded?: boolean | undefined;
|
|
128
|
-
textureRepeat?: string | undefined;
|
|
129
|
-
textureFilter?: string | undefined;
|
|
130
|
-
alphaCutoff?: number | undefined;
|
|
131
|
-
emissive?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
132
|
-
lit?: boolean | undefined;
|
|
133
|
-
vertexColors?: number[] | Uint32Array<ArrayBufferLike> | Color[] | undefined;
|
|
134
|
-
normals?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
135
|
-
specular?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
136
|
-
shininess?: number | undefined;
|
|
137
|
-
alphaMap?: string | HTMLImageElement | TextureAtlas | undefined;
|
|
138
|
-
castGroundShadow?: boolean | undefined;
|
|
139
|
-
transparent?: boolean | undefined;
|
|
140
|
-
fog?: boolean | undefined;
|
|
141
|
-
shadowGroundY?: number | undefined;
|
|
142
|
-
shadowOpacity?: number | undefined;
|
|
143
|
-
});
|
|
51
|
+
constructor(x: number, y: number, settings: MeshSettings);
|
|
144
52
|
/**
|
|
145
53
|
* the original (untransformed) vertex positions as x,y,z triplets
|
|
146
54
|
* @type {Float32Array}
|
|
@@ -179,6 +87,17 @@ export default class Mesh extends Renderable {
|
|
|
179
87
|
* @type {Float32Array|undefined}
|
|
180
88
|
*/
|
|
181
89
|
originalNormals: Float32Array | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* world-space normals for the current draw, recomputed from
|
|
92
|
+
* {@link Mesh#originalNormals} along the Camera3d path. Empty (zero) when
|
|
93
|
+
* the mesh has no source normals — the shader then ignores lighting.
|
|
94
|
+
*
|
|
95
|
+
* Carries the same caveat as {@link Mesh#vertices}: the WebGL
|
|
96
|
+
* `Camera3d` path rotates normals on the GPU and leaves this array
|
|
97
|
+
* untouched.
|
|
98
|
+
* @type {Float32Array}
|
|
99
|
+
*/
|
|
100
|
+
normals: Float32Array;
|
|
182
101
|
/**
|
|
183
102
|
* Whether this mesh is lit by the active stage's {@link Light3d} lights.
|
|
184
103
|
* When `true` it renders through the lit mesh batcher (diffuse shading
|
|
@@ -604,6 +523,123 @@ export default class Mesh extends Renderable {
|
|
|
604
523
|
*/
|
|
605
524
|
toImageBitmap(): Promise<ImageBitmap>;
|
|
606
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* Everything {@link Mesh} takes.
|
|
528
|
+
*
|
|
529
|
+
* Split out of the constructor's own `@param` list so a subclass that
|
|
530
|
+
* forwards these wholesale — {@link InstancedMesh} does — can say so in its
|
|
531
|
+
* type, instead of restating 27 entries that would then drift apart.
|
|
532
|
+
*/
|
|
533
|
+
export type MeshSettings = {
|
|
534
|
+
/**
|
|
535
|
+
* - name of a preloaded OBJ model (via loader.preload with type "obj"). Vertex normals come with it — authored `vn` when the file has them, generated from face geometry when it does not — so an OBJ model can be `lit`.
|
|
536
|
+
*/
|
|
537
|
+
model?: string;
|
|
538
|
+
/**
|
|
539
|
+
* - vertex positions as x,y,z triplets (alternative to `model`)
|
|
540
|
+
*/
|
|
541
|
+
vertices?: Float32Array | number[];
|
|
542
|
+
/**
|
|
543
|
+
* - texture coordinates as u,v pairs (alternative to `model`)
|
|
544
|
+
*/
|
|
545
|
+
uvs?: Float32Array | number[];
|
|
546
|
+
/**
|
|
547
|
+
* - triangle vertex indices (alternative to `model`). A `Uint32Array` is preserved as-is for meshes past 65535 vertices — which is what the glTF parser emits for them — while a plain array is materialized as `Uint16Array`
|
|
548
|
+
*/
|
|
549
|
+
indices?: Uint16Array | Uint32Array | number[];
|
|
550
|
+
/**
|
|
551
|
+
* - the texture to apply (image name, HTMLImageElement, or TextureAtlas). If omitted and settings.material is provided, the texture is resolved from the MTL material's map_Kd. Passing this pins ONE binding over the whole model, which on a multi-material model suppresses the per-material texture split — see {@link Mesh#textureGroups}.
|
|
552
|
+
*/
|
|
553
|
+
texture?: HTMLImageElement | HTMLCanvasElement | Texture2d | TextureAtlas | string;
|
|
554
|
+
/**
|
|
555
|
+
* - name of a preloaded MTL material (via loader.preload with type "mtl"). When provided, the diffuse texture (map_Kd), tint color (Kd), and opacity (d) are automatically applied. On a multi-material model each material's own `map_Kd` is bound for its own slice of the geometry (#1573) and each `Kd` is baked per-vertex, so one `Mesh` renders the whole model.
|
|
556
|
+
*/
|
|
557
|
+
material?: string;
|
|
558
|
+
/**
|
|
559
|
+
* - display width in pixels. With normalization on (the default) the model is scaled to fit this size; with `normalize: false` this is the uniform pixels-per-unit scale applied to the raw geometry. With `normalize: false` and an explicit `scale`, an omitted `width`/`height` is derived from the GEOMETRY's own extent, the way a Sprite takes its size from its frame — a mesh that reports no extent misleads frustum culling, pointer picking and the physics broadphase alike.
|
|
560
|
+
*/
|
|
561
|
+
width: number;
|
|
562
|
+
/**
|
|
563
|
+
* - display height in pixels (normalized models only; ignored when `normalize: false`)
|
|
564
|
+
*/
|
|
565
|
+
height?: number;
|
|
566
|
+
/**
|
|
567
|
+
* - enable backface culling
|
|
568
|
+
*/
|
|
569
|
+
cullBackFaces?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* - fit the source geometry into a `[-0.5, 0.5]` unit cube before scaling, so `width`/`height` behave like a Sprite. Set `false` to keep the geometry's real-world coordinates — required when several meshes share one coordinate space (e.g. nodes of an imported glTF scene) so their relative scale and layout are preserved.
|
|
572
|
+
*/
|
|
573
|
+
normalize?: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* - world-space scale (pixels per source unit) for the Camera3d path; defaults to `width`. Set this when `width`/`height` describe the renderable's world bounds (frustum culling) rather than the geometry scale — see {@link Mesh#meshScale}.
|
|
576
|
+
*/
|
|
577
|
+
scale?: number;
|
|
578
|
+
/**
|
|
579
|
+
* - treat the source as right-handed (Y-up, e.g. glTF) under the `Camera3d` world path. The default Y-up→Y-down bridge negates Y only (a reflection, which mirrors the scene left/right); `true` negates Y **and** Z (a rotation) so chirality is preserved and the result matches the authoring tool. See {@link Mesh#rightHanded}.
|
|
580
|
+
*/
|
|
581
|
+
rightHanded?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* - texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"` / `"no-repeat"`) this mesh samples its texture with (per-mesh — it does not modify the shared texture, so other meshes/sprites using the same image are unaffected). Use `"repeat"` when the geometry's UVs fall outside the `[0, 1]` range and rely on the texture tiling (e.g. glTF assets, whose default sampler wrap is REPEAT) — otherwise the texture clamps to its edge texels and looks flat. Ignored for the white-pixel fallback. Note: REPEAT on a non-power-of-two texture requires WebGL 2.
|
|
584
|
+
*/
|
|
585
|
+
textureRepeat?: string;
|
|
586
|
+
/**
|
|
587
|
+
* - texture magnification filter (`"nearest"` for crisp pixel-art upscaling, `"linear"` for smooth) applied to the resolved texture. Omit to keep the renderer's global `antiAlias` default. On the mesh path, linear filtering also samples a generated mip chain with trilinear minification and 4× anisotropy (distant geometry stops shimmering) — `"nearest"` opts out, keeping crisp pixel-art models on hard level-0 sampling. GPU backends only (ignored by the Canvas renderer).
|
|
588
|
+
*/
|
|
589
|
+
textureFilter?: string;
|
|
590
|
+
/**
|
|
591
|
+
* - alpha cutout threshold. Fragments whose final alpha is below this value are discarded (hard-edged cutout — foliage, fences, decals — with no blending or sorting). `0` disables the cutout. Set automatically by the glTF loader from a material's `alphaMode: "MASK"`. GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).
|
|
592
|
+
*/
|
|
593
|
+
alphaCutoff?: number;
|
|
594
|
+
/**
|
|
595
|
+
* - emissive (self-illumination) color `[r, g, b]` (0..1, may exceed 1 for HDR glow) added on top of the lit/unlit color so the surface glows regardless of scene lights (neon, lava, screens). Omit / all-zero for no emission. Set automatically by the glTF loader (`emissiveFactor`) and OBJ loader (MTL `Ke`). GPU mesh path only (WebGL and WebGPU; the Canvas renderer ignores it).
|
|
596
|
+
*/
|
|
597
|
+
emissive?: number[] | Float32Array;
|
|
598
|
+
/**
|
|
599
|
+
* - shade this mesh with the scene's {@link Light3d} lights (the lit mesh pipeline) instead of rendering fullbright. Set automatically by the glTF importer when the scene carries a directional, point or spot light. With `lit` on and no lights present the batcher uploads a white ambient, so the result is indistinguishable from unlit.
|
|
600
|
+
*/
|
|
601
|
+
lit?: boolean;
|
|
602
|
+
/**
|
|
603
|
+
* - per-vertex colour, one entry per vertex, multiplied into {@link Mesh#tint}. Either packed RGBA8 (`Uint32Array`, the form the batchers read — no conversion) or one {@link Color} per vertex. Omit for plain white. Lets a single mesh carry a gradient — fading a terrain toward the sky with distance, darkening a crease — which a per-object `tint` cannot express. An explicit value wins over the colours a multi-material OBJ bakes from its MTL.
|
|
604
|
+
*/
|
|
605
|
+
vertexColors?: Uint32Array | Color[] | number[];
|
|
606
|
+
/**
|
|
607
|
+
* - per-vertex normals for the lit path. An explicit value wins over the ones an OBJ or glTF source supplies; omit it and they are taken from the model, or generated from the geometry when the mesh is `lit`. Generated normals average per vertex where faces share vertices (smooth shading) and equal the face normal where they do not (flat shading) — the geometry decides, not a flag.
|
|
608
|
+
*/
|
|
609
|
+
normals?: number[] | Float32Array;
|
|
610
|
+
/**
|
|
611
|
+
* - specular color `[r, g, b]` (0..1) for the lit path. Set by the OBJ loader from MTL `Ks`, and derived from glTF metallic/roughness.
|
|
612
|
+
*/
|
|
613
|
+
specular?: number[] | Float32Array;
|
|
614
|
+
/**
|
|
615
|
+
* - specular exponent for the lit path (MTL `Ns`). `0` for a fully diffuse surface.
|
|
616
|
+
*/
|
|
617
|
+
shininess?: number;
|
|
618
|
+
/**
|
|
619
|
+
* - per-texel opacity map, sampled in addition to the diffuse texture (MTL `map_d`).
|
|
620
|
+
*/
|
|
621
|
+
alphaMap?: string | TextureAtlas | HTMLImageElement;
|
|
622
|
+
/**
|
|
623
|
+
* - give this mesh a blob ground shadow, overriding the application's `castGroundShadow` setting in both directions. Omit to inherit. Needs a GPU backend and a `Camera3d`.
|
|
624
|
+
*/
|
|
625
|
+
castGroundShadow?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* - draw in the transparent pass (blended, back-to-front, no depth write). Omit and a mesh goes transparent whenever its draw alpha is fractional; `true` for soft-alpha textures; `false` to stay opaque however faded
|
|
628
|
+
*/
|
|
629
|
+
transparent?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* - set `false` to exempt this mesh from the camera's distance fog ({@link Camera3d#setFog}); omit to fog whenever the camera does
|
|
632
|
+
*/
|
|
633
|
+
fog?: boolean;
|
|
634
|
+
/**
|
|
635
|
+
* - world Y of the floor the shadow lands on. Omit and the blob sits at the object's own base at full strength; set it and the blob shrinks and fades as the object rises. Render space is Y-down, so the floor is a **greater** Y than the object above it.
|
|
636
|
+
*/
|
|
637
|
+
shadowGroundY?: number;
|
|
638
|
+
/**
|
|
639
|
+
* - opacity of the shadow directly beneath the object, before any height fade.
|
|
640
|
+
*/
|
|
641
|
+
shadowOpacity?: number;
|
|
642
|
+
};
|
|
607
643
|
import Renderable from "./renderable.js";
|
|
608
644
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
609
645
|
import { Color } from "../math/color.ts";
|
|
@@ -612,4 +648,5 @@ import { Vector2d } from "../math/vector2d.ts";
|
|
|
612
648
|
import { Polygon } from "../geometries/polygon.ts";
|
|
613
649
|
import { AABB3d } from "../physics/broadphase/aabb3d.ts";
|
|
614
650
|
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
651
|
+
import Texture2d from "./../video/texture/texture2d.ts";
|
|
615
652
|
//# sourceMappingURL=mesh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../src/renderable/mesh.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../src/renderable/mesh.js"],"names":[],"mappings":"AAwZA;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACH,eAhDW,MAAM,KACN,MAAM,YACN,YAAY,EA+0BtB;IApxBC;;;OAGG;IACH,kBAFU,YAAY,CAEkB;IAExC;;;OAGG;IACH,KAFU,YAAY,CAEA;IAqBtB;;;OAGG;IACH,aAFU,MAAM,CAEsB;IAmCvC;;;OAGG;IACH,2BAAoC;IAIpC;;;;;;;;;;;;;;OAcG;IACH,UAFU,YAAY,CAEgC;IAEtD;;;;;OAKG;IACH,iBAFU,YAAY,GAAC,SAAS,CAclB;IAEd;;;;;;;;;OASG;IACH,SAFU,YAAY,CAE+B;IAErD;;;;;;;;;OASG;IACH,KAHU,OAAO,CAGe;IAEhC;;;;;;;;;OASG;IACH,aAHU,MAAM,CAIoD;IAEpE;;;;;;;;;OASG;IACH,UAFU,YAAY,GAAC,SAAS,CAEa;IAE7C;;;;;;;;;;;;OAYG;IACH,UAHU,YAAY,GAAC,SAAS,CAGa;IAE7C;;;;;;;;OAQG;IACH,WAHU,MAAM,CAIgD;IAEhE;;;;;;;;;;OAUG;IACH,UAFU,YAAY,GAAC,SAAS,CAEP;IAEzB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,kBAJU,OAAO,GAAC,SAAS,CAOd;IAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,KAfU,OAAO,GAAC,SAAS,CAe4C;IAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0DG;IACH,aAhBU,OAAO,GAAC,SAAS,CAmBd;IAEb;;;;;;;;;;;;;;;;OAgBG;IACH,eAHU,MAAM,GAAC,SAAS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M;;;;eACN,MAAM,EAAE,GAAC,YAAY;;;;UACrB,OAAO;;;;mBACP,WAAW,GAAC,KAAK,EAAE,GAAC,MAAM,EAAE;;;;cAC5B,MAAM,EAAE,GAAC,YAAY;;;;eACrB,MAAM,EAAE,GAAC,YAAY;;;;gBACrB,MAAM;;;;eACN,MAAM,GAAC,YAAY,GAAC,gBAAgB;;;;uBACpC,OAAO;;;;kBACP,OAAO;;;;UACP,OAAO;;;;oBACP,MAAM;;;;oBACN,MAAM;;uBA/TG,iBAAiB;6BAHX,6BAA6B;sBAXpC,kBAAkB;yBACf,qBAAqB;yBACrB,qBAAqB;wBALtB,0BAA0B;uBAY3B,iCAAiC;+BAU1B,oCAAoC;sBAP5C,iCAAiC"}
|
|
@@ -189,10 +189,24 @@ export default class Renderable extends Rect {
|
|
|
189
189
|
/**
|
|
190
190
|
* Define the renderable opacity<br>
|
|
191
191
|
* Set to zero if you do not wish an object to be drawn
|
|
192
|
+
*
|
|
193
|
+
* Opacity **cascades**: it is multiplied with the alpha already on the
|
|
194
|
+
* renderer, so fading a {@link Container} fades everything inside it,
|
|
195
|
+
* and a child at `alpha` 0.5 inside a parent at 0.5 draws at 0.25.
|
|
196
|
+
* Each renderable keeps its own value — the composition happens at
|
|
197
|
+
* draw time, and is undone when the renderable is done.
|
|
198
|
+
*
|
|
199
|
+
* That is different from {@link Container#setChildsProperty}, which
|
|
200
|
+
* assigns a value onto the children themselves. Use `alpha` to fade a
|
|
201
|
+
* subtree, and `setChildsProperty` to change what the children are.
|
|
192
202
|
* @see Renderable#setOpacity
|
|
193
203
|
* @see Renderable#getOpacity
|
|
204
|
+
* @see Container#setChildsProperty
|
|
194
205
|
* @type {number}
|
|
195
206
|
* @default 1.0
|
|
207
|
+
* @example
|
|
208
|
+
* // fades the whole rig, parts included
|
|
209
|
+
* myModel.alpha = 0.3;
|
|
196
210
|
*/
|
|
197
211
|
alpha: number;
|
|
198
212
|
/**
|
|
@@ -358,6 +372,9 @@ export default class Renderable extends Rect {
|
|
|
358
372
|
getBounds(): Bounds;
|
|
359
373
|
/**
|
|
360
374
|
* get the renderable alpha channel value<br>
|
|
375
|
+
*
|
|
376
|
+
* This is the renderable's OWN value. What it finally draws at is this
|
|
377
|
+
* multiplied by every ancestor's — see {@link Renderable#alpha}.
|
|
361
378
|
* @returns {number} current opacity value between 0 and 1
|
|
362
379
|
*/
|
|
363
380
|
getOpacity(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AA6CA;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;OAeG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAlCU,WAAW,CAkCA;IAErB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAHU,MAAM,GAAC,SAAS,CAGF;IAExB;;;;;OAKG;IACH,MAFU,MAAM,CAEK;IAErB;;;;;;;;;;OAUG;IACH,6BAAmC;IAEnC;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;OAIG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;;OAKG;IACH,UAHU,OAAO,CAGI;IAErB;;;;;;;OAOG;IACH,qBAHU,OAAO,CAGe;IAEhC;;;;;;;;;;;;;;;;OAgBG;IACH,eAdU,OAAO,CAcQ;IAEzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sBAJU,OAAO,CAIe;IAEhC
|
|
1
|
+
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AA6CA;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;OAeG;IACH,aAHU,eAAe,CAMvB;I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0BAF7B,yBAAyB;6BACtB,4BAA4B;6BAG1B,iCAAiC;gCAC9B,sCAAsC;+BACvC,oCAAoC"}
|
|
@@ -80,7 +80,7 @@ export default class Sprite3d extends Mesh {
|
|
|
80
80
|
* @param {number} x - world x position
|
|
81
81
|
* @param {number} y - world y position
|
|
82
82
|
* @param {object} settings - configuration
|
|
83
|
-
* @param {HTMLImageElement|Texture2d|string} [settings.image] - the sprite texture (image name, image, or a {@link Texture2d} asset such as a {@link TextureAtlas}). Alias: `settings.texture`.
|
|
83
|
+
* @param {HTMLImageElement|HTMLCanvasElement|Texture2d|string} [settings.image] - the sprite texture (image name, image, or a {@link Texture2d} asset such as a {@link TextureAtlas}). Alias: `settings.texture`.
|
|
84
84
|
* @param {number} [settings.width=settings.framewidth] - quad width in world units (pixels)
|
|
85
85
|
* @param {number} [settings.height=settings.width] - quad height in world units
|
|
86
86
|
* @param {number} [settings.framewidth] - width of a single frame within a spritesheet (enables frame animation)
|
|
@@ -94,10 +94,15 @@ export default class Sprite3d extends Mesh {
|
|
|
94
94
|
* @param {boolean} [settings.flipY=false] - mirror the sprite vertically (see {@link Sprite3d#flipY})
|
|
95
95
|
* @param {boolean} [settings.lit=false] - shade through the lit mesh batcher (see {@link Mesh})
|
|
96
96
|
* @param {number[]|Float32Array} [settings.emissive] - emissive color (see {@link Mesh})
|
|
97
|
+
* @param {number} [settings.shadowGroundY] - world Y of the floor the blob shadow lands on. Omit and it falls back to the sprite's own base — which for a billboard moves with the camera, so a scene that knows where its floor is should say so.
|
|
98
|
+
* @param {number} [settings.shadowOpacity=0.45] - opacity of the shadow directly beneath the sprite, before any height fade
|
|
99
|
+
* @param {boolean} [settings.castGroundShadow] - give this sprite a blob ground shadow, overriding the application's `castGroundShadow` setting in both directions. Omit to inherit. Needs a GPU backend and a {@link Camera3d}.
|
|
100
|
+
* @param {boolean} [settings.fog] - set `false` to exempt this sprite from the camera's distance fog ({@link Camera3d#setFog}); omit to fog whenever the camera does. A sun or a moon wants this — everything else at that distance dissolves into the haze, and so would it.
|
|
101
|
+
* @param {boolean} [settings.transparent] - draw in the transparent pass (blended, back-to-front, no depth write) instead of the opaque one. Omit and the sprite goes transparent whenever its draw alpha is fractional; `true` for a soft-alpha sprite such as an additive glow; `false` to stay opaque however faded.
|
|
97
102
|
* @param {number} [settings.alphaCutoff=0.5] - alpha cutout threshold (see {@link Mesh}). The mesh pass is opaque (no alpha blending), so this defaults to `0.5` to discard a sprite's transparent background (clean cutout silhouette, correct depth, no sorting). Set `0` for a fully-opaque quad, or tune the threshold.
|
|
98
103
|
*/
|
|
99
104
|
constructor(x: number, y: number, settings: {
|
|
100
|
-
image?: string | HTMLImageElement | Texture2d | undefined;
|
|
105
|
+
image?: string | HTMLImageElement | HTMLCanvasElement | Texture2d | undefined;
|
|
101
106
|
width?: number | undefined;
|
|
102
107
|
height?: number | undefined;
|
|
103
108
|
framewidth?: number | undefined;
|
|
@@ -114,6 +119,11 @@ export default class Sprite3d extends Mesh {
|
|
|
114
119
|
flipY?: boolean | undefined;
|
|
115
120
|
lit?: boolean | undefined;
|
|
116
121
|
emissive?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
122
|
+
shadowGroundY?: number | undefined;
|
|
123
|
+
shadowOpacity?: number | undefined;
|
|
124
|
+
castGroundShadow?: boolean | undefined;
|
|
125
|
+
fog?: boolean | undefined;
|
|
126
|
+
transparent?: boolean | undefined;
|
|
117
127
|
alphaCutoff?: number | undefined;
|
|
118
128
|
});
|
|
119
129
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAoEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC
|
|
1
|
+
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"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BADD,qBAAqB;qBAN3B,uBAAuB;sBAItB,+BAA+B"}
|
|
@@ -15,9 +15,8 @@ export default class BitmapText extends Renderable {
|
|
|
15
15
|
* @param {object} settings - the text configuration
|
|
16
16
|
* @param {string|Image} settings.font - a font name to identify the corresponding source image
|
|
17
17
|
* @param {string} [settings.fontData=settings.font] - the bitmap font data corresponding name, or the bitmap font data itself (AngelCode BMFont, `.fnt` text or `.xml`)
|
|
18
|
-
* @param {number} [settings.size] - size a
|
|
19
|
-
* @param {Color|string} [settings.fillStyle] - a CSS color value used to tint the
|
|
20
|
-
* @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
|
|
18
|
+
* @param {number} [settings.size=1.0] - a scaling RATIO applied to the font's authored size, not a pixel size: `2` draws it at double. ({@link Text} takes pixels here; this one does not.)
|
|
19
|
+
* @param {Color|string} [settings.fillStyle] - a CSS color value used to tint the glyphs, see {@link Renderable#tint}
|
|
21
20
|
* @param {string} [settings.textAlign="left"] - horizontal text alignment
|
|
22
21
|
* @param {string} [settings.textBaseline="top"] - the text baseline
|
|
23
22
|
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
@@ -46,7 +45,6 @@ export default class BitmapText extends Renderable {
|
|
|
46
45
|
fontData?: string | undefined;
|
|
47
46
|
size?: number | undefined;
|
|
48
47
|
fillStyle?: string | Color | undefined;
|
|
49
|
-
lineWidth?: number | undefined;
|
|
50
48
|
textAlign?: string | undefined;
|
|
51
49
|
textBaseline?: string | undefined;
|
|
52
50
|
lineHeight?: number | undefined;
|
|
@@ -106,17 +104,34 @@ export default class BitmapText extends Renderable {
|
|
|
106
104
|
private fontData;
|
|
107
105
|
public set fillStyle(value: Color);
|
|
108
106
|
/**
|
|
109
|
-
* defines the color used to tint the bitmap text
|
|
107
|
+
* defines the color used to tint the bitmap text.
|
|
108
|
+
*
|
|
109
|
+
* This is {@link Renderable#tint} under another name, so the same rule
|
|
110
|
+
* applies: white — `(255, 255, 255)` — is the absence of a tint, and any
|
|
111
|
+
* other colour tints away from there. A page image authored in white
|
|
112
|
+
* therefore keeps every colour available to it.
|
|
110
113
|
* @public
|
|
111
114
|
* @type {Color}
|
|
112
115
|
* @see Renderable#tint
|
|
116
|
+
* @example
|
|
117
|
+
* // tint at construction...
|
|
118
|
+
* const score = new BitmapText(8, 8, {
|
|
119
|
+
* font: "arial",
|
|
120
|
+
* text: "1000",
|
|
121
|
+
* fillStyle: "#ffd700", // gold
|
|
122
|
+
* });
|
|
123
|
+
* app.world.addChild(score);
|
|
124
|
+
*
|
|
125
|
+
* // ...or at any point after it, from a CSS string or a Color
|
|
126
|
+
* score.fillStyle = "#ff4040"; // flash red on damage
|
|
127
|
+
* score.fillStyle = new Color(255, 255, 255); // back to untinted
|
|
113
128
|
*/
|
|
114
129
|
public get fillStyle(): Color;
|
|
115
130
|
metrics: TextMetrics;
|
|
116
131
|
/**
|
|
117
132
|
* change the font settings
|
|
118
133
|
* @param {string} textAlign - ("left", "center", "right")
|
|
119
|
-
* @param {number} [scale]
|
|
134
|
+
* @param {number} [scale] - a scaling ratio, applied through {@link BitmapText#resize} when given
|
|
120
135
|
* @returns {BitmapText} this object for chaining
|
|
121
136
|
*/
|
|
122
137
|
set(textAlign: string, scale?: number): BitmapText;
|
|
@@ -152,14 +167,24 @@ export default class BitmapText extends Renderable {
|
|
|
152
167
|
public get visibleRatio(): number;
|
|
153
168
|
/**
|
|
154
169
|
* change the font display size
|
|
155
|
-
* @param {number} scale - ratio
|
|
170
|
+
* @param {number} scale - a ratio against the font's authored size, NOT a
|
|
171
|
+
* pixel size: `1` is the page image at its native scale, `2` is double
|
|
156
172
|
* @returns {BitmapText} this object for chaining
|
|
173
|
+
* @example
|
|
174
|
+
* // a bitmap font is pixel art — whole-number ratios stay crisp, and
|
|
175
|
+
* // fractional ones resample the page image
|
|
176
|
+
* title.resize(3); // three times its authored size
|
|
177
|
+
* title.set("center", 2); // align and rescale in one call
|
|
157
178
|
*/
|
|
158
179
|
resize(scale: number): BitmapText;
|
|
159
180
|
/**
|
|
160
181
|
* measure the given text size in pixels
|
|
161
182
|
* @param {string} [text]
|
|
162
183
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
184
|
+
* @example
|
|
185
|
+
* // size a panel around a label, at the label's CURRENT scale
|
|
186
|
+
* const size = label.measureText();
|
|
187
|
+
* panel.resize(size.width + 16, size.height + 16);
|
|
163
188
|
*/
|
|
164
189
|
measureText(text?: string): TextMetrics;
|
|
165
190
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH;IACC
|
|
1
|
+
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,eA9BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,YAAY;QACZ,UAAU;QACmB,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;QACjB,aAAa;QACF,IAAI;KACzC,EAqIF;IAhHA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;;;OAKG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAmOlE,4BAlBU,KAAK,EAyBd;IAjCD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,wBAfU,KAAK,CAiBd;IAnMA;;;OAGG;IACH,2BAA4B;IAG5B,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAwBtB;IAoBD,oCAdU,MAAM,EAmBf;IAvBD;;;;;;;;;;;;;OAaG;IACH,gCAVU,MAAM,CAYf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAsGD;;;;;;;;;;OAUG;IACH,cATW,MAAM,GAEJ,UAAU,CAiBtB;IAED;;;;;;;;OAQG;IACH,mBAPW,MAAM,GACJ,WAAW,CAQvB;IAED;;;OAGG;IACH,eAFW,cAAc,GAAC,aAAa,QAmGtC;IAED;;;;OAIG;IACH,gBAQC;CACD;uBAxfsB,kBAAkB;sBAHnB,qBAAqB;wBAKnB,kBAAkB"}
|
|
@@ -20,7 +20,8 @@ export default class Text extends Renderable {
|
|
|
20
20
|
* @param {object} settings - the text configuration
|
|
21
21
|
* @param {string} settings.font - a CSS font family: a specific name (`"Arial"`), a generic keyword (`"sans-serif"`, `"monospace"`, …), or a web font loaded via the `fontface` loader (referenced by its family name)
|
|
22
22
|
* @param {number|string} settings.size - the font size: a number in pixels, or a CSS size string with a unit (`"24px"` / `"1.5em"` / `"18pt"`)
|
|
23
|
-
* @param {Color|string} [settings.fillStyle="#000000"] - a CSS color value used to fill the glyphs
|
|
23
|
+
* @param {Color|Gradient|string} [settings.fillStyle="#000000"] - a CSS color value used to fill the glyphs, or a {@link Gradient} to ramp them
|
|
24
|
+
* @param {boolean} [settings.gradientPerLine=true] - restart a gradient fill on every line; `false` spans one ramp across the whole block, as a plain canvas does
|
|
24
25
|
* @param {Color|string} [settings.strokeStyle="#000000"] - a CSS color value used for the glyph outline (drawn when `lineWidth` > 0)
|
|
25
26
|
* @param {number} [settings.lineWidth=0] - outline width in pixels (0 = no stroke)
|
|
26
27
|
* @param {string} [settings.textAlign="left"] - horizontal text alignment ("left", "center", "right")
|
|
@@ -28,6 +29,8 @@ export default class Text extends Renderable {
|
|
|
28
29
|
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
29
30
|
* @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`.
|
|
30
31
|
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixels of a line before it wraps
|
|
32
|
+
* @param {boolean} [settings.bold=false] - render the face bold, as {@link Text#bold} does
|
|
33
|
+
* @param {boolean} [settings.italic=false] - render the face italic, as {@link Text#italic} does
|
|
31
34
|
* @param {(string|string[])} [settings.text=""] - a string, or an array of strings
|
|
32
35
|
* @example
|
|
33
36
|
* // a styled, word-wrapped, multi-line label using a generic system font
|
|
@@ -46,6 +49,23 @@ export default class Text extends Renderable {
|
|
|
46
49
|
* label.setOpacity(0.8); // per-object transparency
|
|
47
50
|
* app.world.addChild(label);
|
|
48
51
|
* @example
|
|
52
|
+
* // a gradient fill: `fillStyle` takes a Gradient as well as a colour.
|
|
53
|
+
* // Its coordinates are the label's OWN bake, so (0, 0) is the top-left of
|
|
54
|
+
* // the render box and the ramp below runs down exactly one line.
|
|
55
|
+
* const ramp = app.renderer.createLinearGradient(0, 0, 0, 32);
|
|
56
|
+
* ramp.addColorStop(0, "#fffdf0");
|
|
57
|
+
* ramp.addColorStop(1, "#ffa71d");
|
|
58
|
+
*
|
|
59
|
+
* app.world.addChild(new Text(8, 8, {
|
|
60
|
+
* font: "sans-serif",
|
|
61
|
+
* size: 32,
|
|
62
|
+
* fillStyle: ramp, // ramps the glyphs...
|
|
63
|
+
* strokeStyle: "#000000", // ...while the outline keeps its own colour
|
|
64
|
+
* lineWidth: 1,
|
|
65
|
+
* text: "GAME\nOVER", // every line restarts the ramp by default
|
|
66
|
+
* // gradientPerLine: false, // ...or span ONE ramp across both lines
|
|
67
|
+
* }));
|
|
68
|
+
* @example
|
|
49
69
|
* // a web font (loaded via the fontface loader) is used by its family name
|
|
50
70
|
* loader.preload(
|
|
51
71
|
* [{ name: "kenpixel", type: "fontface", src: "data/font/kenvector.woff2" }],
|
|
@@ -59,7 +79,8 @@ export default class Text extends Renderable {
|
|
|
59
79
|
constructor(x: number, y: number, settings: {
|
|
60
80
|
font: string;
|
|
61
81
|
size: number | string;
|
|
62
|
-
fillStyle?: string | Color | undefined;
|
|
82
|
+
fillStyle?: string | Color | Gradient | undefined;
|
|
83
|
+
gradientPerLine?: boolean | undefined;
|
|
63
84
|
strokeStyle?: string | Color | undefined;
|
|
64
85
|
lineWidth?: number | undefined;
|
|
65
86
|
textAlign?: string | undefined;
|
|
@@ -70,6 +91,8 @@ export default class Text extends Renderable {
|
|
|
70
91
|
y: number;
|
|
71
92
|
};
|
|
72
93
|
wordWrapWidth?: number | undefined;
|
|
94
|
+
bold?: boolean | undefined;
|
|
95
|
+
italic?: boolean | undefined;
|
|
73
96
|
text?: string | string[] | undefined;
|
|
74
97
|
});
|
|
75
98
|
/**
|
|
@@ -124,6 +147,40 @@ export default class Text extends Renderable {
|
|
|
124
147
|
* @default 10
|
|
125
148
|
*/
|
|
126
149
|
fontSize: number;
|
|
150
|
+
/**
|
|
151
|
+
* The gradient to fill the glyphs with, when one was given instead of a
|
|
152
|
+
* colour. Built by {@link Renderer#createLinearGradient} /
|
|
153
|
+
* {@link Renderer#createRadialGradient}, and its coordinates are this
|
|
154
|
+
* label's own bake — `(0, 0)` is the top-left of the render box.
|
|
155
|
+
*
|
|
156
|
+
* Set it through `fillStyle`, the way `Renderer#setColor` takes one;
|
|
157
|
+
* this field is where it lands so the pooled `fillStyle` `Color` keeps
|
|
158
|
+
* its type, its alpha and its pooling.
|
|
159
|
+
* @type {Gradient|undefined}
|
|
160
|
+
* @default undefined
|
|
161
|
+
* @example
|
|
162
|
+
* const ramp = renderer.createLinearGradient(0, 0, 0, 24);
|
|
163
|
+
* ramp.addColorStop(0, "#fffdf0");
|
|
164
|
+
* ramp.addColorStop(1, "#f0a020");
|
|
165
|
+
* const label = new Text(x, y, { font: "Arial", size: 24, fillStyle: ramp });
|
|
166
|
+
*/
|
|
167
|
+
fillGradient: Gradient | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* Whether a gradient fill restarts on every line.
|
|
170
|
+
*
|
|
171
|
+
* `true` (the default) re-anchors the ramp to each line, so a
|
|
172
|
+
* multi-line label reads like one `Text` per line — which is how a HUD
|
|
173
|
+
* is usually built, and means the ramp does not have to be authored
|
|
174
|
+
* over the block height to look right.
|
|
175
|
+
*
|
|
176
|
+
* `false` spans one ramp across the whole block, which is what a plain
|
|
177
|
+
* canvas does: a `CanvasGradient` lives in the current transform's
|
|
178
|
+
* space, so lines further down sample further along it. Use it for a
|
|
179
|
+
* deliberate fade across a multi-line title.
|
|
180
|
+
* @type {boolean}
|
|
181
|
+
* @default true
|
|
182
|
+
*/
|
|
183
|
+
gradientPerLine: boolean | undefined;
|
|
127
184
|
canvasTexture: CanvasRenderTarget | undefined;
|
|
128
185
|
metrics: TextMetrics | undefined;
|
|
129
186
|
/**
|
|
@@ -170,15 +227,32 @@ export default class Text extends Renderable {
|
|
|
170
227
|
public set visibleRatio(value: number);
|
|
171
228
|
/**
|
|
172
229
|
* the ratio of visible characters (0.0 to 1.0).
|
|
173
|
-
* Setting this automatically updates {@link visibleCharacters}.
|
|
230
|
+
* Setting this automatically updates {@link Text#visibleCharacters}.
|
|
231
|
+
*
|
|
232
|
+
* This is the one to tween: it is independent of how many characters the
|
|
233
|
+
* label holds, so a reveal takes the same time whatever the string is.
|
|
174
234
|
* @public
|
|
175
235
|
* @type {number}
|
|
236
|
+
* @default 1.0
|
|
237
|
+
* @see Text#visibleCharacters
|
|
238
|
+
* @example
|
|
239
|
+
* // reveal over two seconds, regardless of length
|
|
240
|
+
* label.visibleRatio = 0;
|
|
241
|
+
* new Tween(label).to({ visibleRatio: 1.0 }, { duration: 2000 }).start();
|
|
176
242
|
*/
|
|
177
243
|
public get visibleRatio(): number;
|
|
178
244
|
/**
|
|
179
245
|
* measure the given text size in pixels
|
|
180
246
|
* @param {string} [text] - the text to be measured
|
|
181
247
|
* @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
|
|
248
|
+
* @example
|
|
249
|
+
* // size a panel around a label
|
|
250
|
+
* const size = label.measureText();
|
|
251
|
+
* panel.resize(size.width + 16, size.height + 16);
|
|
252
|
+
*
|
|
253
|
+
* // or measure a string the label does not currently hold, to reserve
|
|
254
|
+
* // room for the widest state a counter will reach
|
|
255
|
+
* const widest = label.measureText("00:00").width;
|
|
182
256
|
*/
|
|
183
257
|
measureText(text?: string): TextMetrics;
|
|
184
258
|
/**
|
|
@@ -189,6 +263,7 @@ export default class Text extends Renderable {
|
|
|
189
263
|
}
|
|
190
264
|
import Renderable from "../renderable.js";
|
|
191
265
|
import { Color } from "../../math/color.ts";
|
|
266
|
+
import { Gradient } from "../../video/gradient.js";
|
|
192
267
|
import CanvasRenderTarget from "../../video/rendertarget/canvasrendertarget.js";
|
|
193
268
|
import TextMetrics from "./textmetrics.js";
|
|
194
269
|
//# sourceMappingURL=text.d.ts.map
|