melonjs 19.7.1 → 19.9.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 +21 -6
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +34 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +1 -1
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/backend.d.ts +21 -2
- package/build/audio/backend.d.ts.map +1 -1
- package/build/audio/playback.d.ts +8 -28
- package/build/audio/playback.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +49 -0
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/geometries/path2d.d.ts +188 -75
- package/build/geometries/path2d.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/index.d.ts +11 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +19170 -13625
- package/build/index.js.map +4 -4
- package/build/level/gltf/GLTFModel.d.ts +173 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -0
- package/build/level/gltf/GLTFScene.d.ts +84 -0
- package/build/level/gltf/GLTFScene.d.ts.map +1 -0
- package/build/level/gltf/gltf_sampler.d.ts +49 -0
- package/build/level/gltf/gltf_sampler.d.ts.map +1 -0
- package/build/level/level.d.ts +7 -3
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +5 -0
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/{renderable → lighting}/light2d.d.ts +79 -78
- package/build/lighting/light2d.d.ts.map +1 -0
- package/build/lighting/light3d.d.ts +86 -0
- package/build/lighting/light3d.d.ts.map +1 -0
- package/build/loader/cache.d.ts +2 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +156 -8
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/fetchdata.d.ts +14 -0
- package/build/loader/parsers/fetchdata.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts +71 -0
- package/build/loader/parsers/gltf.d.ts.map +1 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/shader.d.ts +47 -0
- package/build/loader/parsers/shader.d.ts.map +1 -0
- package/build/loader/parsers/video.d.ts.map +1 -1
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +2 -2
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/noise.d.ts +141 -0
- package/build/math/noise.d.ts.map +1 -0
- 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/vector2d.d.ts +1 -1
- package/build/math/vector2d.d.ts.map +1 -1
- package/build/math/vector3d.d.ts +1 -1
- package/build/math/vector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts +25 -0
- package/build/math/vertex.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +4 -3
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/aabb3d.d.ts +23 -2
- package/build/physics/broadphase/aabb3d.d.ts.map +1 -1
- package/build/renderable/anchorPoint.d.ts +80 -0
- package/build/renderable/anchorPoint.d.ts.map +1 -0
- package/build/renderable/animation.d.ts +41 -0
- package/build/renderable/animation.d.ts.map +1 -0
- package/build/renderable/collectable.d.ts +7 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/container.d.ts +0 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +5 -2
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +154 -0
- package/build/renderable/frameAnimation.d.ts.map +1 -0
- package/build/renderable/imagelayer.d.ts +5 -2
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +175 -6
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts +5 -7
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +28 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +84 -34
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +350 -0
- package/build/renderable/sprite3d.d.ts.map +1 -0
- package/build/renderable/text/bitmaptext.d.ts +24 -12
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +24 -1
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +50 -12
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/state/stage.d.ts +20 -1
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/event.d.ts +18 -2
- package/build/system/event.d.ts.map +1 -1
- package/build/video/buffer/vertex.d.ts +7 -0
- package/build/video/buffer/vertex.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +4 -0
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +62 -1
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +17 -6
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +3 -2
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +55 -6
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/frametexture.d.ts +73 -0
- package/build/video/texture/frametexture.d.ts.map +1 -0
- package/build/video/texture/noise_texture2d.d.ts +176 -0
- package/build/video/texture/noise_texture2d.d.ts.map +1 -0
- package/build/video/texture/parser/aseprite.d.ts.map +1 -1
- package/build/video/texture/texture2d.d.ts +83 -0
- package/build/video/texture/texture2d.d.ts.map +1 -0
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +18 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +30 -4
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +39 -3
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +52 -11
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +13 -0
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/effects/hologram.d.ts +0 -5
- package/build/video/webgl/effects/hologram.d.ts.map +1 -1
- package/build/video/webgl/effects/shine.d.ts +1 -6
- package/build/video/webgl/effects/shine.d.ts.map +1 -1
- package/build/video/webgl/glshader.d.ts +29 -0
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +32 -0
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -0
- package/build/video/webgl/shadereffect.d.ts +183 -0
- package/build/video/webgl/shadereffect.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +59 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +5 -5
- package/build/renderable/light2d.d.ts.map +0 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import { TextureAtlas } from "../video/texture/atlas.js";
|
|
4
|
+
* @import { Vector2d } from "../math/vector2d.js";
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The shared **frame-animation engine** behind {@link Sprite} (2D) and
|
|
8
|
+
* {@link Sprite3d} (3D billboards). It *owns* the animation state — definitions,
|
|
9
|
+
* the current frame, timing, looping and chaining — everything independent of
|
|
10
|
+
* how a frame is ultimately *drawn*, and drives its host renderable through a
|
|
11
|
+
* small contract:
|
|
12
|
+
*
|
|
13
|
+
* - it reads the host's resolved texture (`host.source`, `host.textureAtlas`,
|
|
14
|
+
* `host.atlasIndices`) to turn a frame index/name into a region;
|
|
15
|
+
* - it calls the `applyFrame(region)` callback passed to the constructor whenever
|
|
16
|
+
* the frame changes — the host applies it to its own geometry ({@link Sprite}
|
|
17
|
+
* swaps its source sub-texture, size and anchor; {@link Sprite3d} maps the
|
|
18
|
+
* region onto its quad's UVs + vertices) **and marks itself dirty there**;
|
|
19
|
+
* - it fires `host.onended()` at each cycle end.
|
|
20
|
+
*
|
|
21
|
+
* The engine owns no dirty flag: a frame change flows through `applyFrame`, where
|
|
22
|
+
* the host sets its own `isDirty`. Callers read dirtiness from the host (the
|
|
23
|
+
* host's `update()` returns `super.update()` → `isDirty`).
|
|
24
|
+
*
|
|
25
|
+
* Hosts expose the public-facing state (`anim`, `current`, `animationspeed`,
|
|
26
|
+
* `animationpause`, …) as thin accessors onto this engine, so 2D and 3D frame
|
|
27
|
+
* animation share one implementation with no behavioral fork.
|
|
28
|
+
* @category Animation
|
|
29
|
+
*/
|
|
30
|
+
export default class FrameAnimation {
|
|
31
|
+
/**
|
|
32
|
+
* @param {object} host - the renderable this engine drives. Read for the
|
|
33
|
+
* texture it animates (`source` / `textureAtlas` / `atlasIndices`) and the
|
|
34
|
+
* mutable cycle-end callback (`onended`). These are read lazily (the texture is
|
|
35
|
+
* usually resolved after the engine is constructed), which is why they live on
|
|
36
|
+
* the host rather than being passed in. The engine does not touch `isDirty` —
|
|
37
|
+
* the host marks itself dirty inside `applyFrame`.
|
|
38
|
+
* @param {(region: object) => void} applyFrame - called whenever the frame
|
|
39
|
+
* changes, with the selected texture region; the host applies it to its own
|
|
40
|
+
* geometry (a {@link Sprite} swaps its sub-texture / size / anchor, a
|
|
41
|
+
* {@link Sprite3d} remaps its quad's UVs + vertices).
|
|
42
|
+
*/
|
|
43
|
+
constructor(host: object, applyFrame: (region: object) => void);
|
|
44
|
+
/**
|
|
45
|
+
* the host renderable this engine draws through.
|
|
46
|
+
* @type {object}
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
49
|
+
host: object;
|
|
50
|
+
/**
|
|
51
|
+
* geometry hook invoked on every frame change (see constructor).
|
|
52
|
+
* @type {(region: object) => void}
|
|
53
|
+
* @ignore
|
|
54
|
+
*/
|
|
55
|
+
_applyFrame: (region: object) => void;
|
|
56
|
+
/** defined animations, keyed by id @type {object} */
|
|
57
|
+
anim: object;
|
|
58
|
+
/** animation to chain to / completion callback on cycle end @ignore */
|
|
59
|
+
resetAnim: (() => unknown) | (() => void) | (() => boolean) | (() => void) | undefined;
|
|
60
|
+
/** current frame info @type {object} */
|
|
61
|
+
current: object;
|
|
62
|
+
/** elapsed time within the current frame, in ms @type {number} */
|
|
63
|
+
dt: number;
|
|
64
|
+
/** default frame cycling speed (ms between frames) @type {number} */
|
|
65
|
+
animationspeed: number;
|
|
66
|
+
/** pause flag — freezes the current frame @type {boolean} */
|
|
67
|
+
animationpause: boolean;
|
|
68
|
+
/** per-play speed multiplier (1 = authored speed) @ignore */
|
|
69
|
+
_animSpeed: number;
|
|
70
|
+
/** set once a `loop:false` animation has finished its single cycle @ignore */
|
|
71
|
+
_animDone: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* add an animation definition (see {@link Sprite#addAnimation}).
|
|
74
|
+
* @param {string} name - animation id
|
|
75
|
+
* @param {number[]|string[]|object[]} index - frame indices / names / objects
|
|
76
|
+
* @param {number} [animationspeed] - cycling speed in ms
|
|
77
|
+
* @returns {number} number of frames added (0 if no texture atlas)
|
|
78
|
+
*/
|
|
79
|
+
addAnimation(name: string, index: number[] | string[] | object[], animationspeed?: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* select the active animation (see {@link Sprite#setCurrentAnimation}).
|
|
82
|
+
* @param {string} name - animation id
|
|
83
|
+
* @param {string|Function|object} [resetAnim] - loop / chain / completion behavior
|
|
84
|
+
* @param {boolean} [preserve_dt=false] - keep the elapsed-frame timer
|
|
85
|
+
* @returns {object} the host (for method chaining)
|
|
86
|
+
*/
|
|
87
|
+
setCurrentAnimation(name: string, resetAnim?: string | Function | object, preserve_dt?: boolean): object;
|
|
88
|
+
/**
|
|
89
|
+
* reverse the given (or current) animation in place (see {@link Sprite#reverseAnimation}).
|
|
90
|
+
* The host marks itself dirty (this path doesn't re-apply a frame, so it's the
|
|
91
|
+
* one place a host's `reverseAnimation` wrapper sets `isDirty`).
|
|
92
|
+
* @param {string} [name] - animation id
|
|
93
|
+
*/
|
|
94
|
+
reverseAnimation(name?: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* @param {string} name - animation id
|
|
97
|
+
* @returns {boolean} true if `name` is the current animation
|
|
98
|
+
*/
|
|
99
|
+
isCurrentAnimation(name: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* @returns {string[]} the names of every defined animation
|
|
102
|
+
*/
|
|
103
|
+
getAnimationNames(): string[];
|
|
104
|
+
/**
|
|
105
|
+
* apply a texture region as the current frame: store its geometry into
|
|
106
|
+
* `current` and hand it to the host to draw (see {@link Sprite#setRegion}).
|
|
107
|
+
* @param {object} region - the texture region object
|
|
108
|
+
* @returns {object} the host (for method chaining)
|
|
109
|
+
*/
|
|
110
|
+
setRegion(region: object): object;
|
|
111
|
+
/**
|
|
112
|
+
* force the current animation frame index (see {@link Sprite#setAnimationFrame}).
|
|
113
|
+
* @param {number} [index=0] - animation frame index
|
|
114
|
+
* @returns {object} the host (for method chaining)
|
|
115
|
+
*/
|
|
116
|
+
setAnimationFrame(index?: number): object;
|
|
117
|
+
/**
|
|
118
|
+
* @returns {number} the current animation frame index
|
|
119
|
+
*/
|
|
120
|
+
getCurrentAnimationFrame(): number;
|
|
121
|
+
/**
|
|
122
|
+
* the frame object for the given index within the current animation.
|
|
123
|
+
* @param {number} id - the frame id
|
|
124
|
+
* @returns {object} the frame data
|
|
125
|
+
*/
|
|
126
|
+
getAnimationFrameObjectByIndex(id: number): object;
|
|
127
|
+
/**
|
|
128
|
+
* clear the frame timer and the play-once "done" hold, without changing the
|
|
129
|
+
* current frame (the timer half of a stop, used by the video path which has
|
|
130
|
+
* no frame to rewind to).
|
|
131
|
+
*/
|
|
132
|
+
resetTimer(): void;
|
|
133
|
+
/**
|
|
134
|
+
* reset the current animation to its first frame (the frame-animation half of
|
|
135
|
+
* {@link Sprite#stop} — the host still handles any video / pause concerns).
|
|
136
|
+
*/
|
|
137
|
+
rewind(): void;
|
|
138
|
+
/**
|
|
139
|
+
* advance the frame animation by `dt` milliseconds, stepping frames, looping
|
|
140
|
+
* and chaining as configured (see {@link Sprite#update}). On a frame change the
|
|
141
|
+
* host marks itself dirty via `_applyFrame` (the engine owns no dirty flag);
|
|
142
|
+
* this returns whether a frame actually changed this tick — a finer-grained
|
|
143
|
+
* signal than the host's `isDirty` (which means "needs redraw for any reason").
|
|
144
|
+
* @param {number} dt - elapsed time since the last update, in milliseconds
|
|
145
|
+
* @returns {boolean} true if a frame changed this tick
|
|
146
|
+
*/
|
|
147
|
+
update(dt: number): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* release engine-held resources — returns the pooled `current.offset`
|
|
150
|
+
* Vector2d to the pool. Call from the host's `destroy()`.
|
|
151
|
+
*/
|
|
152
|
+
destroy(): void;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=frameAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameAnimation.d.ts","sourceRoot":"","sources":["../../src/renderable/frameAnimation.js"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IACC;;;;;;;;;;;OAWG;IACH,kBAXW,MAAM,cAMN,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,EA2DlC;IArDA;;;;OAIG;IACH,MAHU,MAAM,CAGA;IAEhB;;;;OAIG;IACH,aAHU,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAGL;IAE7B,qDAAqD;IACrD,MAD2C,MAAM,CACnC;IAEd,uEAAuE;IACvE,uFAA0B;IAE1B,wCAAwC;IACxC,SAD8B,MAAM,CAiBnC;IAED,kEAAkE;IAClE,IADwD,MAAM,CACnD;IAEX,qEAAqE;IACrE,gBAD2D,MAAM,CACxC;IAEzB,6DAA6D;IAC7D,gBADkD,OAAO,CAC9B;IAE3B,6DAA6D;IAC7D,mBAAmB;IAEnB,8EAA8E;IAC9E,mBAAsB;IAGvB;;;;;;OAMG;IACH,mBALW,MAAM,SACN,MAAM,EAAE,GAAC,MAAM,EAAE,GAAC,MAAM,EAAE,mBAC1B,MAAM,GACJ,MAAM,CAoElB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,cACN,MAAM,cAAU,MAAM,gBACtB,OAAO,GACL,MAAM,CAuDlB;IAED;;;;;OAKG;IACH,wBAFW,MAAM,QAQhB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;OAEG;IACH,qBAFa,MAAM,EAAE,CAIpB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,MAAM,CAiBlB;IAED;;;;OAIG;IACH,0BAHW,MAAM,GACJ,MAAM,CAOlB;IAED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAGC;IAED;;;OAGG;IACH,eAKC;IAED;;;;;;;;OAQG;IACH,WAHW,MAAM,GACJ,OAAO,CAyCnB;IAED;;;OAGG;IACH,gBAOC;CACD"}
|
|
@@ -16,7 +16,7 @@ export default class ImageLayer extends Sprite {
|
|
|
16
16
|
* @param {number} [settings.z=0] - z-index position
|
|
17
17
|
* @param {number|Vector2d} [settings.ratio=1.0] - Scrolling ratio to be applied. See {@link ImageLayer#ratio}
|
|
18
18
|
* @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [settings.repeat="repeat"] - define if and how an Image Layer should be repeated. See {@link ImageLayer#repeat}
|
|
19
|
-
* @param {number|Vector2d} [settings.anchorPoint=<0.0,0.0>] - Define how the image is anchored to the viewport bound. By default, its upper-left corner is anchored to the viewport bounds upper left corner.
|
|
19
|
+
* @param {number|string|Vector2d|{x:number,y:number}} [settings.anchorPoint=<0.0,0.0>] - Define how the image is anchored to the viewport bound. By default, its upper-left corner is anchored to the viewport bounds upper left corner. Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"` (anchored relative to the viewport, e.g. `"bottom"` = bottom-center of the viewport); a bare number anchors both axes.
|
|
20
20
|
* @example
|
|
21
21
|
* // create a repetitive background pattern on the X axis using the citycloud image asset
|
|
22
22
|
* app.world.addChild(new me.ImageLayer(0, 0, {
|
|
@@ -30,7 +30,10 @@ export default class ImageLayer extends Sprite {
|
|
|
30
30
|
z?: number | undefined;
|
|
31
31
|
ratio?: number | Vector2d | undefined;
|
|
32
32
|
repeat?: "repeat" | "no-repeat" | "repeat-x" | "repeat-y" | undefined;
|
|
33
|
-
anchorPoint?: number | Vector2d |
|
|
33
|
+
anchorPoint?: string | number | Vector2d | {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
} | undefined;
|
|
34
37
|
});
|
|
35
38
|
/**
|
|
36
39
|
* Define the image scrolling ratio<br>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imagelayer.d.ts","sourceRoot":"","sources":["../../src/renderable/imagelayer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"imagelayer.d.ts","sourceRoot":"","sources":["../../src/renderable/imagelayer.js"],"names":[],"mappings":"AAaA;;;GAGG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;OAgBG;IACH,eAhBW,MAAM,KACN,MAAM,YAEd;QAA4E,KAAK,EAAzE,gBAAgB,GAAC,iBAAiB,GAAC,eAAe,GAAC,MAAM;QACvC,IAAI;QACJ,CAAC;QACQ,KAAK;QACsB,MAAM;QACN,WAAW;eAAvC,MAAM;eAAG,MAAM;;KACjD,EAgEF;IAlCA;;;;;;;;;OASG;IACH,OAHU,QAAQ,CAGqB;IAyCxC,kBAPU,MAAM,EA2Bf;IAnCD;;;;;;;;;;OAUG;IACH,cAHU,MAAM,CAKf;IAGA,4BAAoB;IAGlB,6BAAoB;IACpB,6BAAoB;IAkBvB,wBAsBC;IAED;;;;OAIG;IACH,UAHW,MAAM,KACN,MAAM,QAOhB;IAED;;;OAGG;IACH,sBAKC;IAJA,cAGC;IAGF;;;OAGG;IACH,oBA+CC;IAED;;;;;;;;;;;;;;;OAeG;IACH,6BAmBC;IAED;;;;;OAKG;IACH,yBAHW,cAAc,GAAC,aAAa,aAC5B,QAAQ,QAyElB;IAGD,0BAMC;CAWD;mBAxWkB,aAAa;8BAIL,qBAAqB"}
|
|
@@ -5,6 +5,20 @@
|
|
|
5
5
|
* Includes a built-in perspective projection and supports 3D transforms
|
|
6
6
|
* through the standard Renderable API (`rotate`, `scale`, `translate`).
|
|
7
7
|
* Works on both WebGL (hardware depth testing) and Canvas (painter's algorithm) renderers.
|
|
8
|
+
*
|
|
9
|
+
* **Pivot — transforms are applied about the mesh's local origin `(0, 0, 0)`,
|
|
10
|
+
* NOT a normalized anchor point.** Unlike a {@link Sprite} (whose
|
|
11
|
+
* {@link Renderable#anchorPoint} recenters a `width`×`height` box), a mesh has
|
|
12
|
+
* real vertex coordinates, so rotation and scale pivot around the model origin
|
|
13
|
+
* the geometry is authored against — the standard convention for 3D meshes.
|
|
14
|
+
* Place the origin where you want the pivot at authoring time (or nest the
|
|
15
|
+
* mesh under a transformed parent to pivot elsewhere). Consequently, on the
|
|
16
|
+
* `Camera3d` world-space path the mesh opts out of the anchor offset entirely
|
|
17
|
+
* (see {@link Renderable#applyAnchorTransform}); the legacy 2D path still
|
|
18
|
+
* honors `anchorPoint` for backward compatibility. Subclasses that bake the
|
|
19
|
+
* anchor into their vertex data instead (e.g. {@link Sprite3d}, via the
|
|
20
|
+
* internal `_anchorBaked` flag) opt out on **both** paths — for those, the
|
|
21
|
+
* vertex bake is the single anchoring mechanism.
|
|
8
22
|
* @category Game Objects
|
|
9
23
|
*/
|
|
10
24
|
export default class Mesh extends Renderable {
|
|
@@ -18,9 +32,16 @@ export default class Mesh extends Renderable {
|
|
|
18
32
|
* @param {Uint16Array|number[]} [settings.indices] - triangle vertex indices (alternative to settings.model)
|
|
19
33
|
* @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
34
|
* @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
|
|
22
|
-
* @param {number} settings.height - display height in pixels (
|
|
35
|
+
* @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.
|
|
36
|
+
* @param {number} [settings.height] - display height in pixels (normalized models only; ignored when `normalize: false`)
|
|
23
37
|
* @param {boolean} [settings.cullBackFaces=true] - enable backface culling
|
|
38
|
+
* @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.
|
|
39
|
+
* @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}.
|
|
40
|
+
* @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}.
|
|
41
|
+
* @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.
|
|
42
|
+
* @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. WebGL only (ignored by the Canvas renderer).
|
|
43
|
+
* @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"`. WebGL mesh path only.
|
|
44
|
+
* @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`). WebGL mesh path only.
|
|
24
45
|
* @example
|
|
25
46
|
* // create from OBJ + MTL (texture auto-resolved from material)
|
|
26
47
|
* let mesh = new me.Mesh(0, 0, {
|
|
@@ -38,6 +59,28 @@ export default class Mesh extends Renderable {
|
|
|
38
59
|
* height: 200,
|
|
39
60
|
* });
|
|
40
61
|
*
|
|
62
|
+
* // create from raw geometry that already carries its own world scale
|
|
63
|
+
* // (e.g. a glTF scene node) — keep real coordinates, no mirror
|
|
64
|
+
* let node = new me.Mesh(0, 0, {
|
|
65
|
+
* vertices: positions, // Float32Array of x,y,z triplets
|
|
66
|
+
* uvs: texcoords, // Float32Array of u,v pairs
|
|
67
|
+
* indices: tris, // Uint16Array of triangle indices
|
|
68
|
+
* texture: baseColorImage,
|
|
69
|
+
* width: 32, // pixels per unit
|
|
70
|
+
* normalize: false,
|
|
71
|
+
* rightHanded: true,
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* // material settings (WebGL) — usually set for you by the glTF/OBJ loader,
|
|
75
|
+
* // but available directly on a hand-built mesh too
|
|
76
|
+
* let sign = new me.Mesh(0, 0, {
|
|
77
|
+
* vertices, uvs, indices, texture: "neon-sign",
|
|
78
|
+
* width: 64, normalize: false,
|
|
79
|
+
* textureFilter: "nearest", // crisp pixel-art upscaling
|
|
80
|
+
* alphaCutoff: 0.5, // discard texels below 0.5 alpha (cutout)
|
|
81
|
+
* emissive: [0.9, 0.2, 0.6], // glow, independent of scene lights
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
41
84
|
* // 3D rotation using the standard rotate() API
|
|
42
85
|
* mesh.rotate(Math.PI / 4, new me.Vector3d(0, 1, 0)); // rotate around Y axis
|
|
43
86
|
*
|
|
@@ -52,8 +95,15 @@ export default class Mesh extends Renderable {
|
|
|
52
95
|
texture?: string | HTMLImageElement | TextureAtlas | undefined;
|
|
53
96
|
material?: string | undefined;
|
|
54
97
|
width: number;
|
|
55
|
-
height
|
|
98
|
+
height?: number | undefined;
|
|
56
99
|
cullBackFaces?: boolean | undefined;
|
|
100
|
+
normalize?: boolean | undefined;
|
|
101
|
+
scale?: number | undefined;
|
|
102
|
+
rightHanded?: boolean | undefined;
|
|
103
|
+
textureRepeat?: string | undefined;
|
|
104
|
+
textureFilter?: string | undefined;
|
|
105
|
+
alphaCutoff?: number | undefined;
|
|
106
|
+
emissive?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
57
107
|
});
|
|
58
108
|
/**
|
|
59
109
|
* the original (untransformed) vertex positions as x,y,z triplets
|
|
@@ -76,12 +126,75 @@ export default class Mesh extends Renderable {
|
|
|
76
126
|
* @type {Float32Array}
|
|
77
127
|
*/
|
|
78
128
|
vertices: Float32Array;
|
|
129
|
+
/**
|
|
130
|
+
* the source per-vertex normals (x,y,z triplets), or `undefined` if the
|
|
131
|
+
* mesh was built without them. Supplied by the glTF loader; used for
|
|
132
|
+
* lit shading under a `Camera3d` (see {@link Light3d}).
|
|
133
|
+
* @type {Float32Array|undefined}
|
|
134
|
+
*/
|
|
135
|
+
originalNormals: Float32Array | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Whether this mesh is lit by the active stage's {@link Light3d} lights.
|
|
138
|
+
* When `true` it renders through the lit mesh batcher (diffuse shading
|
|
139
|
+
* from the scene's lights, using {@link Mesh#originalNormals}); when
|
|
140
|
+
* `false` (the default) it uses the lean unlit path and pays no lighting
|
|
141
|
+
* cost. The glTF loader sets this on scene meshes when the scene has
|
|
142
|
+
* lights. Only meaningful under a `Camera3d` + WebGL.
|
|
143
|
+
* @type {boolean}
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
lit: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Alpha cutout threshold. A fragment whose final alpha is below this
|
|
149
|
+
* value is discarded — a hard-edged cutout (foliage, fences, chain-link,
|
|
150
|
+
* decals) that needs no blending or back-to-front sorting. `0` (the
|
|
151
|
+
* default) disables the cutout and the mesh renders fully opaque. Set by
|
|
152
|
+
* the glTF loader from a material's `alphaMode: "MASK"` / `alphaCutoff`.
|
|
153
|
+
* WebGL mesh path only (the Canvas renderer ignores it).
|
|
154
|
+
* @type {number}
|
|
155
|
+
* @default 0
|
|
156
|
+
*/
|
|
157
|
+
alphaCutoff: number;
|
|
158
|
+
/**
|
|
159
|
+
* Emissive (self-illumination) color as an `[r, g, b]` `Float32Array`
|
|
160
|
+
* (0..1, may exceed 1 for HDR glow), added on top of the lit/unlit color
|
|
161
|
+
* so the surface glows independently of the scene lights (neon, lava,
|
|
162
|
+
* screens, glowing eyes). `undefined` (the default) means no emission and
|
|
163
|
+
* keeps the mesh on the lean path. Set by the glTF loader from a material's
|
|
164
|
+
* `emissiveFactor` (× `KHR_materials_emissive_strength`) and by the OBJ
|
|
165
|
+
* loader from an MTL's `Ke`. WebGL mesh path only.
|
|
166
|
+
* @type {Float32Array|undefined}
|
|
167
|
+
*/
|
|
168
|
+
emissive: Float32Array | undefined;
|
|
79
169
|
/**
|
|
80
170
|
* whether to cull back-facing triangles
|
|
81
171
|
* @type {boolean}
|
|
82
172
|
* @default true
|
|
83
173
|
*/
|
|
84
174
|
cullBackFaces: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Treat the source geometry as right-handed (Y-up, e.g. glTF) under
|
|
177
|
+
* the Camera3d world path. The default (`false`) Y-up→Y-down bridge
|
|
178
|
+
* negates Y only — a reflection, which mirrors the scene left/right.
|
|
179
|
+
* When `true`, the bridge negates Y **and** Z (a 180° rotation about
|
|
180
|
+
* X, determinant +1) so chirality is preserved and the result matches
|
|
181
|
+
* the authoring tool (no mirror); triangle winding is left untouched
|
|
182
|
+
* since a rotation doesn't invert it.
|
|
183
|
+
* @type {boolean}
|
|
184
|
+
* @default false
|
|
185
|
+
*/
|
|
186
|
+
rightHanded: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Uniform world-space scale (pixels per source unit) applied along the
|
|
189
|
+
* Camera3d world path. Defaults to `width`. Scene loaders (e.g. glTF)
|
|
190
|
+
* set this independently of `width` / `height` so those can describe
|
|
191
|
+
* the renderable's world-space bounds (used for frustum culling) while
|
|
192
|
+
* the geometry is still scaled by this factor — `width` alone can't
|
|
193
|
+
* serve both roles for a non-normalized scene mesh.
|
|
194
|
+
* @type {number}
|
|
195
|
+
* @default settings.width
|
|
196
|
+
*/
|
|
197
|
+
meshScale: number;
|
|
85
198
|
/**
|
|
86
199
|
* Per-material submesh groups, populated when the OBJ
|
|
87
200
|
* contains multiple `usemtl` directives AND a matching MTL
|
|
@@ -128,6 +241,25 @@ export default class Mesh extends Renderable {
|
|
|
128
241
|
*/
|
|
129
242
|
vertexColors: Uint32Array;
|
|
130
243
|
texture: any;
|
|
244
|
+
/**
|
|
245
|
+
* Per-mesh texture wrap mode (`"repeat"` / `"repeat-x"` / `"repeat-y"`
|
|
246
|
+
* / `"no-repeat"`), or `undefined` to sample with the texture's own
|
|
247
|
+
* wrap. Some assets author UVs outside the `[0, 1]` range and rely on
|
|
248
|
+
* the sampler repeating the texture (this is the glTF default sampler
|
|
249
|
+
* behavior); the mesh would otherwise clamp to the edge texels and
|
|
250
|
+
* look flat / untextured.
|
|
251
|
+
*
|
|
252
|
+
* Kept on the mesh and threaded to the batcher at draw time — sampler
|
|
253
|
+
* state per use, like a GL sampler object — so it never mutates the
|
|
254
|
+
* per-image `TextureAtlas` shared with every other consumer of the
|
|
255
|
+
* same image (#1503). Two meshes (or a mesh and a sprite) can point
|
|
256
|
+
* at one image with different wrap modes; the texture cache keys GL
|
|
257
|
+
* units by `(source, repeat)` so each wrap gets its own GL texture.
|
|
258
|
+
* Applied only to a real texture — never the shared white-pixel
|
|
259
|
+
* fallback, which is global and must stay `"no-repeat"`.
|
|
260
|
+
* @type {string|undefined}
|
|
261
|
+
*/
|
|
262
|
+
textureRepeat: string | undefined;
|
|
131
263
|
/**
|
|
132
264
|
* Projection matrix applied automatically before the model transform in draw().
|
|
133
265
|
* Defaults to a perspective projection (45° FOV, camera at z=-2.5) suitable for
|
|
@@ -137,6 +269,8 @@ export default class Mesh extends Renderable {
|
|
|
137
269
|
*/
|
|
138
270
|
projectionMatrix: Matrix3d;
|
|
139
271
|
/** @ignore */
|
|
272
|
+
_anchorBaked: boolean;
|
|
273
|
+
/** @ignore */
|
|
140
274
|
_hullPoints: Vector2d[];
|
|
141
275
|
/** @ignore */
|
|
142
276
|
_hullPolygon: Polygon | null;
|
|
@@ -157,8 +291,9 @@ export default class Mesh extends Renderable {
|
|
|
157
291
|
* view + projection matrices, the same way it does for Sprites.
|
|
158
292
|
*
|
|
159
293
|
* Per-vertex math: `currentTransform × originalVertex`, then a uniform
|
|
160
|
-
* scale by `this.width`,
|
|
161
|
-
*
|
|
294
|
+
* scale by `this.width`, the Y-up→Y-down bridge (negate Y, and also Z when
|
|
295
|
+
* {@link Mesh#rightHanded} is set so the bridge is a rotation rather than a
|
|
296
|
+
* mirror), and a translate to `(offsetX, offsetY, offsetZ)`.
|
|
162
297
|
*
|
|
163
298
|
* @param {number} offsetX - world X to place the mesh center at
|
|
164
299
|
* @param {number} offsetY - world Y to place the mesh center at
|
|
@@ -166,6 +301,20 @@ export default class Mesh extends Renderable {
|
|
|
166
301
|
* @ignore
|
|
167
302
|
*/
|
|
168
303
|
_projectVerticesWorld(offsetX: number, offsetY: number, offsetZ: number): void;
|
|
304
|
+
/**
|
|
305
|
+
* Project {@link Mesh#originalNormals} into world space for lit shading,
|
|
306
|
+
* storing the result in {@link Mesh#normals}. Applies the rotation/scale of
|
|
307
|
+
* {@link Renderable#currentTransform} (no translation), the same Y-down /
|
|
308
|
+
* `rightHanded` Y/Z bridge as {@link Mesh#_projectVerticesWorld}, then
|
|
309
|
+
* renormalizes. No-op when the mesh has no source normals.
|
|
310
|
+
*
|
|
311
|
+
* Note: uses the transform's rotation/scale columns directly rather than
|
|
312
|
+
* the inverse-transpose, so normals are exact under rotation + uniform
|
|
313
|
+
* scale (the common case); a strongly non-uniform scale would skew them
|
|
314
|
+
* slightly — acceptable for the diffuse lighting path.
|
|
315
|
+
* @ignore
|
|
316
|
+
*/
|
|
317
|
+
_projectNormalsWorld(): void;
|
|
169
318
|
/**
|
|
170
319
|
* Build the winding-reversed indices buffer used by the Camera3d
|
|
171
320
|
* world-space path. Called once, lazily, the first time the mesh
|
|
@@ -186,9 +335,28 @@ export default class Mesh extends Renderable {
|
|
|
186
335
|
* @ignore
|
|
187
336
|
*/
|
|
188
337
|
_setupWorldSpace(): void;
|
|
189
|
-
_indicesReversed:
|
|
338
|
+
_indicesReversed: any;
|
|
190
339
|
_worldSpace: boolean | undefined;
|
|
191
340
|
_useWorldSpace: boolean | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* The mesh's world-space 3D axis-aligned bounding box, as projected by the
|
|
343
|
+
* most recent draw. This is the 3D analog of {@link Renderable#getBounds}
|
|
344
|
+
* (which returns a flat 2D box from `width`/`height` and so cannot describe
|
|
345
|
+
* a mesh's real extent).
|
|
346
|
+
*
|
|
347
|
+
* Under a `Camera3d` the mesh projects its vertices into world space every
|
|
348
|
+
* frame (see {@link Mesh#_projectVerticesWorld}), so the returned box tracks
|
|
349
|
+
* the live transform / animation. Under the 2D path the projected vertices
|
|
350
|
+
* are screen-space, so the box is only meaningful after a Camera3d draw —
|
|
351
|
+
* use {@link Renderable#getBounds} for the 2D case.
|
|
352
|
+
*
|
|
353
|
+
* The same {@link AABB3d} instance is returned each call (recomputed in
|
|
354
|
+
* place), so copy it (`.clone()`) if you need to keep it.
|
|
355
|
+
* @returns {AABB3d} the world-space bounding box (reused instance)
|
|
356
|
+
*/
|
|
357
|
+
getBounds3d(): AABB3d;
|
|
358
|
+
/** @ignore */
|
|
359
|
+
_bounds3d: AABB3d | undefined;
|
|
192
360
|
/**
|
|
193
361
|
* Render the mesh at its current state (transforms, projection, tint) to an offscreen canvas.
|
|
194
362
|
* The returned canvas can be used with `renderer.drawImage()`, as a `Sprite` image source,
|
|
@@ -218,5 +386,6 @@ import { Color } from "../math/color.ts";
|
|
|
218
386
|
import { Matrix3d } from "../math/matrix3d.ts";
|
|
219
387
|
import { Vector2d } from "../math/vector2d.ts";
|
|
220
388
|
import { Polygon } from "../geometries/polygon.ts";
|
|
389
|
+
import { AABB3d } from "../physics/broadphase/aabb3d.ts";
|
|
221
390
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
222
391
|
//# 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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CAEgC;IAuDtD,aAIC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,eAFU,MAAM,GAAC,SAAS,CAKb;IAsBb;;;;;;OAMG;IACH,kBAFU,QAAQ,CAEoB;IAqBtC,cAAc;IACd,sBAAyB;IAOzB,cAAc;IACd,wBAEE;IACF,cAAc;IACd,6BAAwB;IAGzB;;;;;;;OAOG;IACH,2BALW,MAAM,YACN,MAAM,WACN,MAAM,QAiBhB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,+BALW,MAAM,WACN,MAAM,WACN,MAAM,QAqChB;IAED;;;;;;;;;;;;OAYG;IACH,6BA8BC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,yBAqBC;IAHC,sBAA2B;IAE5B,iCAAuB;IAoBvB,oCAAuD;IAGxD;;;;;;;;;;;;;;;OAeG;IACH,eAFa,MAAM,CAWlB;IAPC,cAAc;IACd,8BAA6B;IAkI/B;;;;;;;;;;;;OAYG;IACH,YATa,iBAAiB,CAoH7B;IAED;;;;;;;OAOG;IACH,iBALa,OAAO,CAAC,WAAW,CAAC,CAOhC;CACD;uBA3hCsB,iBAAiB;sBAZlB,kBAAkB;yBACf,qBAAqB;yBACrB,qBAAqB;wBAJtB,0BAA0B;uBAU3B,iCAAiC;6BAE3B,6BAA6B"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* additional import for TypeScript
|
|
3
|
-
* @import {Color} from "./../math/color.ts";
|
|
4
|
-
* @import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* A NineSliceSprite is similar to a Sprite, but it uses 9-slice scaling to stretch its inner area to fit the size of the Renderable,
|
|
8
3
|
* by proportionally scaling a sprite by splitting it in a grid of nine parts (with only parts 1, 3, 7, 9 not being scaled). <br>
|
|
@@ -27,7 +22,7 @@ export default class NineSliceSprite extends Sprite {
|
|
|
27
22
|
* @param {string|Color} [settings.tint] - a tint to be applied to this sprite
|
|
28
23
|
* @param {number} [settings.flipX] - flip the sprite on the horizontal axis
|
|
29
24
|
* @param {number} [settings.flipY] - flip the sprite on the vertical axis
|
|
30
|
-
* @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame).
|
|
25
|
+
* @param {string|Vector2d|{x:number,y:number}} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame). Also accepts the named presets `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`, `"bottom-left"`, `"bottom-right"`.
|
|
31
26
|
* @example
|
|
32
27
|
* this.panelSprite = new me.NineSliceSprite(0, 0, {
|
|
33
28
|
* image : game.texture,
|
|
@@ -49,7 +44,10 @@ export default class NineSliceSprite extends Sprite {
|
|
|
49
44
|
tint?: string | Color | undefined;
|
|
50
45
|
flipX?: number | undefined;
|
|
51
46
|
flipY?: number | undefined;
|
|
52
|
-
anchorPoint?:
|
|
47
|
+
anchorPoint?: string | Vector2d | {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
53
51
|
});
|
|
54
52
|
set width(value: number);
|
|
55
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nineslicesprite.d.ts","sourceRoot":"","sources":["../../src/renderable/nineslicesprite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nineslicesprite.d.ts","sourceRoot":"","sources":["../../src/renderable/nineslicesprite.js"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,eAxBW,MAAM,KACN,MAAM,YAEd;QAAyB,KAAK,EAAtB,MAAM;QACW,MAAM,EAAvB,MAAM;QACY,MAAM;QACN,MAAM;QACyD,KAAK,EAAtF,gBAAgB,GAAC,iBAAiB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACpD,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACwB,WAAW,GAA1D,MAAM,GAAC,QAAQ,GAAC;YAAC,CAAC,EAAC,MAAM,CAAC;YAAA,CAAC,EAAC,MAAM,CAAA;SAAC;KAC3C,EA8BF;IASD,iBALU,MAAM,EAOf;IATD;;;OAGG;IACH,aAFU,MAAM,CAIf;IAYD,kBALU,MAAM,EAOf;IATD;;;OAGG;IACH,cAFU,MAAM,CAIf;IAxBA,kBAA2B;IAC3B,mBAA6B;IAE7B,2BAA6B;IAC7B,2BAA6B;IAkD9B;;OAEG;IACH,0BAyEC;CACD;mBAvMkB,aAAa;kCAKC,6BAA6B;2BADtC,oBAAoB"}
|
|
@@ -25,7 +25,12 @@ export default class Renderable extends Rect {
|
|
|
25
25
|
* a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
|
|
26
26
|
* <br>
|
|
27
27
|
* <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
|
|
28
|
-
* To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
|
|
28
|
+
* To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`, or (since 19.9) a plain string preset such as `bottom`. </i>
|
|
29
|
+
* <br>
|
|
30
|
+
* At construction time, `settings.anchorPoint` also accepts the named presets
|
|
31
|
+
* `"center"`, `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-left"`, `"top-right"`,
|
|
32
|
+
* `"bottom-left"`, `"bottom-right"` on every renderable that consumes it
|
|
33
|
+
* (Sprite, Entity, Collectable, ImageLayer, Text, BitmapText, Sprite3d and subclasses).
|
|
29
34
|
* @type {ObservablePoint}
|
|
30
35
|
* @default <0.5,0.5>
|
|
31
36
|
*/
|
|
@@ -173,6 +178,28 @@ export default class Renderable extends Rect {
|
|
|
173
178
|
* }
|
|
174
179
|
*/
|
|
175
180
|
autoTransform: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Whether {@link Renderable#preDraw} applies the
|
|
183
|
+
* {@link Renderable#anchorPoint} offset to the renderer transform.
|
|
184
|
+
*
|
|
185
|
+
* When `true` (the default), the renderable is shifted by
|
|
186
|
+
* `-anchorPoint × (width, height)` so its anchor — not its top-left
|
|
187
|
+
* corner — aligns with its position. Correct for sprites and other 2D
|
|
188
|
+
* renderables.
|
|
189
|
+
*
|
|
190
|
+
* Set to `false` for a renderable that emits its own final world
|
|
191
|
+
* coordinates and takes its origin from geometry rather than a bounds
|
|
192
|
+
* box — e.g. a {@link Mesh} on the `Camera3d` world-space path (a 3D
|
|
193
|
+
* mesh is positioned by its transform and has no anchor). The WebGL mesh
|
|
194
|
+
* batcher reuses this same renderer transform as its **view matrix**,
|
|
195
|
+
* so applying the normalized anchor there would shift every mesh by
|
|
196
|
+
* half its OWN bounds box; because scene meshes size that box per node,
|
|
197
|
+
* props and the platforms they rest on would drift apart and overlap.
|
|
198
|
+
* @type {boolean}
|
|
199
|
+
* @default true
|
|
200
|
+
* @see Mesh#preDraw
|
|
201
|
+
*/
|
|
202
|
+
applyAnchorTransform: boolean;
|
|
176
203
|
/**
|
|
177
204
|
* Define the renderable opacity<br>
|
|
178
205
|
* Set to zero if you do not wish an object to be drawn
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;OAeG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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