melonjs 20.8.0 → 20.10.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 +1 -0
- package/build/application/application.d.ts +66 -8
- 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/resize.d.ts +25 -0
- package/build/application/resize.d.ts.map +1 -1
- package/build/application/scaleMethods.d.ts +13 -3
- package/build/application/scaleMethods.d.ts.map +1 -1
- package/build/application/settings.d.ts +68 -13
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +29 -5
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/autopause.d.ts +36 -0
- package/build/audio/autopause.d.ts.map +1 -0
- package/build/audio/backend/engine.d.ts +10 -0
- package/build/audio/backend/engine.d.ts.map +1 -1
- package/build/audio/backend/sound.d.ts.map +1 -1
- package/build/audio/backend/spatial.d.ts.map +1 -1
- package/build/audio/context.d.ts +35 -0
- package/build/audio/context.d.ts.map +1 -0
- package/build/audio/playback.d.ts.map +1 -1
- package/build/audio/procedural.d.ts.map +1 -1
- package/build/audio/spatial.d.ts +87 -0
- package/build/audio/spatial.d.ts.map +1 -0
- package/build/audio/state.d.ts +1 -0
- package/build/audio/state.d.ts.map +1 -1
- package/build/audio/types.d.ts +46 -6
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/camera/effects/mask_effect.d.ts.map +1 -1
- package/build/camera/effects/shake_effect.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +1 -1
- package/build/geometries/box3d.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +1 -1
- package/build/geometries/ellipse.d.ts.map +1 -1
- package/build/geometries/line.d.ts +1 -1
- package/build/geometries/line.d.ts.map +1 -1
- package/build/geometries/point.d.ts +1 -1
- package/build/geometries/point.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +1 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/geometries/rectangle.d.ts +1 -1
- package/build/geometries/rectangle.d.ts.map +1 -1
- package/build/geometries/roundrect.d.ts +1 -1
- package/build/geometries/roundrect.d.ts.map +1 -1
- package/build/geometries/sphere.d.ts +1 -1
- package/build/geometries/sphere.d.ts.map +1 -1
- package/build/index.d.ts +9 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38737 -35039
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts +129 -3
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +5 -4
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/tiled/TMXObjectFactory.d.ts +3 -2
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +1 -4
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/loader/cache.d.ts +220 -0
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/loader.d.ts +20 -349
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts +115 -0
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/math/color.d.ts +1 -1
- package/build/math/color.d.ts.map +1 -1
- package/build/math/matrix2d.d.ts +1 -1
- package/build/math/matrix2d.d.ts.map +1 -1
- package/build/math/matrix3d.d.ts +1 -1
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +14 -2
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +15 -1
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/math/vector2d.d.ts +31 -1
- package/build/math/vector2d.d.ts.map +1 -1
- package/build/math/vector3d.d.ts +38 -1
- package/build/math/vector3d.d.ts.map +1 -1
- package/build/math/vertex.d.ts.map +1 -1
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +7 -1
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +35 -0
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +1 -1
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +24 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/broadphase/quadtree.d.ts +31 -0
- package/build/physics/broadphase/quadtree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +14 -0
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/pool.d.ts +4 -0
- package/build/pool.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +13 -0
- package/build/renderable/colorlayer.d.ts.map +1 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/groundshadow.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +56 -0
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +97 -11
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +47 -3
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +2 -1
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +6 -2
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +63 -2
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
- package/build/renderable/text/glypheffect.d.ts +44 -0
- package/build/renderable/text/glypheffect.d.ts.map +1 -0
- package/build/renderable/text/text.d.ts +17 -0
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/trail.d.ts.map +1 -1
- package/build/renderable/trail3d.d.ts +174 -0
- package/build/renderable/trail3d.d.ts.map +1 -0
- package/build/renderable/trigger.d.ts +2 -1
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/renderable/ui/panelpaint.d.ts +5 -0
- package/build/renderable/ui/panelpaint.d.ts.map +1 -0
- package/build/renderable/ui/progressbar.d.ts +2 -4
- package/build/renderable/ui/progressbar.d.ts.map +1 -1
- package/build/renderable/ui/uipanel.d.ts +245 -0
- package/build/renderable/ui/uipanel.d.ts.map +1 -0
- package/build/renderable/ui/uitextbutton.d.ts +30 -1
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/state.d.ts.map +1 -1
- package/build/system/bootstrap.d.ts.map +1 -1
- package/build/system/legacy_pool.d.ts +22 -2
- package/build/system/legacy_pool.d.ts.map +1 -1
- package/build/system/pool.d.ts +5 -8
- package/build/system/pool.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +1 -1
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/squish.d.ts +74 -0
- package/build/video/effects/squish.d.ts.map +1 -0
- package/build/video/effects/tintPulse.d.ts +0 -5
- package/build/video/effects/tintPulse.d.ts.map +1 -1
- package/build/video/effects/wave.d.ts +0 -5
- package/build/video/effects/wave.d.ts.map +1 -1
- package/build/video/gpu/batcher.d.ts +8 -2
- package/build/video/gpu/batcher.d.ts.map +1 -1
- package/build/video/gradient.d.ts +1 -0
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +16 -3
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/rendertarget/rendertarget.d.ts +12 -5
- package/build/video/rendertarget/rendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +6 -12
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +1 -1
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/texture2d.d.ts +6 -0
- package/build/video/texture/texture2d.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -11
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +5 -0
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +21 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/deletable.d.ts +15 -0
- package/build/video/webgl/buffer/deletable.d.ts.map +1 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/AGENTS.md +1 -1
- package/skills/melonjs/SKILL.md +2 -0
- package/skills/melonjs-3d/SKILL.md +192 -18
- package/skills/melonjs-3d-assets/SKILL.md +36 -2
- package/skills/melonjs-audio/SKILL.md +229 -8
- package/skills/melonjs-camera-and-drawing/SKILL.md +73 -3
- package/skills/melonjs-display-and-scaling/SKILL.md +273 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +54 -10
- package/skills/melonjs-events/SKILL.md +8 -6
- package/skills/melonjs-input/SKILL.md +100 -4
- package/skills/melonjs-loading-assets/SKILL.md +22 -4
- package/skills/melonjs-math/SKILL.md +313 -0
- package/skills/melonjs-particles-and-trails/SKILL.md +88 -14
- package/skills/melonjs-performance/SKILL.md +57 -22
- package/skills/melonjs-physics/SKILL.md +2 -1
- package/skills/melonjs-renderables/SKILL.md +6 -1
- package/skills/melonjs-scenes-and-state/SKILL.md +14 -3
- package/skills/melonjs-sprites-and-animation/SKILL.md +9 -4
- package/skills/melonjs-tilemaps/SKILL.md +40 -12
- package/skills/melonjs-ui-and-text/SKILL.md +382 -4
|
@@ -367,6 +367,7 @@ export default class Mesh extends Renderable {
|
|
|
367
367
|
* const coin = new Mesh(x, floorY, { ...geometry, castGroundShadow: true });
|
|
368
368
|
* coin.shadowGroundY = floorY;
|
|
369
369
|
* coin.pos.y = floorY - 40 - 30 * Math.sin(t);
|
|
370
|
+
* @see Mesh#shadowGroundPoint
|
|
370
371
|
*/
|
|
371
372
|
shadowGroundY: number | undefined;
|
|
372
373
|
/**
|
|
@@ -405,11 +406,12 @@ export default class Mesh extends Renderable {
|
|
|
405
406
|
* at all. {@link Mesh#shadowScale} rides in that radius, so widening
|
|
406
407
|
* the blob carries the offset with it.
|
|
407
408
|
*
|
|
408
|
-
* Honoured ONLY when
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
409
|
+
* Honoured ONLY when the floor has been NAMED, by
|
|
410
|
+
* {@link Mesh#shadowGroundY} or by {@link Mesh#shadowGroundPoint}. The
|
|
411
|
+
* blob is a flat quad on one named plane with no contact with terrain,
|
|
412
|
+
* so sliding it across a plane the game has not named puts it somewhere
|
|
413
|
+
* there may be no floor at all. Naming the floor is the game saying
|
|
414
|
+
* where it is, and that is the only case where an offset is honest.
|
|
413
415
|
*
|
|
414
416
|
* An {@link InstancedMesh} honours it too, as one throw shared by the
|
|
415
417
|
* whole set, measured in the SET's own blob radius.
|
|
@@ -474,6 +476,47 @@ export default class Mesh extends Renderable {
|
|
|
474
476
|
* sun.direction.set(Math.sin(t), 1, Math.cos(t)).normalize();
|
|
475
477
|
*/
|
|
476
478
|
shadowLight: Light3d | undefined;
|
|
479
|
+
/**
|
|
480
|
+
* Takes an array or a `Vector3d` and keeps a copy of its own, so a game
|
|
481
|
+
* placing these from one scratch vector per frame does not end up with
|
|
482
|
+
* every shadow in the scene sharing a point. `undefined` goes back to
|
|
483
|
+
* `shadowGroundY` and the caster's own column.
|
|
484
|
+
* @param {number[]|Vector3d|undefined} value - the point on the floor
|
|
485
|
+
* @example
|
|
486
|
+
* // a rock resting on a globe: the contact point is radially below it,
|
|
487
|
+
* // and the floor it lands on faces the same way
|
|
488
|
+
* rock.shadowGroundPoint = surfacePoint;
|
|
489
|
+
* rock.shadowGroundNormal = outwardNormal;
|
|
490
|
+
*/
|
|
491
|
+
set shadowGroundPoint(value: number[] | Vector3d | undefined);
|
|
492
|
+
/**
|
|
493
|
+
* The point on the floor the blob lands on, for ground that is not flat.
|
|
494
|
+
*
|
|
495
|
+
* {@link Mesh#shadowGroundY} names a HEIGHT and lets the caster's own
|
|
496
|
+
* vertical column supply the rest, which is a flat-world assumption: the
|
|
497
|
+
* blob can only ever be directly below the thing casting it. That is the
|
|
498
|
+
* right answer for a platformer, and the wrong one anywhere "down" is not
|
|
499
|
+
* world down. On a sphere it is radial, so a blob pinned to the column
|
|
500
|
+
* lands BESIDE its caster by the drop times the tangent of the tilt.
|
|
501
|
+
*
|
|
502
|
+
* Set this and the blob goes where you put it. It supersedes
|
|
503
|
+
* `shadowGroundY`, which it already contains, and it names a floor the
|
|
504
|
+
* same way, so {@link Mesh#shadowOffset} and the height fade work with it;
|
|
505
|
+
* pair it with {@link Mesh#shadowGroundNormal} to say which way that floor
|
|
506
|
+
* faces, and the fade is then measured along that normal rather than
|
|
507
|
+
* straight down.
|
|
508
|
+
* Per object only. An {@link InstancedMesh} shares one plane across a
|
|
509
|
+
* set, built through the set's own origin, and refuses this with a
|
|
510
|
+
* warning rather than accepting it silently. `level.load()` and
|
|
511
|
+
* `GLTFScene` do not forward it either, since one point shared by every
|
|
512
|
+
* part of a scene would stack that scene's blobs on a single spot; set
|
|
513
|
+
* it on the part you want after the load.
|
|
514
|
+
* @type {Vector3d|undefined}
|
|
515
|
+
* @default undefined
|
|
516
|
+
* @see Mesh#shadowGroundY
|
|
517
|
+
* @see Mesh#shadowGroundNormal
|
|
518
|
+
*/
|
|
519
|
+
get shadowGroundPoint(): Vector3d | undefined;
|
|
477
520
|
/**
|
|
478
521
|
* Takes an array or a `Vector3d` and keeps a normalized copy of its own,
|
|
479
522
|
* so a game that goes on mutating what it passed does not steer this
|
|
@@ -499,10 +542,16 @@ export default class Mesh extends Renderable {
|
|
|
499
542
|
* exactly.
|
|
500
543
|
*
|
|
501
544
|
* The blob is ROTATED onto the plane, not projected, so it keeps its
|
|
502
|
-
* shape; it
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
545
|
+
* shape; it sits directly under the caster rather than sliding along the
|
|
546
|
+
* slope, unless {@link Mesh#shadowGroundPoint} says otherwise, and it is
|
|
547
|
+
* still a flat quad with no contact with what it lies on.
|
|
548
|
+
*
|
|
549
|
+
* The tilt is clamped at 75 degrees ALONGSIDE `shadowGroundY`, past
|
|
550
|
+
* which an edge-on blob has nothing left to show. That ceiling measures
|
|
551
|
+
* the tilt from world up, which stands in for "tilted away from the
|
|
552
|
+
* viewer" only while the camera looks down the Y axis; it is lifted
|
|
553
|
+
* alongside `shadowGroundPoint`, where a point and a normal state the
|
|
554
|
+
* plane outright and there is nothing left to guess.
|
|
506
555
|
*
|
|
507
556
|
* On an {@link InstancedMesh} the plane serves the WHOLE set: it passes
|
|
508
557
|
* through the set's origin at `shadowGroundY` and faces this way, and
|
|
@@ -728,6 +777,34 @@ export default class Mesh extends Renderable {
|
|
|
728
777
|
* @returns {AABB3d} the world-space bounding box (reused instance)
|
|
729
778
|
*/
|
|
730
779
|
getBounds3d(): AABB3d;
|
|
780
|
+
/**
|
|
781
|
+
* Tint this mesh from a LINEAR material factor.
|
|
782
|
+
*
|
|
783
|
+
* The counterpart of {@link Renderable#setTint}, which takes an ordinary
|
|
784
|
+
* sRGB colour: this one takes the form a renderer's own colour space
|
|
785
|
+
* states it in, which in practice means a glTF `baseColorFactor`, and
|
|
786
|
+
* encodes it. Scaling such a value by 255 into `setColor` instead renders
|
|
787
|
+
* the material 60 to 70 counts too dark in the midtones.
|
|
788
|
+
*
|
|
789
|
+
* The same thing the `baseColorFactor` SETTING does at construction, so a
|
|
790
|
+
* material that changes during play is reached the same way as one that
|
|
791
|
+
* is set up front. `emissive`, `specular` and `shininess` are all
|
|
792
|
+
* settable after construction; this was the one material value that was
|
|
793
|
+
* not.
|
|
794
|
+
*
|
|
795
|
+
* A METHOD rather than a property, deliberately: the factor is encoded
|
|
796
|
+
* into {@link Renderable#tint} and nothing holds the original, so a
|
|
797
|
+
* readable `baseColorFactor` would either have to invert the encoding or
|
|
798
|
+
* keep a copy that goes stale the moment anything writes `tint`.
|
|
799
|
+
* @param {number[]|Float32Array} factor - `[r, g, b]` in 0..1, linear
|
|
800
|
+
* @returns {this} this mesh, for chaining
|
|
801
|
+
* @example
|
|
802
|
+
* // what the glTF loader hands back, applied by hand
|
|
803
|
+
* mesh.setBaseColorFactor(node.baseColorFactor);
|
|
804
|
+
* // and the sRGB counterpart, for a colour a game picked
|
|
805
|
+
* mesh.setTint("#ff8800");
|
|
806
|
+
*/
|
|
807
|
+
setBaseColorFactor(factor: number[] | Float32Array): this;
|
|
731
808
|
/**
|
|
732
809
|
* Draw the mesh (automatically called by melonJS). Picks between two
|
|
733
810
|
* projection paths based on the camera that was active when this mesh
|
|
@@ -871,6 +948,10 @@ export type MeshSettings = {
|
|
|
871
948
|
* - 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.
|
|
872
949
|
*/
|
|
873
950
|
normals?: number[] | Float32Array;
|
|
951
|
+
/**
|
|
952
|
+
* - the material's base colour factor `[r, g, b]` in 0..1, LINEAR, applied as the mesh tint. That is the form a glTF material states it in (spec 3.9.2) and the form the loader hands back, so a mesh built from a node passes the node's own field straight through. It is ENCODED rather than scaled: a linear factor pushed through `tint.setColor` by multiplying by 255 renders every untextured material 60 to 70 counts too dark in the midtones, which reads as a lighting fault and gets debugged as one. For an ordinary sRGB colour use {@link Renderable#setTint}. The type admits `undefined` deliberately: the loader declares the field optional, so `baseColorFactor: node.baseColorFactor` is the headline use and it has to compile for a consumer building under `exactOptionalPropertyTypes`.
|
|
953
|
+
*/
|
|
954
|
+
baseColorFactor?: number[] | Float32Array | undefined;
|
|
874
955
|
/**
|
|
875
956
|
* - 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.
|
|
876
957
|
*/
|
|
@@ -916,7 +997,7 @@ export type MeshSettings = {
|
|
|
916
997
|
*/
|
|
917
998
|
shadowScale?: number;
|
|
918
999
|
/**
|
|
919
|
-
* - how far to slide the shadow along `shadowDirectionX`/`shadowDirectionZ`, in multiples of the blob's own radius, for the look of a light that is not directly overhead. A ratio rather than a world distance so one value serves casters of any size. Honoured only when `shadowGroundY`
|
|
1000
|
+
* - how far to slide the shadow along `shadowDirectionX`/`shadowDirectionZ`, in multiples of the blob's own radius, for the look of a light that is not directly overhead. A ratio rather than a world distance so one value serves casters of any size. Honoured only when the floor has been named, by `shadowGroundY` or by `shadowGroundPoint`, since the blob is a flat quad and sliding it off a plane the game has NOT named puts it somewhere there is no floor. On an `InstancedMesh` it is one throw for the whole set.
|
|
920
1001
|
*/
|
|
921
1002
|
shadowOffset?: number;
|
|
922
1003
|
/**
|
|
@@ -932,7 +1013,11 @@ export type MeshSettings = {
|
|
|
932
1013
|
*/
|
|
933
1014
|
shadowDirectionZ?: number;
|
|
934
1015
|
/**
|
|
935
|
-
* - the
|
|
1016
|
+
* - the point on the floor the blob lands on, for ground that is not flat. Supersedes `shadowGroundY`, which can only put the blob on the caster's own vertical column; anywhere "down" is not world down, such as on a sphere, that lands the blob beside its caster rather than under it. Names a floor the same way `shadowGroundY` does, so `shadowOffset` and the height fade work with it.
|
|
1017
|
+
*/
|
|
1018
|
+
shadowGroundPoint?: number[] | Vector3d;
|
|
1019
|
+
/**
|
|
1020
|
+
* - the UP normal of the floor the shadow lands on, for a surface that is not level. Needs the floor to be named, by `shadowGroundY` or by `shadowGroundPoint`; this says which way it faces. Defaults to world up. The tilt is clamped at 75 degrees alongside `shadowGroundY`, and NOT clamped alongside `shadowGroundPoint`, which states the plane outright. On an `InstancedMesh` one plane serves the whole set, through the set's origin at `shadowGroundY`, so a scatter over curved ground is one set per facet.
|
|
936
1021
|
*/
|
|
937
1022
|
shadowGroundNormal?: number[] | Vector3d;
|
|
938
1023
|
/**
|
|
@@ -942,6 +1027,7 @@ export type MeshSettings = {
|
|
|
942
1027
|
};
|
|
943
1028
|
import Renderable from "./renderable.js";
|
|
944
1029
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
1030
|
+
import type { Light3d } from "../lighting/light3d.ts";
|
|
945
1031
|
import { Vector3d } from "../math/vector3d.ts";
|
|
946
1032
|
import { Color } from "../math/color.ts";
|
|
947
1033
|
import { Matrix3d } from "../math/matrix3d.ts";
|
|
@@ -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":"AAmjBA;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACH,eAhDW,MAAM,KACN,MAAM,YACN,YAAY,EA8iCtB;IAn/BC;;;OAGG;IACH,kBAFU,YAAY,CAEkB;IAExC;;;OAGG;IACH,KAFU,YAAY,C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;;UACP,OAAO;;;;oBACP,MAAM;;;;oBACN,MAAM;;;;kBACN,MAAM;;;;mBACN,MAAM;;;;oBACN,MAAM;;;;uBACN,MAAM;;;;uBACN,MAAM;;;;wBACN,MAAM,EAAE,GAAC,QAAQ;;;;yBACjB,MAAM,EAAE,GAAC,QAAQ;;;;kBACjB,OAAO;;uBAldE,iBAAiB;6BAVX,6BAA6B;6BAuBhC,wBAAwB;yBAhCzB,qBAAqB;sBAHxB,kBAAkB;yBACf,qBAAqB;yBACrB,qBAAqB;wBALtB,0BAA0B;0BAuCzB,4BAA4B;uBA1B9B,iCAAiC;+BAuB1B,oCAAoC;qBAtB7C,wBAAwB;0BAuBpB,uBAAuB;sBArB1B,iCAAiC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
/**
|
|
2
3
|
* A base class for renderable objects.
|
|
3
4
|
* @category Game Objects
|
|
@@ -158,6 +159,10 @@ export default class Renderable extends Rect {
|
|
|
158
159
|
alwaysUpdate: boolean;
|
|
159
160
|
/**
|
|
160
161
|
* Whether to update this object when the game is paused.
|
|
162
|
+
*
|
|
163
|
+
* On a container it covers everything under it: a child steps through
|
|
164
|
+
* a pause on its own opt-in or on one from any container above it, so
|
|
165
|
+
* a pause menu flags itself once and its nested labels follow.
|
|
161
166
|
* @type {boolean}
|
|
162
167
|
* @default false
|
|
163
168
|
*/
|
|
@@ -356,7 +361,15 @@ export default class Renderable extends Rect {
|
|
|
356
361
|
* @type {boolean}
|
|
357
362
|
*/
|
|
358
363
|
get isFloating(): boolean;
|
|
359
|
-
|
|
364
|
+
/**
|
|
365
|
+
* Takes a {@link Color} to copy, or a CSS colour string.
|
|
366
|
+
*
|
|
367
|
+
* It COPIES rather than holds, so a caller that goes on mutating what it
|
|
368
|
+
* passed does not steer this renderable's tint by accident. What the
|
|
369
|
+
* getter hands back is always a `Color`, whichever form went in.
|
|
370
|
+
* @param {Color|string} value - the colour to tint with
|
|
371
|
+
*/
|
|
372
|
+
set tint(value: Color | string);
|
|
360
373
|
/**
|
|
361
374
|
* define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
|
|
362
375
|
* @type {Color}
|
|
@@ -368,6 +381,31 @@ export default class Renderable extends Rect {
|
|
|
368
381
|
* this.tint.setColor(255, 255, 255);
|
|
369
382
|
*/
|
|
370
383
|
get tint(): Color;
|
|
384
|
+
/**
|
|
385
|
+
* Tint this renderable, chainably.
|
|
386
|
+
*
|
|
387
|
+
* Exactly {@link Renderable#tint}'s own setter, returning the renderable
|
|
388
|
+
* so it can be chained with the other `set*` methods. It exists because
|
|
389
|
+
* `tint` is a live {@link Color}, so reaching for it means choosing
|
|
390
|
+
* between `setColor` (0 to 255), `setFloat` (0 to 1), `parseCSS`,
|
|
391
|
+
* `setHSL` and `setLinear` — and picking the wrong one is silent, it just
|
|
392
|
+
* renders the wrong colour.
|
|
393
|
+
*
|
|
394
|
+
* Deliberately sRGB only. A LINEAR value, which in practice means a glTF
|
|
395
|
+
* `baseColorFactor` or `emissiveFactor`, stays an explicit
|
|
396
|
+
* `tint.setLinear(...)` so the conversion is never silent; for a mesh
|
|
397
|
+
* built from an asset, pass {@link Mesh#baseColorFactor} as a setting and
|
|
398
|
+
* the loader's value is applied for you.
|
|
399
|
+
* @param {Color|string} value - a `Color` to copy, or a CSS colour string
|
|
400
|
+
* @returns {this} this renderable, for chaining
|
|
401
|
+
* @example
|
|
402
|
+
* sprite.setTint("#ff8800");
|
|
403
|
+
* // the same on any renderable, mesh included
|
|
404
|
+
* mesh.setTint(theme.accent).setOpacity(0.5);
|
|
405
|
+
* // remove a tint
|
|
406
|
+
* sprite.setTint("#ffffff");
|
|
407
|
+
*/
|
|
408
|
+
setTint(value: Color | string): this;
|
|
371
409
|
set depth(value: number);
|
|
372
410
|
/**
|
|
373
411
|
* the depth of this renderable on the z axis
|
|
@@ -392,13 +430,13 @@ export default class Renderable extends Rect {
|
|
|
392
430
|
* @param {number} x - the new x position
|
|
393
431
|
* @param {number} y - the new y position
|
|
394
432
|
* @param {number} [z] - the new depth; left untouched when omitted
|
|
395
|
-
* @returns {
|
|
433
|
+
* @returns {this} this renderable, for chaining
|
|
396
434
|
* @example
|
|
397
435
|
* sprite.setPosition(120, 64); // 2D: depth unchanged
|
|
398
436
|
* mesh.setPosition(0, -20, 140); // 3D
|
|
399
437
|
* camera.setPosition(0, 0, -300).lookAt(player);
|
|
400
438
|
*/
|
|
401
|
-
setPosition(x: number, y: number, z?: number):
|
|
439
|
+
setPosition(x: number, y: number, z?: number): this;
|
|
402
440
|
set inViewport(value: boolean);
|
|
403
441
|
/**
|
|
404
442
|
* Whether the renderable object is visible and within the viewport
|
|
@@ -414,6 +452,12 @@ export default class Renderable extends Rect {
|
|
|
414
452
|
get shader(): GLShader | ShaderEffect | undefined;
|
|
415
453
|
/**
|
|
416
454
|
* Add a post-processing shader effect to this renderable.
|
|
455
|
+
*
|
|
456
|
+
* With the `prewarm` application setting on (the default), what the
|
|
457
|
+
* effect will need to draw here is compiled from this call, off the
|
|
458
|
+
* frame, rather than on the frame the renderable first draws with it.
|
|
459
|
+
* That takes a moment to finish, so attach effects when the renderable
|
|
460
|
+
* is built (a pool, a stage starting) rather than when it is shown.
|
|
417
461
|
* @param {GLShader|ShaderEffect} effect - the effect to add
|
|
418
462
|
* @returns {GLShader|ShaderEffect} the added effect
|
|
419
463
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAkjDA;;;;;;;;;;;;;;;;;GAiBG;AACH,iDAJW,UAAU,QA+BpB;AAziDD;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ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BA0EC;IAED;;;;;;;OAOG;IACH,yBAFc,GAAC,EAAA,QAId;IAED;;;;;;;;OAQG;IACH,0BAHc,GAAC,EAAA,QAKd;IAED;;;;;;;OAOG;IACH,4BAHc,GAAC,EAAA,QAKd;CACD;qBA/iDoB,8BAA8B;gCADnB,kCAAkC;yBAKzC,qBAAqB;iCAwBhB,uBAAuB;2BAd3B,gBAAgB;wBADnB,oBAAoB;+BAKf,8BAA8B;6BADhC,0BAA0B;0BAF7B,yBAAyB;6BACtB,4BAA4B;0BAU7B,4BAA4B;8BAGxB,kCAAkC;8BAEpC,qBAAqB;2BANxB,kBAAkB;6BANd,iCAAiC;8BAQlC,qBAAqB;8BAGrB,qBAAqB;4BAPvB,sBAAsB;0BAStB,sBAAsB;0BARtB,uBAAuB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* additional import for TypeScript
|
|
3
|
+
* @import {TextureAtlas} from "./../video/texture/atlas.js";
|
|
3
4
|
* @import {Vector2d} from "../math/vector2d.ts";
|
|
4
5
|
* @import Renderer from "./../video/renderer.js";
|
|
5
6
|
* @import {CompressedImage} from "../loader/parsers/compressed_textures/compressed_image.js";
|
|
@@ -381,7 +382,7 @@ export default class Sprite extends Renderable {
|
|
|
381
382
|
}
|
|
382
383
|
import Renderable from "./renderable.js";
|
|
383
384
|
import type { Vector2d } from "../math/vector2d.ts";
|
|
384
|
-
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
385
|
+
import type { TextureAtlas } from "./../video/texture/atlas.js";
|
|
385
386
|
import type { CompressedImage } from "../loader/parsers/compressed_textures/compressed_image.js";
|
|
386
387
|
import type Renderer from "./../video/renderer.js";
|
|
387
388
|
import Texture2d from "./../video/texture/texture2d.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sprite.d.ts","sourceRoot":"","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AQG;IACH,mBAqBC;IAED;;;;;OAKG;IACH,2BAkBC;IAED;;;;OAIG;IACH,yBAIC;IAED;;;OAGG;IACH,oCAYC;IAED;;;;OAIG;IACH,gBA0BC;CACD;uBAtnCsB,iBAAiB;2BADb,qBAAqB;8BAarB,qBAAqB;kCADjB,6BAA6B;qCAG1B,2DAA2D;0BADpE,wBAAwB;sBAhB3B,iCAAiC;sBAHjC,kBAAkB"}
|
|
@@ -97,11 +97,13 @@ export default class Sprite3d extends Mesh {
|
|
|
97
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
98
|
* @param {number} [settings.shadowOpacity=0.45] - opacity of the shadow directly beneath the sprite, before any height fade
|
|
99
99
|
* @param {number} [settings.shadowScale=1] - multiplier for the ground shadow's footprint; non-positive or non-finite values hide the shadow
|
|
100
|
-
* @param {number} [settings.shadowOffset=0] - how far to slide the shadow along its direction, in multiples of the blob's own radius; needs `shadowGroundY` (see {@link Mesh#shadowOffset})
|
|
100
|
+
* @param {number} [settings.shadowOffset=0] - how far to slide the shadow along its direction, in multiples of the blob's own radius; needs the floor named, by `shadowGroundY` or `shadowGroundPoint` (see {@link Mesh#shadowOffset})
|
|
101
101
|
* @param {number} [settings.shadowStretch=1] - how much longer the blob is along its direction, clamped to 3
|
|
102
102
|
* @param {number} [settings.shadowDirectionX=0] - x of the ground direction the shadow is cast along
|
|
103
103
|
* @param {number} [settings.shadowDirectionZ=0] - z of the ground direction the shadow is cast along
|
|
104
|
-
* @param {number[]|Vector3d} [settings.shadowGroundNormal] - the UP normal of the floor the shadow lands on; needs `shadowGroundY` (see {@link Mesh#shadowGroundNormal})
|
|
104
|
+
* @param {number[]|Vector3d} [settings.shadowGroundNormal] - the UP normal of the floor the shadow lands on; needs the floor named, by `shadowGroundY` or `shadowGroundPoint` (see {@link Mesh#shadowGroundNormal})
|
|
105
|
+
* @param {number[]|Vector3d} [settings.shadowGroundPoint] - the point on the floor the blob lands on, for ground that is not flat; supersedes `shadowGroundY` (see {@link Mesh#shadowGroundPoint})
|
|
106
|
+
* @param {number[]|Float32Array} [settings.baseColorFactor] - the material's base colour as a LINEAR triple, applied as the tint (see {@link Mesh#baseColorFactor})
|
|
105
107
|
* @param {Light3d} [settings.shadowLight] - a {@link Light3d} to take that direction from instead
|
|
106
108
|
* @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}.
|
|
107
109
|
* @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.
|
|
@@ -135,6 +137,8 @@ export default class Sprite3d extends Mesh {
|
|
|
135
137
|
shadowDirectionX?: number | undefined;
|
|
136
138
|
shadowDirectionZ?: number | undefined;
|
|
137
139
|
shadowGroundNormal?: number[] | Vector3d | undefined;
|
|
140
|
+
shadowGroundPoint?: number[] | Vector3d | undefined;
|
|
141
|
+
baseColorFactor?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
138
142
|
shadowLight?: any;
|
|
139
143
|
castGroundShadow?: boolean | undefined;
|
|
140
144
|
fog?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC
|
|
1
|
+
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;OAUG;IACH,mBAJa,OAAO,CA+CnB;IAkDD;;;;;;OAMG;IACH,yEAmBC;CACD;iBA9pCgB,WAAW;2BADD,qBAAqB;qBAN3B,uBAAuB;sBAItB,+BAA+B;8BAO1B,qBAAqB;yBARvB,qBAAqB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @import WebGLRenderer from "../../video/webgl/webgl_renderer.js";
|
|
6
6
|
* @import {Bounds} from "../../physics/bounds.ts";
|
|
7
7
|
* @import Renderer from "../../video/renderer.js";
|
|
8
|
+
* @import {GlyphEffect, GlyphEffectContext, GlyphEffectOutput} from "./glypheffect.ts";
|
|
8
9
|
*/
|
|
9
10
|
/**
|
|
10
11
|
* a bitmap font object.
|
|
@@ -30,6 +31,7 @@ export default class BitmapText extends Renderable {
|
|
|
30
31
|
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
31
32
|
* @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"`.
|
|
32
33
|
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
|
|
34
|
+
* @param {GlyphEffect|null} [settings.glyphEffect=null] - a per-glyph offset and tint callback
|
|
33
35
|
* @param {(string|string[])} [settings.text] - a string, or an array of strings
|
|
34
36
|
* @example
|
|
35
37
|
* // Load the BMFont descriptor as a "binary" asset and its page as an "image".
|
|
@@ -61,6 +63,7 @@ export default class BitmapText extends Renderable {
|
|
|
61
63
|
y: number;
|
|
62
64
|
} | undefined;
|
|
63
65
|
wordWrapWidth?: number | undefined;
|
|
66
|
+
glyphEffect?: GlyphEffect | null | undefined;
|
|
64
67
|
text?: string | string[] | undefined;
|
|
65
68
|
});
|
|
66
69
|
/**
|
|
@@ -136,6 +139,61 @@ export default class BitmapText extends Renderable {
|
|
|
136
139
|
*/
|
|
137
140
|
public get fillStyle(): Color;
|
|
138
141
|
metrics: TextMetrics;
|
|
142
|
+
set glyphEffect(effect: GlyphEffect | null);
|
|
143
|
+
/**
|
|
144
|
+
* A per-glyph offset and multiplicative tint callback, or `null` to disable.
|
|
145
|
+
* The output and context are reused: do not retain them. Offsets start at
|
|
146
|
+
* zero and tint at opaque white on each call. Time advances through update,
|
|
147
|
+
* so drawing through multiple cameras does not advance the animation.
|
|
148
|
+
* Effects change drawing only: metrics, wrapping and bounds stay unchanged.
|
|
149
|
+
* Keep the measured text in view: effects do not extend the culling bounds.
|
|
150
|
+
* WebGL and WebGPU retain batching: the tint rides the per-vertex colour,
|
|
151
|
+
* so a whole animated line is still one draw call. Canvas realizes each
|
|
152
|
+
* DISTINCT tint as a cached, tinted copy of the entire font page, and that
|
|
153
|
+
* cache is unbounded for the life of the renderer, so a colour driven by
|
|
154
|
+
* `ctx.time` costs a font-page canvas per frame there. On Canvas, keep the
|
|
155
|
+
* palette finite or vary only the offsets.
|
|
156
|
+
*
|
|
157
|
+
* While an effect is set the renderable reports itself as changed every
|
|
158
|
+
* frame, since whether the callback reads `ctx.time` cannot be known.
|
|
159
|
+
*
|
|
160
|
+
* Two things decide whether a travelling effect reads as motion. Take the
|
|
161
|
+
* phase from `ctx.x` rather than `ctx.index`: a per-glyph step advances
|
|
162
|
+
* the wave as far across a narrow glyph as a wide one, so its wavelength
|
|
163
|
+
* changes with whatever the line spells. And round the offsets if the
|
|
164
|
+
* frame is upscaled, since they are applied unchanged and a fractional
|
|
165
|
+
* destination under nearest sampling makes the glyph's own pixels uneven,
|
|
166
|
+
* differently each frame.
|
|
167
|
+
* @type {GlyphEffect|null}
|
|
168
|
+
* @example
|
|
169
|
+
* // A wave travelling along the line, four pixels deep, about a 1.3s
|
|
170
|
+
* // cycle, with a wavelength of roughly ten times the font size.
|
|
171
|
+
* title.glyphEffect = (out, ctx) => {
|
|
172
|
+
* out.offsetY = Math.round(Math.sin(ctx.time * 0.005 + ctx.x * 0.02) * 4);
|
|
173
|
+
* };
|
|
174
|
+
*
|
|
175
|
+
* // One hit, ringing down to nothing. A shake throws each glyph somewhere
|
|
176
|
+
* // unrelated to its neighbours; a sine would move the line as one body.
|
|
177
|
+
* // `ctx.time` counts from the moment the effect is ASSIGNED, so attach
|
|
178
|
+
* // this on the frame the hit lands, not when the label was built.
|
|
179
|
+
* const angle = (i, tick) => {
|
|
180
|
+
* const h = Math.sin(i * 127.1 + tick * 311.7) * 43758.5453;
|
|
181
|
+
* return (h - Math.floor(h)) * Math.PI * 2;
|
|
182
|
+
* };
|
|
183
|
+
* banner.glyphEffect = (out, ctx) => {
|
|
184
|
+
* const left = 1 - ctx.time / 650;
|
|
185
|
+
* if (left <= 0) return; // settled; `out` is already zeroed
|
|
186
|
+
* const amp = 3 * left * left; // decays on the square
|
|
187
|
+
* const tick = (ctx.time / 1000) * 24; // a new direction 24 times a second
|
|
188
|
+
* const held = Math.floor(tick);
|
|
189
|
+
* const k = tick - held;
|
|
190
|
+
* const a = angle(ctx.index, held);
|
|
191
|
+
* const b = angle(ctx.index, held + 1);
|
|
192
|
+
* out.offsetX = Math.round((Math.sin(a) + (Math.sin(b) - Math.sin(a)) * k) * amp);
|
|
193
|
+
* out.offsetY = Math.round((Math.cos(a) + (Math.cos(b) - Math.cos(a)) * k) * amp);
|
|
194
|
+
* };
|
|
195
|
+
*/
|
|
196
|
+
get glyphEffect(): GlyphEffect | null;
|
|
139
197
|
/**
|
|
140
198
|
* change the font settings
|
|
141
199
|
* @param {string} textAlign - ("left", "center", "right")
|
|
@@ -149,6 +207,8 @@ export default class BitmapText extends Renderable {
|
|
|
149
207
|
* @returns {BitmapText} this object for chaining
|
|
150
208
|
*/
|
|
151
209
|
setText(value?: number | string | string[]): BitmapText;
|
|
210
|
+
/** @inheritdoc */
|
|
211
|
+
update(dt: any): boolean;
|
|
152
212
|
public set visibleCharacters(value: number);
|
|
153
213
|
/**
|
|
154
214
|
* the number of characters to display (use -1 to show all).
|
|
@@ -177,14 +237,14 @@ export default class BitmapText extends Renderable {
|
|
|
177
237
|
* change the font display size
|
|
178
238
|
* @param {number} scale - a ratio against the font's authored size, NOT a
|
|
179
239
|
* pixel size: `1` is the page image at its native scale, `2` is double
|
|
180
|
-
* @returns {
|
|
240
|
+
* @returns {this} this object for chaining
|
|
181
241
|
* @example
|
|
182
242
|
* // a bitmap font is pixel art — whole-number ratios stay crisp, and
|
|
183
243
|
* // fractional ones resample the page image
|
|
184
244
|
* title.resize(3); // three times its authored size
|
|
185
245
|
* title.set("center", 2); // align and rescale in one call
|
|
186
246
|
*/
|
|
187
|
-
resize(scale: number):
|
|
247
|
+
resize(scale: number): this;
|
|
188
248
|
/**
|
|
189
249
|
* measure the given text size in pixels
|
|
190
250
|
* @param {string} [text]
|
|
@@ -204,6 +264,7 @@ export default class BitmapText extends Renderable {
|
|
|
204
264
|
import Renderable from "../renderable.js";
|
|
205
265
|
import { Color } from "../../math/color.ts";
|
|
206
266
|
import TextMetrics from "./textmetrics.js";
|
|
267
|
+
import type { GlyphEffect } from "./glypheffect.ts";
|
|
207
268
|
import type Renderer from "../../video/renderer.js";
|
|
208
269
|
import type { Vector2d } from "../../math/vector2d.ts";
|
|
209
270
|
//# sourceMappingURL=bitmaptext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH;;;;;;;;;GASG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,eA/BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,YAAY;QACZ,UAAU;QACmB,WA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B;IAED;;;;;;;;;;OAUG;IACH,yBA0CC;IAED;;;;OAIG;IACH,gBAUC;CACD;uBAxqBsB,kBAAkB;sBAHnB,qBAAqB;wBAKnB,kBAAkB;iCAS2B,kBAAkB;0BAD9D,yBAAyB;8BAHvB,wBAAwB"}
|
|
@@ -16,5 +16,5 @@ export default class BitmapTextData {
|
|
|
16
16
|
constructor(data: string);
|
|
17
17
|
parse(fontData: string): void;
|
|
18
18
|
}
|
|
19
|
-
export declare const bitmapTextDataPool: import("../../
|
|
19
|
+
export declare const bitmapTextDataPool: import("../../index.ts").Pool<BitmapTextData, [fontData: string]>;
|
|
20
20
|
//# sourceMappingURL=bitmaptextdata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AAkFA;;;;GAIG;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;gBAYf,IAAI,EAAE,MAAM;IAIxB,KAAK,CAAC,QAAQ,EAAE,MAAM;CAkMtB;AAED,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"AAkFA;;;;GAIG;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;gBAYf,IAAI,EAAE,MAAM;IAIxB,KAAK,CAAC,QAAQ,EAAE,MAAM;CAkMtB;AAED,eAAO,MAAM,kBAAkB,mEAY7B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Color } from "../../math/color.ts";
|
|
2
|
+
/** Mutable per-glyph output, reset before each call. Do not retain it. */
|
|
3
|
+
export interface GlyphEffectOutput {
|
|
4
|
+
/**
|
|
5
|
+
* Horizontal offset in drawing pixels, after font scaling.
|
|
6
|
+
*
|
|
7
|
+
* Added to the glyph's destination as given, with no rounding. On an
|
|
8
|
+
* upscaled low-resolution frame, round it: a fractional destination under
|
|
9
|
+
* nearest sampling makes the glyph's own pixels come out uneven, and
|
|
10
|
+
* differently so each frame, which reads as a shimmer rather than motion.
|
|
11
|
+
*/
|
|
12
|
+
offsetX: number;
|
|
13
|
+
/**
|
|
14
|
+
* Vertical offset in drawing pixels, after font scaling. Rounds like
|
|
15
|
+
* {@link GlyphEffectOutput.offsetX}.
|
|
16
|
+
*/
|
|
17
|
+
offsetY: number;
|
|
18
|
+
/** Multiplicative tint; reset to opaque white before each call. */
|
|
19
|
+
readonly tint: Color;
|
|
20
|
+
}
|
|
21
|
+
/** Reused per-glyph context. Read its values during the callback only. */
|
|
22
|
+
export interface GlyphEffectContext {
|
|
23
|
+
/** UTF-16 character index across drawn lines, excluding line breaks. */
|
|
24
|
+
index: number;
|
|
25
|
+
/** The UTF-16 character represented by this glyph. */
|
|
26
|
+
char: string;
|
|
27
|
+
/** The BMFont character code. */
|
|
28
|
+
code: number;
|
|
29
|
+
/** Elapsed update time in milliseconds while the effect is enabled. */
|
|
30
|
+
time: number;
|
|
31
|
+
/**
|
|
32
|
+
* Unmodified glyph destination coordinates, after alignment and scaling.
|
|
33
|
+
*
|
|
34
|
+
* The natural phase source for a travelling effect: deriving it from
|
|
35
|
+
* {@link GlyphEffectContext.index} instead advances the wave as far across
|
|
36
|
+
* a narrow glyph as a wide one, so its wavelength changes with whatever
|
|
37
|
+
* the line spells.
|
|
38
|
+
*/
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
}
|
|
42
|
+
/** Modify the reused output to offset or tint a BitmapText glyph. */
|
|
43
|
+
export type GlyphEffect = (out: GlyphEffectOutput, context: GlyphEffectContext) => void;
|
|
44
|
+
//# sourceMappingURL=glypheffect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glypheffect.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/glypheffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IACjC;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACrB;AAED,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IAClC,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,CACzB,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,kBAAkB,KACvB,IAAI,CAAC"}
|
|
@@ -261,6 +261,23 @@ export default class Text extends Renderable {
|
|
|
261
261
|
*/
|
|
262
262
|
draw(renderer: Renderer): void;
|
|
263
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* A pool of reusable {@link Text} instances.
|
|
266
|
+
*
|
|
267
|
+
* Text is worth recycling: each one owns a canvas-backed measurement cache and
|
|
268
|
+
* a colour, so a scene that spawns damage numbers or score popups churns
|
|
269
|
+
* meaningfully without one. Reachable as `getPool("text")`.
|
|
270
|
+
*
|
|
271
|
+
* `release` it yourself when the text is finished, as the particle and tween
|
|
272
|
+
* pools require. A label this pool built is the exception: it carries the pool
|
|
273
|
+
* it came from, so removing it from a container releases it back rather than
|
|
274
|
+
* destroying it. Pass `keepalive` to `removeChild()` to keep holding one.
|
|
275
|
+
* @example
|
|
276
|
+
* const label = getPool("text").get(x, y, { font: "Arial", size: 12, text: "+10" });
|
|
277
|
+
* // ... later
|
|
278
|
+
* getPool("text").release(label);
|
|
279
|
+
*/
|
|
280
|
+
export const textPool: import("../../index.ts").Pool<Text, [x: unknown, y: unknown, settings: unknown]>;
|
|
264
281
|
import Renderable from "../renderable.js";
|
|
265
282
|
import { Color } from "../../math/color.ts";
|
|
266
283
|
import { Gradient } from "../../video/gradient.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"],"names":[],"mappings":"AAiDA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6DG;IACH,eA7DW,MAAM,KACN,MAAM,YAEd;QAAyB,IAAI,EAArB,MAAM;QACkB,IAAI,EAA5B,MAAM,GAAC,MAAM;QACoB,SAAS;QACvB,eAAe;QACV,WAAW;QACjB,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACmB,WAAW;eAAvC,MAAM;eAAG,MAAM;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AAkB;sBANlC,qBAAqB;yBAE7B,yBAAyB;+BAEnB,gDAAgD;wBAGvD,kBAAkB;0BASjB,yBAAyB;8BAHvB,wBAAwB"}
|
|
@@ -1 +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,EA6DA;IAzDA,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;IAYV,
|
|
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,EA6DA;IAzDA,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;IAYV,kBAA6C;IAC7C;;;OAGG;IACH,eAAiB;IACjB;;;OAGG;IACH,qBAAoC;IACpC;;;OAGG;IACH;;;MAAyB;IACzB;;;OAGG;IACH;;;MAAyB;IAa1B;;;;OAIG;IACH,YAHW,MAAM,KACN,MAAM,QAehB;IAED;;;OAGG;IACH,yBAsBC;IAED;;;OAGG;IACH,0BAiDC;IAED,6BAA6B;IAC7B,cAEC;IAED;;;;;;OAMG;IACH,wBALW,MAAM,GACJ,MAAM,CAOlB;IAED;;;OAGG;IACH,gBAMC;CACD;uBAxPsB,iBAAiB;8BAIb,qBAAqB;2BADxB,kBAAkB"}
|