melonjs 18.3.0 → 19.1.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/README.md +11 -4
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -1
- package/build/application/header.d.ts.map +1 -1
- package/build/application/settings.d.ts +46 -7
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +1 -2
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/geometries/earcut.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/index.d.ts +20 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3174 -783
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/level/level.d.ts +3 -3
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/loader/cache.d.ts +2 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +60 -0
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -1
- package/build/loader/parsers/mtl.d.ts +11 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -0
- package/build/loader/parsers/obj.d.ts +11 -0
- package/build/loader/parsers/obj.d.ts.map +1 -0
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +12 -0
- package/build/math/math.d.ts.map +1 -1
- package/build/math/matrix2d.d.ts +2 -2
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/matrix3d.d.ts +19 -4
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +1 -1
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +1 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts +42 -0
- package/build/math/vertex.d.ts.map +1 -0
- package/build/particles/particle.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +3 -2
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/renderable/container.d.ts +21 -5
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +7 -0
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +147 -0
- package/build/renderable/mesh.d.ts.map +1 -0
- package/build/renderable/renderable.d.ts +56 -30
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +1 -1
- package/build/renderable/text/bitmaptext.d.ts +1 -10
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/glyph.d.ts +1 -1
- package/build/renderable/text/glyph.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +2 -12
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/trail.d.ts +120 -0
- package/build/renderable/trail.d.ts.map +1 -0
- package/build/renderable/ui/uitextbutton.d.ts +2 -6
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts +39 -57
- package/build/state/stage.d.ts.map +1 -1
- package/build/state/state.d.ts +14 -28
- package/build/state/state.d.ts.map +1 -1
- package/build/system/event.d.ts +1 -1
- package/build/system/event.d.ts.map +1 -1
- package/build/system/eventEmitter.d.ts.map +1 -1
- package/build/tweens/easing.d.ts +23 -34
- package/build/tweens/easing.d.ts.map +1 -1
- package/build/tweens/interpolation.d.ts +32 -0
- package/build/tweens/interpolation.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +77 -41
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +7 -4
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/gradient.d.ts +31 -0
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +17 -6
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +4 -4
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +6 -0
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +65 -0
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts +20 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts +17 -39
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +5 -0
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertex.d.ts +13 -2
- package/build/video/webgl/buffer/vertex.d.ts.map +1 -1
- package/build/video/webgl/effects/blur.d.ts +36 -0
- package/build/video/webgl/effects/blur.d.ts.map +1 -0
- package/build/video/webgl/effects/chromaticAberration.d.ts +39 -0
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/webgl/effects/desaturate.d.ts +32 -0
- package/build/video/webgl/effects/desaturate.d.ts.map +1 -0
- package/build/video/webgl/effects/dissolve.d.ts +42 -0
- package/build/video/webgl/effects/dissolve.d.ts.map +1 -0
- package/build/video/webgl/effects/dropShadow.d.ts +47 -0
- package/build/video/webgl/effects/dropShadow.d.ts.map +1 -0
- package/build/video/webgl/effects/flash.d.ts +46 -0
- package/build/video/webgl/effects/flash.d.ts.map +1 -0
- package/build/video/webgl/effects/glow.d.ts +48 -0
- package/build/video/webgl/effects/glow.d.ts.map +1 -0
- package/build/video/webgl/effects/hologram.d.ts +37 -0
- package/build/video/webgl/effects/hologram.d.ts.map +1 -0
- package/build/video/webgl/effects/invert.d.ts +29 -0
- package/build/video/webgl/effects/invert.d.ts.map +1 -0
- package/build/video/webgl/effects/outline.d.ts +49 -0
- package/build/video/webgl/effects/outline.d.ts.map +1 -0
- package/build/video/webgl/effects/pixelate.d.ts +38 -0
- package/build/video/webgl/effects/pixelate.d.ts.map +1 -0
- package/build/video/webgl/effects/scanline.d.ts +47 -0
- package/build/video/webgl/effects/scanline.d.ts.map +1 -0
- package/build/video/webgl/effects/sepia.d.ts +28 -0
- package/build/video/webgl/effects/sepia.d.ts.map +1 -0
- package/build/video/webgl/effects/tintPulse.d.ts +43 -0
- package/build/video/webgl/effects/tintPulse.d.ts.map +1 -0
- package/build/video/webgl/effects/wave.d.ts +43 -0
- package/build/video/webgl/effects/wave.d.ts.map +1 -0
- package/build/video/webgl/shadereffect.d.ts.map +1 -1
- package/build/video/webgl/shaders/multitexture.d.ts +10 -0
- package/build/video/webgl/shaders/multitexture.d.ts.map +1 -0
- package/build/video/webgl/utils/precision.d.ts +4 -3
- package/build/video/webgl/utils/precision.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +15 -9
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,147 @@
|
|
|
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 WebGL (hardware depth testing) and Canvas (painter's algorithm) renderers.
|
|
8
|
+
* @category Game Objects
|
|
9
|
+
*/
|
|
10
|
+
export default class Mesh extends Renderable {
|
|
11
|
+
/**
|
|
12
|
+
* @param {number} x - the x screen position of the mesh object
|
|
13
|
+
* @param {number} y - the y screen position of the mesh object
|
|
14
|
+
* @param {object} settings - Configuration parameters for the Mesh object
|
|
15
|
+
* @param {string} [settings.model] - name of a preloaded OBJ model (via loader.preload with type "obj")
|
|
16
|
+
* @param {Float32Array|number[]} [settings.vertices] - vertex positions as x,y,z triplets (alternative to settings.model)
|
|
17
|
+
* @param {Float32Array|number[]} [settings.uvs] - texture coordinates as u,v pairs (alternative to settings.model)
|
|
18
|
+
* @param {Uint16Array|number[]} [settings.indices] - triangle vertex indices (alternative to settings.model)
|
|
19
|
+
* @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.
|
|
20
|
+
* @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.
|
|
21
|
+
* @param {number} settings.width - display width in pixels (the 3D model is normalized and scaled to fit this size)
|
|
22
|
+
* @param {number} settings.height - display height in pixels (the 3D model is normalized and scaled to fit this size)
|
|
23
|
+
* @param {boolean} [settings.cullBackFaces=true] - enable backface culling
|
|
24
|
+
* @example
|
|
25
|
+
* // create from OBJ + MTL (texture auto-resolved from material)
|
|
26
|
+
* let mesh = new me.Mesh(0, 0, {
|
|
27
|
+
* model: "fox",
|
|
28
|
+
* material: "fox",
|
|
29
|
+
* width: 200,
|
|
30
|
+
* height: 200,
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // create from OBJ with explicit texture (no MTL needed)
|
|
34
|
+
* let mesh = new me.Mesh(0, 0, {
|
|
35
|
+
* model: "cube",
|
|
36
|
+
* texture: "cube_texture",
|
|
37
|
+
* width: 200,
|
|
38
|
+
* height: 200,
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // 3D rotation using the standard rotate() API
|
|
42
|
+
* mesh.rotate(Math.PI / 4, new me.Vector3d(0, 1, 0)); // rotate around Y axis
|
|
43
|
+
*
|
|
44
|
+
* // 2D rotation (Z axis, same as Sprite)
|
|
45
|
+
* mesh.rotate(Math.PI / 4);
|
|
46
|
+
*/
|
|
47
|
+
constructor(x: number, y: number, settings: {
|
|
48
|
+
model?: string | undefined;
|
|
49
|
+
vertices?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
50
|
+
uvs?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
51
|
+
indices?: number[] | Uint16Array<ArrayBufferLike> | undefined;
|
|
52
|
+
texture?: string | HTMLImageElement | TextureAtlas | undefined;
|
|
53
|
+
material?: string | undefined;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
cullBackFaces?: boolean | undefined;
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* the original (untransformed) vertex positions as x,y,z triplets
|
|
60
|
+
* @type {Float32Array}
|
|
61
|
+
*/
|
|
62
|
+
originalVertices: Float32Array;
|
|
63
|
+
/**
|
|
64
|
+
* texture coordinates as u,v pairs
|
|
65
|
+
* @type {Float32Array}
|
|
66
|
+
*/
|
|
67
|
+
uvs: Float32Array;
|
|
68
|
+
/**
|
|
69
|
+
* number of vertices
|
|
70
|
+
* @type {number}
|
|
71
|
+
*/
|
|
72
|
+
vertexCount: number;
|
|
73
|
+
/**
|
|
74
|
+
* the projected vertex positions, updated each draw call
|
|
75
|
+
* @type {Float32Array}
|
|
76
|
+
*/
|
|
77
|
+
vertices: Float32Array;
|
|
78
|
+
/**
|
|
79
|
+
* whether to cull back-facing triangles
|
|
80
|
+
* @type {boolean}
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
cullBackFaces: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* the texture atlas used by this mesh
|
|
86
|
+
* @type {TextureAtlas}
|
|
87
|
+
*/
|
|
88
|
+
texture: TextureAtlas;
|
|
89
|
+
/**
|
|
90
|
+
* Projection matrix applied automatically before the model transform in draw().
|
|
91
|
+
* Defaults to a perspective projection (45° FOV, camera at z=-2.5) suitable for
|
|
92
|
+
* viewing unit-cube-sized geometry. Set to identity for orthographic (flat) projection.
|
|
93
|
+
* Most users don't need to modify this — the default works for standard OBJ models.
|
|
94
|
+
* @type {Matrix3d}
|
|
95
|
+
*/
|
|
96
|
+
projectionMatrix: Matrix3d;
|
|
97
|
+
/** @ignore */
|
|
98
|
+
_hullPoints: Vector2d[];
|
|
99
|
+
/** @ignore */
|
|
100
|
+
_hullPolygon: Polygon | null;
|
|
101
|
+
/**
|
|
102
|
+
* Project all vertices through projectionMatrix × currentTransform
|
|
103
|
+
* and store the results in `this.vertices`.
|
|
104
|
+
* @param {number} [offsetX=0] - x offset added to each projected vertex
|
|
105
|
+
* @param {number} [offsetY=0] - y offset added to each projected vertex
|
|
106
|
+
* @param {number} [zScale=0] - scale factor for Z output (0 = skip Z, 1000 = depth buffer range)
|
|
107
|
+
* @ignore
|
|
108
|
+
*/
|
|
109
|
+
_projectVertices(offsetX?: number, offsetY?: number, zScale?: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* Draw the mesh (automatically called by melonJS).
|
|
112
|
+
* Projects vertices through projectionMatrix × currentTransform and calls renderer.drawMesh().
|
|
113
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer instance
|
|
114
|
+
*/
|
|
115
|
+
draw(renderer: CanvasRenderer | WebGLRenderer): void;
|
|
116
|
+
/**
|
|
117
|
+
* Render the mesh at its current state (transforms, projection, tint) to an offscreen canvas.
|
|
118
|
+
* The returned canvas can be used with `renderer.drawImage()`, as a `Sprite` image source,
|
|
119
|
+
* or converted to an ImageBitmap via `createImageBitmap()`.
|
|
120
|
+
* @returns {HTMLCanvasElement} an offscreen canvas containing the rendered mesh
|
|
121
|
+
* @example
|
|
122
|
+
* // snapshot the mesh and create a Sprite from it
|
|
123
|
+
* const canvas = mesh.toCanvas();
|
|
124
|
+
* const sprite = new me.Sprite(100, 100, { image: canvas });
|
|
125
|
+
*
|
|
126
|
+
* // or draw directly
|
|
127
|
+
* renderer.drawImage(mesh.toCanvas(), 100, 100);
|
|
128
|
+
*/
|
|
129
|
+
toCanvas(): HTMLCanvasElement;
|
|
130
|
+
/**
|
|
131
|
+
* Render the mesh at its current state to an ImageBitmap.
|
|
132
|
+
* Useful for creating textures or sprites from the rendered mesh.
|
|
133
|
+
* @returns {Promise<ImageBitmap>} a promise that resolves to an ImageBitmap of the rendered mesh
|
|
134
|
+
* @example
|
|
135
|
+
* const bitmap = await mesh.toImageBitmap();
|
|
136
|
+
* const sprite = new me.Sprite(100, 100, { image: bitmap });
|
|
137
|
+
*/
|
|
138
|
+
toImageBitmap(): Promise<ImageBitmap>;
|
|
139
|
+
}
|
|
140
|
+
import Renderable from "./renderable.js";
|
|
141
|
+
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
142
|
+
import { Matrix3d } from "../math/matrix3d.ts";
|
|
143
|
+
import { Vector2d } from "../math/vector2d.ts";
|
|
144
|
+
import { Polygon } from "../geometries/polygon.ts";
|
|
145
|
+
import type CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
146
|
+
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
147
|
+
//# sourceMappingURL=mesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../src/renderable/mesh.js"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,eAnCW,MAAM,KACN,MAAM,YAEd;QAA0B,KAAK;QACU,QAAQ;QACR,GAAG;QACJ,OAAO;QACS,OAAO;QACrC,QAAQ;QACT,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACa,aAAa;KACxC,EAqKF;IArIC;;;OAGG;IACH,kBAFU,YAAY,CAEkB;IAExC;;;OAGG;IACH,KAFU,YAAY,CAEA;IAQtB;;;OAGG;IACH,aAFU,MAAM,CAEsB;IAkBvC;;;OAGG;IACH,UAFU,YAAY,CAEgC;IAEtD;;;;OAIG;IACH,eAHU,OAAO,CAIoD;IAgCpE;;;OAGG;IACH,SAFU,YAAY,CAEM;IAiB7B;;;;;;OAMG;IACH,kBAFU,QAAQ,CAEoB;IAetC,cAAc;IACd,wBAEE;IACF,cAAc;IACd,6BAAwB;IAGzB;;;;;;;OAOG;IACH,2BALW,MAAM,YACN,MAAM,WACN,MAAM,QAiBhB;IAED;;;;OAIG;IACH,eAFW,cAAc,GAAC,aAAa,QAKtC;IAyBD;;;;;;;;;;;;OAYG;IACH,YATa,iBAAiB,CAoH7B;IAED;;;;;;;OAOG;IACH,iBALa,OAAO,CAAC,WAAW,CAAC,CAOhC;CACD;uBAvYsB,iBAAiB;6BADX,6BAA6B;yBAPjC,qBAAqB;yBACrB,qBAAqB;wBAHtB,0BAA0B;gCAcnB,sCAAsC;+BACvC,oCAAoC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* additional import for TypeScript
|
|
3
|
-
* @import {
|
|
3
|
+
* @import {Matrix3d} from "../math/matrix3d.ts";
|
|
4
4
|
* @import Entity from "./entity/entity.js";
|
|
5
5
|
* @import Container from "./container.js";
|
|
6
6
|
* @import {Line} from "./../geometries/line.ts";
|
|
@@ -31,10 +31,14 @@ export default class Renderable extends Rect {
|
|
|
31
31
|
*/
|
|
32
32
|
anchorPoint: ObservablePoint;
|
|
33
33
|
/**
|
|
34
|
-
* the renderable
|
|
35
|
-
*
|
|
34
|
+
* the renderable transformation matrix (4x4).
|
|
35
|
+
* For standard 2D use, only the 2D components are used (rotate around Z, scale X/Y, translate X/Y).
|
|
36
|
+
* For 3D use (e.g. Mesh), the full 4x4 matrix supports rotation around any axis,
|
|
37
|
+
* 3D translation, and perspective projection.
|
|
38
|
+
* Use the `rotate()`, `scale()`, and `translate()` methods rather than modifying this directly.
|
|
39
|
+
* @type {Matrix3d}
|
|
36
40
|
*/
|
|
37
|
-
currentTransform:
|
|
41
|
+
currentTransform: Matrix3d;
|
|
38
42
|
/**
|
|
39
43
|
* the renderable physic body
|
|
40
44
|
* @type {Body}
|
|
@@ -182,13 +186,33 @@ export default class Renderable extends Rect {
|
|
|
182
186
|
mask: Rect | RoundRect | Polygon | Line | Ellipse;
|
|
183
187
|
/**
|
|
184
188
|
* an optional shader, to be used instead of the default built-in one, when drawing this renderable (WebGL only).
|
|
185
|
-
* Use {@link ShaderEffect} for a
|
|
186
|
-
* or
|
|
189
|
+
* Use {@link ShaderEffect} for a custom fragment `apply()` function,
|
|
190
|
+
* or one of the built-in effect presets:
|
|
191
|
+
* - {@link FlashEffect} — flash the sprite with a solid color (hit feedback)
|
|
192
|
+
* - {@link OutlineEffect} — colored outline around the sprite (selection, hover)
|
|
193
|
+
* - {@link GlowEffect} — soft colored glow around the sprite (power-ups, magic)
|
|
194
|
+
* - {@link DesaturateEffect} — partial or full grayscale (disabled, death)
|
|
195
|
+
* - {@link PixelateEffect} — progressive pixelation (teleport, retro)
|
|
196
|
+
* - {@link BlurEffect} — box blur (defocus, backdrop)
|
|
197
|
+
* - {@link ChromaticAberrationEffect} — RGB channel offset (impact, glitch)
|
|
198
|
+
* - {@link DissolveEffect} — noise-based dissolve (death, spawn)
|
|
199
|
+
* - {@link DropShadowEffect} — offset shadow beneath the sprite
|
|
200
|
+
* - {@link ScanlineEffect} — horizontal scanlines with optional CRT curvature and vignette
|
|
201
|
+
* - {@link TintPulseEffect} — pulsing color overlay (poison, freeze, fire)
|
|
202
|
+
* - {@link WaveEffect} — sine wave distortion (underwater, heat haze)
|
|
203
|
+
* - {@link InvertEffect} — color inversion (negative image, X-ray)
|
|
204
|
+
* - {@link SepiaEffect} — warm vintage photo tone
|
|
205
|
+
* - {@link HologramEffect} — flickering holographic projection (sci-fi)
|
|
206
|
+
*
|
|
207
|
+
* Use {@link GLShader} for full control over vertex and fragment shaders.
|
|
187
208
|
* In Canvas mode, this property is ignored.
|
|
188
209
|
* @type {GLShader|ShaderEffect}
|
|
189
210
|
* @default undefined
|
|
190
211
|
* @example
|
|
191
|
-
* //
|
|
212
|
+
* // apply a built-in effect
|
|
213
|
+
* mySprite.shader = new FlashEffect(renderer, { intensity: 1.0 });
|
|
214
|
+
* @example
|
|
215
|
+
* // custom shader effect
|
|
192
216
|
* mySprite.shader = new ShaderEffect(renderer, `
|
|
193
217
|
* vec4 apply(vec4 color, vec2 uv) {
|
|
194
218
|
* float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
|
@@ -196,18 +220,6 @@ export default class Renderable extends Rect {
|
|
|
196
220
|
* }
|
|
197
221
|
* `);
|
|
198
222
|
* @example
|
|
199
|
-
* // pulsing brightness effect — makes the sprite glow rhythmically
|
|
200
|
-
* const effect = new ShaderEffect(renderer, `
|
|
201
|
-
* uniform float uTime;
|
|
202
|
-
* vec4 apply(vec4 color, vec2 uv) {
|
|
203
|
-
* float pulse = 0.8 + 0.2 * sin(uTime * 3.0);
|
|
204
|
-
* return vec4(color.rgb * pulse, color.a);
|
|
205
|
-
* }
|
|
206
|
-
* `);
|
|
207
|
-
* mySprite.shader = effect;
|
|
208
|
-
* // update the uniform each frame
|
|
209
|
-
* effect.setUniform("uTime", time);
|
|
210
|
-
* @example
|
|
211
223
|
* // to remove a custom shader
|
|
212
224
|
* mySprite.shader = undefined;
|
|
213
225
|
*/
|
|
@@ -264,7 +276,7 @@ export default class Renderable extends Rect {
|
|
|
264
276
|
* renderable cache tint value used by the getter/setter
|
|
265
277
|
* @ignore
|
|
266
278
|
*/
|
|
267
|
-
_tint: Color;
|
|
279
|
+
_tint: import("../index.ts").Color;
|
|
268
280
|
/**
|
|
269
281
|
* returns the parent application (or game) to which this renderable is attached to
|
|
270
282
|
* @return {Application} the parent application or undefined if not attached to any container/app
|
|
@@ -315,6 +327,11 @@ export default class Renderable extends Rect {
|
|
|
315
327
|
* @type {boolean}
|
|
316
328
|
*/
|
|
317
329
|
public get isFlippedY(): boolean;
|
|
330
|
+
/**
|
|
331
|
+
* returns the bounding box for this renderable
|
|
332
|
+
* @returns {Bounds} bounding box Rectangle object
|
|
333
|
+
*/
|
|
334
|
+
getBounds(): Bounds;
|
|
318
335
|
/**
|
|
319
336
|
* get the renderable alpha channel value<br>
|
|
320
337
|
* @returns {number} current opacity value between 0 and 1
|
|
@@ -327,14 +344,14 @@ export default class Renderable extends Rect {
|
|
|
327
344
|
setOpacity(alpha: number): void;
|
|
328
345
|
/**
|
|
329
346
|
* flip the renderable on the horizontal axis (around the center of the renderable)
|
|
330
|
-
* @see
|
|
347
|
+
* @see Matrix3d#scaleX
|
|
331
348
|
* @param {boolean} [flip=true] - `true` to flip this renderable.
|
|
332
349
|
* @returns {Renderable} Reference to this object for method chaining
|
|
333
350
|
*/
|
|
334
351
|
flipX(flip?: boolean): Renderable;
|
|
335
352
|
/**
|
|
336
353
|
* flip the renderable on the vertical axis (around the center of the renderable)
|
|
337
|
-
* @see
|
|
354
|
+
* @see Matrix3d#scaleY
|
|
338
355
|
* @param {boolean} [flip=true] - `true` to flip this renderable.
|
|
339
356
|
* @returns {Renderable} Reference to this object for method chaining
|
|
340
357
|
*/
|
|
@@ -342,10 +359,10 @@ export default class Renderable extends Rect {
|
|
|
342
359
|
/**
|
|
343
360
|
* multiply the renderable currentTransform with the given matrix
|
|
344
361
|
* @see Renderable#currentTransform
|
|
345
|
-
* @param {Matrix2d} m - the transformation matrix
|
|
362
|
+
* @param {Matrix2d|Matrix3d} m - the transformation matrix
|
|
346
363
|
* @returns {Renderable} Reference to this object for method chaining
|
|
347
364
|
*/
|
|
348
|
-
transform(m: Matrix2d): Renderable;
|
|
365
|
+
transform(m: Matrix2d | Matrix3d): Renderable;
|
|
349
366
|
/**
|
|
350
367
|
* return the angle to the specified target
|
|
351
368
|
* @param {Renderable|Vector2d|Vector3d} target
|
|
@@ -366,11 +383,13 @@ export default class Renderable extends Rect {
|
|
|
366
383
|
lookAt(target: Renderable | Vector2d | Vector3d): Renderable;
|
|
367
384
|
/**
|
|
368
385
|
* Rotate this renderable by the specified angle (in radians).
|
|
386
|
+
* When called with just an angle, rotates around the Z axis (2D rotation).
|
|
387
|
+
* When called with an angle and a Vector3d axis, rotates around that axis in 3D.
|
|
369
388
|
* @param {number} angle - The angle to rotate (in radians)
|
|
370
|
-
* @param {
|
|
389
|
+
* @param {Vector3d} [v] - the axis to rotate around (defaults to Z axis for 2D)
|
|
371
390
|
* @returns {Renderable} Reference to this object for method chaining
|
|
372
391
|
*/
|
|
373
|
-
rotate(angle: number, v?:
|
|
392
|
+
rotate(angle: number, v?: Vector3d): Renderable;
|
|
374
393
|
/**
|
|
375
394
|
* scale the renderable around his anchor point. Scaling actually applies changes
|
|
376
395
|
* to the currentTransform member which is used by the renderer to scale the object
|
|
@@ -379,15 +398,24 @@ export default class Renderable extends Rect {
|
|
|
379
398
|
* member will be changed.
|
|
380
399
|
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
381
400
|
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
401
|
+
* @param {number} [z=1] - a number representing the depth of the scaling vector.
|
|
382
402
|
* @returns {Renderable} Reference to this object for method chaining
|
|
383
403
|
*/
|
|
384
|
-
scale(x: number, y?: number): Renderable;
|
|
404
|
+
scale(x: number, y?: number, z?: number): Renderable;
|
|
385
405
|
/**
|
|
386
406
|
* scale the renderable around his anchor point
|
|
387
407
|
* @param {Vector2d} v - scaling vector
|
|
388
408
|
* @returns {Renderable} Reference to this object for method chaining
|
|
389
409
|
*/
|
|
390
410
|
scaleV(v: Vector2d): Renderable;
|
|
411
|
+
/**
|
|
412
|
+
* Translate the renderable by the specified offset.
|
|
413
|
+
* @param {number} x - x offset
|
|
414
|
+
* @param {number} [y=0] - y offset
|
|
415
|
+
* @param {number} [z=0] - z offset
|
|
416
|
+
* @returns {Renderable} Reference to this object for method chaining
|
|
417
|
+
*/
|
|
418
|
+
translate(x: number, y?: number, z?: number): Renderable;
|
|
391
419
|
/**
|
|
392
420
|
* update function (automatically called by melonJS).
|
|
393
421
|
* @param {number} dt - time since the last update in milliseconds.
|
|
@@ -468,7 +496,7 @@ export default class Renderable extends Rect {
|
|
|
468
496
|
}
|
|
469
497
|
import { Rect } from "./../geometries/rectangle.ts";
|
|
470
498
|
import { ObservablePoint } from "../geometries/observablePoint.ts";
|
|
471
|
-
import
|
|
499
|
+
import { Matrix3d } from "../math/matrix3d.ts";
|
|
472
500
|
import Body from "./../physics/body.js";
|
|
473
501
|
import type Container from "./container.js";
|
|
474
502
|
import type Entity from "./entity/entity.js";
|
|
@@ -476,9 +504,7 @@ import type { RoundRect } from "./../geometries/roundrect.ts";
|
|
|
476
504
|
import type { Polygon } from "../geometries/polygon.ts";
|
|
477
505
|
import type { Line } from "./../geometries/line.ts";
|
|
478
506
|
import type { Ellipse } from "./../geometries/ellipse.ts";
|
|
479
|
-
import { Color } from "./../math/color.ts";
|
|
480
507
|
import type Application from "./../application/application.ts";
|
|
481
|
-
import { Bounds } from "./../physics/bounds.ts";
|
|
482
508
|
import type CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
483
509
|
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
484
510
|
//# sourceMappingURL=renderable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;OAUG;IACH,aAHU,eAAe,CAMvB;IAGD
|
|
1
|
+
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;OAUG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,MAlCU,IAAI,CAkCO;IAErB;;;;;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;IAEz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,4BAA4B;6BAG1B,iCAAiC;gCAC9B,sCAAsC;+BACvC,oCAAoC"}
|
|
@@ -47,7 +47,7 @@ export default class Sprite extends Renderable {
|
|
|
47
47
|
* anchorPoint : new me.Vector2d(0.5, 0.5)
|
|
48
48
|
* });
|
|
49
49
|
* // scale the video sprite
|
|
50
|
-
* videoSprite.
|
|
50
|
+
* videoSprite.scale(2);
|
|
51
51
|
* // start playing the video (if video is preloaded with `autoplay` set to false)
|
|
52
52
|
* videoSprite.play();
|
|
53
53
|
*/
|
|
@@ -119,12 +119,6 @@ export default class BitmapText extends Renderable {
|
|
|
119
119
|
* @returns {BitmapText} this object for chaining
|
|
120
120
|
*/
|
|
121
121
|
setText(value?: number | string | string[]): BitmapText;
|
|
122
|
-
/**
|
|
123
|
-
* update the bounding box for this Bitmap Text.
|
|
124
|
-
* @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
|
|
125
|
-
* @returns {Bounds} this Bitmap Text bounding box Rectangle object
|
|
126
|
-
*/
|
|
127
|
-
updateBounds(absolute?: boolean): Bounds;
|
|
128
122
|
/**
|
|
129
123
|
* change the font display size
|
|
130
124
|
* @param {number} scale - ratio
|
|
@@ -140,11 +134,8 @@ export default class BitmapText extends Renderable {
|
|
|
140
134
|
/**
|
|
141
135
|
* draw the bitmap font
|
|
142
136
|
* @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
|
|
143
|
-
* @param {string} [text]
|
|
144
|
-
* @param {number} [x]
|
|
145
|
-
* @param {number} [y]
|
|
146
137
|
*/
|
|
147
|
-
draw(renderer: CanvasRenderer | WebGLRenderer
|
|
138
|
+
draw(renderer: CanvasRenderer | WebGLRenderer): void;
|
|
148
139
|
/**
|
|
149
140
|
* Destroy function
|
|
150
141
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,eA5BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EAsHF;IApGA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;OAGG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAgJlE,4BANU,KAAK,EAad;IAhBD;;;;;OAKG;IACH,wBAHU,KAAK,CAKd;IAnHA,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAqBtB;
|
|
1
|
+
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,eA5BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EAsHF;IApGA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;OAGG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAgJlE,4BANU,KAAK,EAad;IAhBD;;;;;OAKG;IACH,wBAHU,KAAK,CAKd;IAnHA,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAqBtB;IAyED;;;;OAIG;IACH,cAHW,MAAM,GACJ,UAAU,CAYtB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,WAAW,CAIvB;IAED;;;OAGG;IACH,eAFW,cAAc,GAAC,aAAa,QAwFtC;IAED;;;OAGG;IACH,gBAQC;CACD;uBArYsB,kBAAkB;sBAFnB,qBAAqB;wBAInB,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,YAAY,CAAC;AA8E/B;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,cAAc;IAClC,MAAM,EAAE,MAAM,CAAK;IACnB,QAAQ,EAAE,MAAM,CAAK;IACrB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,UAAU,EAAE,MAAM,CAAK;IACvB,SAAS,EAAE,MAAM,CAAK;IACtB,OAAO,EAAE,MAAM,CAAK;IACpB,WAAW,EAAE,MAAM,CAAK;IACxB,cAAc,EAAE,MAAM,CAAK;IAC3B,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAM;gBAE1B,IAAI,EAAE,MAAM;IAIxB,KAAK,CAAC,QAAQ,EAAE,MAAM;CAuGtB;AAED,eAAO,MAAM,kBAAkB,yEAY7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glyph.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/glyph.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACzB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"glyph.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/glyph.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,KAAK;IACzB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAEvD;;OAEG;;IAiBH;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAU9B;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAW3C"}
|
|
@@ -122,27 +122,17 @@ export default class Text extends Renderable {
|
|
|
122
122
|
* @returns {Text} this object for chaining
|
|
123
123
|
*/
|
|
124
124
|
setText(value?: number | string | string[]): Text;
|
|
125
|
-
/**
|
|
126
|
-
* update the bounding box for this Text, accounting for textAlign and textBaseline.
|
|
127
|
-
* @param {boolean} [absolute=true] - update in absolute coordinates
|
|
128
|
-
* @returns {Bounds} this renderable's bounding box
|
|
129
|
-
*/
|
|
130
|
-
updateBounds(absolute?: boolean): Bounds;
|
|
131
125
|
/**
|
|
132
126
|
* measure the given text size in pixels
|
|
133
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer - reference to the active renderer
|
|
134
127
|
* @param {string} [text] - the text to be measured
|
|
135
128
|
* @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
|
|
136
129
|
*/
|
|
137
|
-
measureText(
|
|
130
|
+
measureText(text?: string): TextMetrics;
|
|
138
131
|
/**
|
|
139
132
|
* draw a text at the specified coord
|
|
140
133
|
* @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
|
|
141
|
-
* @param {string} [text]
|
|
142
|
-
* @param {number} [x]
|
|
143
|
-
* @param {number} [y]
|
|
144
134
|
*/
|
|
145
|
-
draw(renderer: CanvasRenderer | WebGLRenderer
|
|
135
|
+
draw(renderer: CanvasRenderer | WebGLRenderer): void;
|
|
146
136
|
/**
|
|
147
137
|
* @ignore
|
|
148
138
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;OAiBG;IACH,eAjBW,MAAM,KACN,MAAM,YAEd;QAAyB,IAAI,EAArB,MAAM;QACkB,IAAI,EAA5B,MAAM,GAAC,MAAM;QACW,SAAS;QACT,WAAW;QACjB,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EA2EF;IApEA;;;;OAIG;IACH,WAHU,KAAK,CAGwB;IAEvC;;;;OAIG;IACH,aAHU,KAAK,CAG0B;IAEzC;;;;OAIG;IACH,WAHU,MAAM,CAGE;IAElB;;;;;OAKG;IACH,WAHU,MAAM,CAGO;IAEvB;;;;;OAKG;IACH,cAHU,MAAM,CAGS;IAEzB;;;;;OAKG;IACH,YAHU,MAAM,CAGK;IAErB;;;;;OAKG;IACH,eAHU,MAAM,CAGO;IAEvB;;;;OAIG;IACH,UAHU,MAAM,CAGE;IAElB;;;OAGG;IACH,cAAe;IAMhB,cAAc;IACd,kDAqEC;IATA,8CAEE;IAGF,iCAAoC;IAMrC;;;OAGG;IACH,QAFa,IAAI,CAWhB;IAJC,UAA+B;IAMjC;;;OAGG;IACH,UAFa,IAAI,CAWhB;IAED;;;;;;;;OAQG;IACH,cAPW,MAAM,SACN,MAAM,GAAC,MAAM,GACX,IAAI,CAiChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,IAAI,CAyDhB;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"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
|
3
|
+
* @import {Vector2d} from "../math/vector2d.ts";
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A Trail renderable that draws a fading, tapering ribbon behind a moving object.
|
|
7
|
+
* Points are sampled from a target or added manually, and rendered as connected
|
|
8
|
+
* quads with interpolated width and color.
|
|
9
|
+
* @category Game Objects
|
|
10
|
+
* @example
|
|
11
|
+
* // simple single-color trail following a sprite
|
|
12
|
+
* const trail = new Trail({ target: player, color: "#44aaff", width: 20 });
|
|
13
|
+
* app.world.addChild(trail);
|
|
14
|
+
* @example
|
|
15
|
+
* // gradient trail following a sprite (fire effect)
|
|
16
|
+
* const trail = new Trail({
|
|
17
|
+
* target: player,
|
|
18
|
+
* width: 30,
|
|
19
|
+
* gradient: ["#ffff00", "#ff4400", "#ff000000"],
|
|
20
|
+
* });
|
|
21
|
+
* app.world.addChild(trail);
|
|
22
|
+
* @example
|
|
23
|
+
* // rainbow trail with custom width curve
|
|
24
|
+
* const trail = new Trail({
|
|
25
|
+
* target: player,
|
|
26
|
+
* width: 40,
|
|
27
|
+
* widthCurve: [1, 1, 0.8, 0.4, 0],
|
|
28
|
+
* gradient: ["#ff0000", "#ff8800", "#ffff00", "#00ff00", "#0088ff", "#8800ff00"],
|
|
29
|
+
* });
|
|
30
|
+
* app.world.addChild(trail);
|
|
31
|
+
* @example
|
|
32
|
+
* // manual mode (e.g. sword slash)
|
|
33
|
+
* const slash = new Trail({ width: 24, lifetime: 200, color: "#ffffff" });
|
|
34
|
+
* app.world.addChild(slash);
|
|
35
|
+
* // call each frame during the attack animation
|
|
36
|
+
* slash.addPoint(swordTip.x, swordTip.y);
|
|
37
|
+
* @see {@link Renderable}
|
|
38
|
+
*/
|
|
39
|
+
export default class Trail extends Renderable {
|
|
40
|
+
/**
|
|
41
|
+
* @param {object} [options] - trail options
|
|
42
|
+
* @param {Renderable|Vector2d} [options.target] - auto-follow target
|
|
43
|
+
* @param {number} [options.length=20] - max number of points
|
|
44
|
+
* @param {number} [options.lifetime=500] - point lifetime in ms
|
|
45
|
+
* @param {number} [options.minDistance=4] - min distance between samples in px
|
|
46
|
+
* @param {number} [options.width=10] - max trail width in px
|
|
47
|
+
* @param {number[]} [options.widthCurve=[1, 0]] - width multiplier curve (0=head, 1=tail)
|
|
48
|
+
* @param {Color|string} [options.color="#ffffff"] - single trail color. Ignored if `gradient` is set.
|
|
49
|
+
* @param {(Color|string|{pos: number, color: Color|string})[]} [options.gradient] - color gradient. Overrides `color`.
|
|
50
|
+
* @param {number} [options.opacity=1.0] - trail opacity (0.0–1.0)
|
|
51
|
+
* @param {string} [options.blendMode="normal"] - blend mode
|
|
52
|
+
*/
|
|
53
|
+
constructor(options?: {
|
|
54
|
+
target?: Vector2d | Renderable | undefined;
|
|
55
|
+
length?: number | undefined;
|
|
56
|
+
lifetime?: number | undefined;
|
|
57
|
+
minDistance?: number | undefined;
|
|
58
|
+
width?: number | undefined;
|
|
59
|
+
widthCurve?: number[] | undefined;
|
|
60
|
+
color?: string | Color | undefined;
|
|
61
|
+
gradient?: (string | Color | {
|
|
62
|
+
pos: number;
|
|
63
|
+
color: Color | string;
|
|
64
|
+
})[] | undefined;
|
|
65
|
+
opacity?: number | undefined;
|
|
66
|
+
blendMode?: string | undefined;
|
|
67
|
+
});
|
|
68
|
+
/** @type {Renderable|Vector2d|null} */
|
|
69
|
+
target: Renderable | Vector2d | null;
|
|
70
|
+
/** @type {number} */
|
|
71
|
+
maxPoints: number;
|
|
72
|
+
/** @type {number} */
|
|
73
|
+
lifetime: number;
|
|
74
|
+
/** @type {number} */
|
|
75
|
+
minDistance: number;
|
|
76
|
+
/** @type {number[]} */
|
|
77
|
+
widthCurve: number[];
|
|
78
|
+
/** @ignore */
|
|
79
|
+
_gradient: Gradient;
|
|
80
|
+
/** @ignore */
|
|
81
|
+
_points: any[];
|
|
82
|
+
/** @ignore */
|
|
83
|
+
_segmentColor: Color;
|
|
84
|
+
/** @ignore */
|
|
85
|
+
_n0: {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
};
|
|
89
|
+
/** @ignore */
|
|
90
|
+
_n1: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* add a point to the trail
|
|
96
|
+
* @param {number} x - x position
|
|
97
|
+
* @param {number} y - y position
|
|
98
|
+
*/
|
|
99
|
+
addPoint(x: number, y: number): void;
|
|
100
|
+
/** @ignore */
|
|
101
|
+
update(dt: any): boolean;
|
|
102
|
+
/** @ignore */
|
|
103
|
+
draw(renderer: any): void;
|
|
104
|
+
/** clear all trail points */
|
|
105
|
+
clear(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Build a Gradient from trail constructor options.
|
|
108
|
+
* @param {object} options - trail constructor options
|
|
109
|
+
* @returns {Gradient}
|
|
110
|
+
* @ignore
|
|
111
|
+
*/
|
|
112
|
+
_buildGradient(options: object): Gradient;
|
|
113
|
+
/** @ignore */
|
|
114
|
+
destroy(): void;
|
|
115
|
+
}
|
|
116
|
+
import Renderable from "./renderable.js";
|
|
117
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
118
|
+
import { Gradient } from "../video/gradient.js";
|
|
119
|
+
import type { Color } from "../math/color.ts";
|
|
120
|
+
//# sourceMappingURL=trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../../src/renderable/trail.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IACC;;;;;;;;;;;;OAYG;IACH,sBAXG;QAAsC,MAAM;QACnB,MAAM;QACN,QAAQ;QACR,WAAW;QACX,KAAK;QACH,UAAU;QACN,KAAK;QACkC,QAAQ;iBAAlD,MAAM;mBAAS,KAAK,GAAC,MAAM;;QAC9B,OAAO;QACP,SAAS;KACpC,EAwCA;IApCA,uCAAuC;IACvC,QADW,UAAU,GAAC,QAAQ,GAAC,IAAI,CACC;IACpC,qBAAqB;IACrB,WADW,MAAM,CACoB;IACrC,qBAAqB;IACrB,UADW,MAAM,CACsB;IACvC,qBAAqB;IACrB,aADW,MAAM,CAC0B;IAG3C,uBAAuB;IACvB,YADW,MAAM,EAAE,CAIT;IAEV,cAAc;IACd,oBAA6C;IAC7C,cAAc;IACd,eAAiB;IACjB,cAAc;IACd,qBAAoC;IACpC,cAAc;IACd;;;MAAyB;IACzB,cAAc;IACd;;;MAAyB;IAa1B;;;;OAIG;IACH,YAHW,MAAM,KACN,MAAM,QAehB;IAED,cAAc;IACd,yBAsBC;IAED,cAAc;IACd,0BAiDC;IAED,6BAA6B;IAC7B,cAEC;IAED;;;;;OAKG;IACH,wBAJW,MAAM,GACJ,QAAQ,CAgCpB;IAED,cAAc;IACd,gBAMC;CACD;uBAnPsB,iBAAiB;8BAIb,qBAAqB;yBALvB,sBAAsB;2BAIvB,kBAAkB"}
|
|
@@ -16,10 +16,6 @@ interface UITextButtonSettings {
|
|
|
16
16
|
textBaseline?: string;
|
|
17
17
|
borderWidth?: number;
|
|
18
18
|
borderHeight?: number;
|
|
19
|
-
/** @deprecated use hoverOffColor */
|
|
20
|
-
backgroundColor?: string;
|
|
21
|
-
/** @deprecated use hoverOnColor */
|
|
22
|
-
hoverColor?: string;
|
|
23
19
|
[key: string]: any;
|
|
24
20
|
}
|
|
25
21
|
/**
|
|
@@ -85,8 +81,8 @@ export default class UITextButton extends UIBaseElement {
|
|
|
85
81
|
* // if you omit the next two, size is calculated by the size of the text
|
|
86
82
|
* borderWidth: 200,
|
|
87
83
|
* borderHeight: 20,
|
|
88
|
-
*
|
|
89
|
-
*
|
|
84
|
+
* hoverOffColor: '#00aa0080',
|
|
85
|
+
* hoverOnColor: '#00ff00ff'
|
|
90
86
|
* });
|
|
91
87
|
* }
|
|
92
88
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uitextbutton.d.ts","sourceRoot":"","sources":["../../../src/renderable/ui/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