melonjs 20.7.0 → 20.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 +7 -3
- package/build/application/application.d.ts +66 -8
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +6 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/header.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 +144 -5
- 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 -1
- package/build/audio/backend/engine.d.ts.map +1 -1
- package/build/audio/backend/sound.d.ts +0 -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/camera3d.d.ts +95 -8
- package/build/camera/camera3d.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 +25 -7
- package/build/geometries/box3d.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +15 -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 +15 -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 +36 -7
- package/build/geometries/sphere.d.ts.map +1 -1
- package/build/index.d.ts +16 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +38172 -33633
- 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/input/pointerevent.d.ts +8 -0
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +20 -33
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +40 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/level.d.ts +35 -0
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +5 -2
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +0 -1
- package/build/level/tiled/TMXObjectFactory.d.ts +3 -2
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +2 -1
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +7 -4
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXTilesetGroup.d.ts +5 -0
- package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
- package/build/level/tiled/factories/shape.d.ts +0 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +6 -5
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +5 -7
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +5 -0
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts +19 -4
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/autodetect.d.ts +0 -4
- package/build/level/tiled/renderer/autodetect.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 -340
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -2
- package/build/loader/loadingscreen.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/loader/parsers/shader.d.ts +0 -2
- package/build/math/color.d.ts +28 -5
- 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 +29 -2
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +104 -0
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +9 -1
- package/build/physics/adapter.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 +17 -2
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts +0 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/sat.d.ts +0 -7
- package/build/physics/builtin/sat3d.d.ts +46 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -1
- package/build/physics/response.d.ts +45 -62
- package/build/physics/response.d.ts.map +1 -1
- package/build/pool.d.ts +4 -0
- package/build/pool.d.ts.map +1 -1
- package/build/renderable/collectable.d.ts +6 -1
- package/build/renderable/collectable.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +17 -4
- package/build/renderable/colorlayer.d.ts.map +1 -1
- package/build/renderable/container.d.ts +23 -17
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +12 -16
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts +1 -1
- package/build/renderable/groundshadow.d.ts +1 -0
- package/build/renderable/groundshadow.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +12 -5
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +56 -7
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +369 -4
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/nineslicesprite.d.ts +3 -13
- package/build/renderable/nineslicesprite.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +129 -28
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +7 -20
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +31 -16
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +76 -5
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/bitmaptextdata.d.ts +1 -5
- 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 +22 -3
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +2 -0
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/trail.d.ts +0 -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 +28 -5
- 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 +192 -0
- package/build/renderable/ui/progressbar.d.ts.map +1 -0
- package/build/renderable/ui/uibaseelement.d.ts +48 -3
- package/build/renderable/ui/uibaseelement.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/uispriteelement.d.ts +19 -3
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- 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 +24 -4
- package/build/system/legacy_pool.d.ts.map +1 -1
- package/build/system/pool.d.ts +15 -8
- package/build/system/pool.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +50 -3
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +34 -23
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/effects/blendEffect.d.ts +0 -1
- package/build/video/effects/bloom.d.ts +72 -0
- package/build/video/effects/bloom.d.ts.map +1 -0
- package/build/video/effects/blur.d.ts +3 -2
- package/build/video/effects/blur.d.ts.map +1 -1
- package/build/video/effects/chromaticAberration.d.ts +3 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -1
- package/build/video/effects/colorMatrix.d.ts +3 -2
- package/build/video/effects/colorMatrix.d.ts.map +1 -1
- package/build/video/effects/desaturate.d.ts +10 -2
- package/build/video/effects/desaturate.d.ts.map +1 -1
- package/build/video/effects/dissolve.d.ts +3 -2
- package/build/video/effects/dissolve.d.ts.map +1 -1
- package/build/video/effects/dropShadow.d.ts +3 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -1
- package/build/video/effects/flash.d.ts +3 -2
- package/build/video/effects/flash.d.ts.map +1 -1
- package/build/video/effects/glow.d.ts +3 -2
- package/build/video/effects/glow.d.ts.map +1 -1
- package/build/video/effects/hologram.d.ts +3 -2
- package/build/video/effects/hologram.d.ts.map +1 -1
- package/build/video/effects/invert.d.ts +10 -2
- package/build/video/effects/invert.d.ts.map +1 -1
- package/build/video/effects/outline.d.ts +3 -2
- package/build/video/effects/outline.d.ts.map +1 -1
- package/build/video/effects/pixelate.d.ts +3 -2
- package/build/video/effects/pixelate.d.ts.map +1 -1
- package/build/video/effects/radialGradient.d.ts +8 -3
- package/build/video/effects/radialGradient.d.ts.map +1 -1
- package/build/video/effects/scanline.d.ts +3 -2
- package/build/video/effects/scanline.d.ts.map +1 -1
- package/build/video/effects/sepia.d.ts +10 -2
- package/build/video/effects/sepia.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts +10 -4
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/shine.d.ts +3 -2
- package/build/video/effects/shine.d.ts.map +1 -1
- package/build/video/effects/tintPulse.d.ts +3 -7
- package/build/video/effects/tintPulse.d.ts.map +1 -1
- package/build/video/effects/tonemap.d.ts +121 -0
- package/build/video/effects/tonemap.d.ts.map +1 -0
- package/build/video/effects/vignette.d.ts +3 -2
- package/build/video/effects/vignette.d.ts.map +1 -1
- package/build/video/effects/wave.d.ts +3 -7
- 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/gpu/vertexformat.d.ts +26 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -1
- package/build/video/gradient.d.ts +1 -1
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +111 -7
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +2 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +3 -4
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +0 -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 +0 -1
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +24 -14
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
- package/build/video/texture/atlas.d.ts +2 -1
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +1 -3
- package/build/video/texture/frametexture.d.ts +0 -1
- package/build/video/texture/frametexture.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +1 -0
- package/build/video/texture/noise_texture2d.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/utils/autodetect.d.ts +0 -2
- package/build/video/webgl/batchers/batcher.d.ts +0 -9
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +4 -2
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +4 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +0 -1
- package/build/video/webgl/buffer/retained_geometry.d.ts +0 -1
- package/build/video/webgl/glshader.d.ts +5 -3
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +0 -4
- package/build/video/webgl/texture/store.d.ts +0 -1
- package/build/video/webgl/webgl_renderer.d.ts +63 -24
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +0 -3
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +0 -2
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts +0 -2
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts +0 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +7 -75
- 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 +454 -22
- package/skills/melonjs-3d-assets/SKILL.md +111 -10
- package/skills/melonjs-audio/SKILL.md +229 -8
- package/skills/melonjs-camera-and-drawing/SKILL.md +127 -1
- package/skills/melonjs-display-and-scaling/SKILL.md +273 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +341 -29
- package/skills/melonjs-events/SKILL.md +8 -6
- package/skills/melonjs-input/SKILL.md +147 -7
- package/skills/melonjs-math/SKILL.md +313 -0
- package/skills/melonjs-particles-and-trails/SKILL.md +189 -13
- package/skills/melonjs-performance/SKILL.md +131 -23
- package/skills/melonjs-physics/SKILL.md +103 -28
- package/skills/melonjs-renderables/SKILL.md +8 -2
- package/skills/melonjs-scenes-and-state/SKILL.md +134 -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 +546 -7
- package/build/level/gltf/srgb.d.ts +0 -20
- package/build/level/gltf/srgb.d.ts.map +0 -1
|
@@ -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
|
*/
|
|
@@ -315,6 +320,36 @@ export default class Renderable extends Rect {
|
|
|
315
320
|
* @default true
|
|
316
321
|
*/
|
|
317
322
|
isKinematic: boolean;
|
|
323
|
+
/**
|
|
324
|
+
* whether a single post effect on this renderable needs an offscreen
|
|
325
|
+
* capture instead of the renderer's shader-swap fast path.
|
|
326
|
+
*
|
|
327
|
+
* One effect is normally applied by drawing the renderable with the
|
|
328
|
+
* effect's own program rather than capturing and post-processing it,
|
|
329
|
+
* which costs no render target. That is only equivalent when everything
|
|
330
|
+
* the renderable draws is a textured quad. `fillRect` and the shape
|
|
331
|
+
* dispatch go through a batcher that never looks at that shader, so a
|
|
332
|
+
* single effect on a renderable that draws with primitives silently
|
|
333
|
+
* does nothing. Set this and the capture is used instead, at the cost
|
|
334
|
+
* of a render target while the effect is active.
|
|
335
|
+
*
|
|
336
|
+
* Two or more effects always capture, so this only ever changes the
|
|
337
|
+
* single-effect case.
|
|
338
|
+
* @type {boolean}
|
|
339
|
+
* @default false
|
|
340
|
+
* @example
|
|
341
|
+
* class Bar extends Renderable {
|
|
342
|
+
* constructor(x, y, w, h) {
|
|
343
|
+
* super(x, y, w, h);
|
|
344
|
+
* // this draws itself with primitives, not as a sprite
|
|
345
|
+
* this.postEffectNeedsCapture = true;
|
|
346
|
+
* }
|
|
347
|
+
* draw(renderer) {
|
|
348
|
+
* renderer.fillRect(this.pos.x, this.pos.y, this.width, this.height);
|
|
349
|
+
* }
|
|
350
|
+
* }
|
|
351
|
+
*/
|
|
352
|
+
postEffectNeedsCapture: boolean;
|
|
318
353
|
/**
|
|
319
354
|
* returns the parent application (or game) to which this renderable is attached to
|
|
320
355
|
* @return {Application} the parent application or undefined if not attached to any container/app
|
|
@@ -326,7 +361,15 @@ export default class Renderable extends Rect {
|
|
|
326
361
|
* @type {boolean}
|
|
327
362
|
*/
|
|
328
363
|
get isFloating(): boolean;
|
|
329
|
-
|
|
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);
|
|
330
373
|
/**
|
|
331
374
|
* define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
|
|
332
375
|
* @type {Color}
|
|
@@ -338,12 +381,62 @@ export default class Renderable extends Rect {
|
|
|
338
381
|
* this.tint.setColor(255, 255, 255);
|
|
339
382
|
*/
|
|
340
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;
|
|
341
409
|
set depth(value: number);
|
|
342
410
|
/**
|
|
343
411
|
* the depth of this renderable on the z axis
|
|
344
412
|
* @type {number}
|
|
345
413
|
*/
|
|
346
414
|
get depth(): number;
|
|
415
|
+
/**
|
|
416
|
+
* Move this renderable, optionally in three dimensions.
|
|
417
|
+
*
|
|
418
|
+
* `pos` holds an `ObservableVector3d`, but the geometry this class
|
|
419
|
+
* inherits from declares it as a 2D vector, so from TypeScript
|
|
420
|
+
* `pos.set(x, y)` takes two arguments and silently writes a zero z.
|
|
421
|
+
* Anything with a depth then drops to the near plane. Reaching past that
|
|
422
|
+
* previously meant a double cast or assigning `pos.x`, `pos.y` and
|
|
423
|
+
* `depth` by hand, which is why that pattern is written out dozens of
|
|
424
|
+
* times across the examples.
|
|
425
|
+
*
|
|
426
|
+
* **Omitting `z` leaves the depth exactly as it was**, rather than
|
|
427
|
+
* zeroing it. That is the whole difference from `pos.set(x, y)`, and it
|
|
428
|
+
* is what makes this safe to call on a 2D sprite that happens to sit at
|
|
429
|
+
* a depth, or on a `Camera2d`, without having to know whether it does.
|
|
430
|
+
* @param {number} x - the new x position
|
|
431
|
+
* @param {number} y - the new y position
|
|
432
|
+
* @param {number} [z] - the new depth; left untouched when omitted
|
|
433
|
+
* @returns {this} this renderable, for chaining
|
|
434
|
+
* @example
|
|
435
|
+
* sprite.setPosition(120, 64); // 2D: depth unchanged
|
|
436
|
+
* mesh.setPosition(0, -20, 140); // 3D
|
|
437
|
+
* camera.setPosition(0, 0, -300).lookAt(player);
|
|
438
|
+
*/
|
|
439
|
+
setPosition(x: number, y: number, z?: number): this;
|
|
347
440
|
set inViewport(value: boolean);
|
|
348
441
|
/**
|
|
349
442
|
* Whether the renderable object is visible and within the viewport
|
|
@@ -403,11 +496,6 @@ export default class Renderable extends Rect {
|
|
|
403
496
|
* @type {boolean}
|
|
404
497
|
*/
|
|
405
498
|
public get isFlippedY(): boolean;
|
|
406
|
-
/**
|
|
407
|
-
* returns the bounding box for this renderable
|
|
408
|
-
* @returns {Bounds} bounding box Rectangle object
|
|
409
|
-
*/
|
|
410
|
-
getBounds(): Bounds;
|
|
411
499
|
/**
|
|
412
500
|
* get the renderable alpha channel value<br>
|
|
413
501
|
*
|
|
@@ -439,9 +527,9 @@ export default class Renderable extends Rect {
|
|
|
439
527
|
* multiply the renderable currentTransform with the given matrix
|
|
440
528
|
* @see Renderable#currentTransform
|
|
441
529
|
* @param {Matrix2d|Matrix3d} m - the transformation matrix
|
|
442
|
-
* @returns {
|
|
530
|
+
* @returns {this} Reference to this object for method chaining
|
|
443
531
|
*/
|
|
444
|
-
transform(m: Matrix2d | Matrix3d):
|
|
532
|
+
transform(m: Matrix2d | Matrix3d): this;
|
|
445
533
|
/**
|
|
446
534
|
* return the angle to the specified target
|
|
447
535
|
* @param {Renderable|Vector2d|Vector3d} target
|
|
@@ -466,9 +554,9 @@ export default class Renderable extends Rect {
|
|
|
466
554
|
* When called with an angle and a Vector3d axis, rotates around that axis in 3D.
|
|
467
555
|
* @param {number} angle - The angle to rotate (in radians)
|
|
468
556
|
* @param {Vector3d} [v] - the axis to rotate around (defaults to Z axis for 2D)
|
|
469
|
-
* @returns {
|
|
557
|
+
* @returns {this} Reference to this object for method chaining
|
|
470
558
|
*/
|
|
471
|
-
rotate(angle: number, v?: Vector3d):
|
|
559
|
+
rotate(angle: number, v?: Vector3d): this;
|
|
472
560
|
/**
|
|
473
561
|
* scale the renderable around his anchor point. Scaling actually applies changes
|
|
474
562
|
* to the currentTransform member which is used by the renderer to scale the object
|
|
@@ -478,23 +566,23 @@ export default class Renderable extends Rect {
|
|
|
478
566
|
* @param {number} x - a number representing the abscissa of the scaling vector.
|
|
479
567
|
* @param {number} [y=x] - a number representing the ordinate of the scaling vector.
|
|
480
568
|
* @param {number} [z=1] - a number representing the depth of the scaling vector.
|
|
481
|
-
* @returns {
|
|
569
|
+
* @returns {this} Reference to this object for method chaining
|
|
482
570
|
*/
|
|
483
|
-
scale(x: number, y?: number, z?: number):
|
|
571
|
+
scale(x: number, y?: number, z?: number): this;
|
|
484
572
|
/**
|
|
485
573
|
* scale the renderable around his anchor point
|
|
486
574
|
* @param {Vector2d} v - scaling vector
|
|
487
|
-
* @returns {
|
|
575
|
+
* @returns {this} Reference to this object for method chaining
|
|
488
576
|
*/
|
|
489
|
-
scaleV(v: Vector2d):
|
|
577
|
+
scaleV(v: Vector2d): this;
|
|
490
578
|
/**
|
|
491
579
|
* Translate the renderable by the specified offset.
|
|
492
|
-
* @param {number} x - x offset
|
|
493
|
-
* @param {number} [y=0] - y offset
|
|
494
|
-
* @param {number} [z=0] - z offset
|
|
495
|
-
* @returns {
|
|
580
|
+
* @param {number|Vector2d|Vector3d} x - x offset, or a vector to translate by
|
|
581
|
+
* @param {number} [y=0] - y offset, ignored when the first argument is a vector
|
|
582
|
+
* @param {number} [z=0] - z offset, ignored when the first argument is a vector
|
|
583
|
+
* @returns {this} Reference to this object for method chaining
|
|
496
584
|
*/
|
|
497
|
-
translate(x: number, y?: number, z?: number):
|
|
585
|
+
translate(x: number | Vector2d | Vector3d, y?: number, z?: number): this;
|
|
498
586
|
/**
|
|
499
587
|
* update function (automatically called by melonJS).
|
|
500
588
|
* @param {number} dt - time since the last update in milliseconds.
|
|
@@ -618,9 +706,9 @@ export default class Renderable extends Rect {
|
|
|
618
706
|
* This will apply any defined transforms, anchor point, tint or blend mode and translate the context accordingly to this renderable position.
|
|
619
707
|
* @see Renderable#draw
|
|
620
708
|
* @see Renderable#postDraw
|
|
621
|
-
* @param {
|
|
709
|
+
* @param {Renderer} renderer - a renderer object
|
|
622
710
|
*/
|
|
623
|
-
preDraw(renderer:
|
|
711
|
+
preDraw(renderer: Renderer): void;
|
|
624
712
|
/**
|
|
625
713
|
* Draw this renderable (automatically called by melonJS).
|
|
626
714
|
* All draw operations for renderable are made respectively
|
|
@@ -634,17 +722,22 @@ export default class Renderable extends Rect {
|
|
|
634
722
|
* `(0, 0)` places the shape at the container's origin instead.
|
|
635
723
|
* @see Renderable#preDraw
|
|
636
724
|
* @see Renderable#postDraw
|
|
637
|
-
* @param {
|
|
638
|
-
* @param {Camera2d} [viewport] - the
|
|
725
|
+
* @param {Renderer} renderer - a renderer instance
|
|
726
|
+
* @param {Camera2d|Container} [viewport] - the frame this draw happens in:
|
|
727
|
+
* the camera drawing it, or -- when a camera is itself the renderable being
|
|
728
|
+
* drawn -- the container it draws. `Camera2d#draw` takes the second, and
|
|
729
|
+
* declaring only the first here meant a camera was not assignable to the
|
|
730
|
+
* `Renderable` it extends, which cascaded into every signature mentioning
|
|
731
|
+
* either of them
|
|
639
732
|
*/
|
|
640
|
-
draw(renderer:
|
|
733
|
+
draw(renderer: Renderer, viewport?: Camera2d | Container): void;
|
|
641
734
|
/**
|
|
642
735
|
* restore the rendering context after drawing (automatically called by melonJS).
|
|
643
736
|
* @see Renderable#preDraw
|
|
644
737
|
* @see Renderable#draw
|
|
645
|
-
* @param {
|
|
738
|
+
* @param {Renderer} renderer - a renderer object
|
|
646
739
|
*/
|
|
647
|
-
postDraw(renderer:
|
|
740
|
+
postDraw(renderer: Renderer): void;
|
|
648
741
|
/**
|
|
649
742
|
* Legacy collision callback — fires every frame this renderable body is
|
|
650
743
|
* overlapping another body. Kept for backward compatibility with code
|
|
@@ -714,13 +807,21 @@ export default class Renderable extends Rect {
|
|
|
714
807
|
import { Rect } from "./../geometries/rectangle.ts";
|
|
715
808
|
import { ObservablePoint } from "../geometries/observablePoint.ts";
|
|
716
809
|
import { Matrix3d } from "../math/matrix3d.ts";
|
|
810
|
+
import type { PhysicsBody } from "../physics/adapter.ts";
|
|
717
811
|
import type Container from "./container.js";
|
|
718
812
|
import type Entity from "./entity/entity.js";
|
|
719
813
|
import type { RoundRect } from "./../geometries/roundrect.ts";
|
|
720
814
|
import type { Polygon } from "../geometries/polygon.ts";
|
|
721
815
|
import type { Line } from "./../geometries/line.ts";
|
|
722
816
|
import type { Ellipse } from "./../geometries/ellipse.ts";
|
|
817
|
+
import type GLShader from "../video/webgl/glshader.js";
|
|
818
|
+
import type ShaderEffect from "../video/effects/shadereffect.js";
|
|
819
|
+
import type { Vector3d } from "../math/vector3d.ts";
|
|
820
|
+
import type { Color } from "../math/color.ts";
|
|
723
821
|
import type Application from "./../application/application.ts";
|
|
724
|
-
import type
|
|
725
|
-
import type
|
|
822
|
+
import type { Matrix2d } from "../math/matrix2d.ts";
|
|
823
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
824
|
+
import type { Bounds } from "../physics/bounds.ts";
|
|
825
|
+
import type Renderer from "../video/renderer.js";
|
|
826
|
+
import type Camera2d from "../camera/camera2d.ts";
|
|
726
827
|
//# sourceMappingURL=renderable.d.ts.map
|
|
@@ -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":"AAwiDA;;;;;;;;;;;;;;;;;GAiBG;AACH,iDAJW,UAAU,QA+BpB;AA/hDD;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,MAlCU,WAAW,CAkCA;IAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,SAxBU,MAAM,GAAC,SAAS,CAwBF;IAExB;;;;;OAKG;IACH,MAFU,MAAM,CAEK;IAErB;;;;;;;;;;OAUG;IACH,6BAAmC;IAEnC;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;;;;;OAQG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;;OAKG;IACH,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;4BAPvB,sBAAsB;0BAStB,sBAAsB;0BARtB,uBAAuB"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* additional import for TypeScript
|
|
3
|
-
* @import {
|
|
3
|
+
* @import {TextureAtlas} from "./../video/texture/atlas.js";
|
|
4
|
+
* @import {Vector2d} from "../math/vector2d.ts";
|
|
4
5
|
* @import Renderer from "./../video/renderer.js";
|
|
6
|
+
* @import {CompressedImage} from "../loader/parsers/compressed_textures/compressed_image.js";
|
|
5
7
|
*/
|
|
6
8
|
/**
|
|
7
9
|
* An object to display a fixed or animated sprite on screen.
|
|
@@ -143,10 +145,8 @@ export default class Sprite extends Renderable {
|
|
|
143
145
|
* axe.shininess = 0;
|
|
144
146
|
*/
|
|
145
147
|
shininess: number;
|
|
146
|
-
image:
|
|
148
|
+
image: HTMLVideoElement | import("./../video/texture/texture2d.ts").Texture2dSource | CompressedImage;
|
|
147
149
|
textureAtlas: any;
|
|
148
|
-
width: any;
|
|
149
|
-
height: any;
|
|
150
150
|
set animationpause(value: boolean);
|
|
151
151
|
/**
|
|
152
152
|
* pause the frame animation, freezing the current frame.
|
|
@@ -374,19 +374,6 @@ export default class Sprite extends Renderable {
|
|
|
374
374
|
* @returns {number} current animation frame index
|
|
375
375
|
*/
|
|
376
376
|
getCurrentAnimationFrame(): number;
|
|
377
|
-
/**
|
|
378
|
-
* Prepare the rendering context before drawing this sprite (automatically called by melonJS).
|
|
379
|
-
* Extends `Renderable.preDraw` to publish this sprite's `normalMap` (if any)
|
|
380
|
-
* on the renderer so the WebGL lit pipeline can pair it with the next
|
|
381
|
-
* `drawImage` call. Cleared back in `postDraw`.
|
|
382
|
-
* @param {Renderer} renderer - a renderer instance
|
|
383
|
-
*/
|
|
384
|
-
preDraw(renderer: Renderer): void;
|
|
385
|
-
/**
|
|
386
|
-
* restore the rendering context after drawing this sprite (automatically called by melonJS).
|
|
387
|
-
* @param {Renderer} renderer - a renderer instance
|
|
388
|
-
*/
|
|
389
|
-
postDraw(renderer: Renderer): void;
|
|
390
377
|
/**
|
|
391
378
|
* draw this sprite (automatically called by melonJS)
|
|
392
379
|
* @param {Renderer} renderer - a renderer instance
|
|
@@ -394,9 +381,9 @@ export default class Sprite extends Renderable {
|
|
|
394
381
|
draw(renderer: Renderer): void;
|
|
395
382
|
}
|
|
396
383
|
import Renderable from "./renderable.js";
|
|
397
|
-
import
|
|
398
|
-
import type {
|
|
399
|
-
import {
|
|
384
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
385
|
+
import type { TextureAtlas } from "./../video/texture/atlas.js";
|
|
386
|
+
import type { CompressedImage } from "../loader/parsers/compressed_textures/compressed_image.js";
|
|
400
387
|
import type Renderer from "./../video/renderer.js";
|
|
401
388
|
import Texture2d from "./../video/texture/texture2d.ts";
|
|
402
389
|
import { Color } from "../math/color.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":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,eA5CW,MAAM,KACN,MAAM,YAEd;QAAoH,KAAK,EAAjH,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,SAAS,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QAC/E,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACwB,WAAW;eAAvC,MAAM;eAAG,MAAM;;QACyD,SAAS;QAClF,OAAO;QACP,SAAS;KACnC,EAoZF;IApWA;;;OAGG;IACH,2BAEE;IAEF;;;;OAIG;IACH,QAHU,QAAQ,CAGkB;IAEpC;;;;OAIG;IACH,SAHU,OAAO,CAGG;I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B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,0BAlCW,MAAM,cACN,MAAM,cAAU,MAAM,gBACtB,OAAO,GACL,MAAM,CAkClB;IAED;;;;;OAKG;IACH,wBAJW,MAAM,GACJ,MAAM,CASlB;IAED;;;;;;;;OAQG;IACH,yBAPW,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;;;;OAQG;IACH,qBANa,MAAM,EAAE,CAQpB;IAED;;;;;;;;OAQG;IACH,kBANW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;OAOG;IACH,oBAJW,MAAM,QA2ChB;IAED;;;;;;;OAOG;IACH,0BANW,MAAM,GACJ,MAAM,CAQlB;IAED;;;OAGG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;IAwFD;;;OAGG;IACH,eAFW,QAAQ,QAsDlB;IAED;;;;OAIG;IACH,gBAyBC;CACD;uBArgCsB,iBAAiB;2BADb,qBAAqB;8BASrB,qBAAqB;kCADjB,6BAA6B;qCAG1B,2DAA2D;0BADpE,wBAAwB;sBAZ3B,iCAAiC;sBAHjC,kBAAkB"}
|
|
@@ -96,9 +96,19 @@ export default class Sprite3d extends Mesh {
|
|
|
96
96
|
* @param {number[]|Float32Array} [settings.emissive] - emissive color (see {@link 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
|
+
* @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 the floor named, by `shadowGroundY` or `shadowGroundPoint` (see {@link Mesh#shadowOffset})
|
|
101
|
+
* @param {number} [settings.shadowStretch=1] - how much longer the blob is along its direction, clamped to 3
|
|
102
|
+
* @param {number} [settings.shadowDirectionX=0] - x of the ground direction the shadow is cast along
|
|
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 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})
|
|
107
|
+
* @param {Light3d} [settings.shadowLight] - a {@link Light3d} to take that direction from instead
|
|
99
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}.
|
|
100
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.
|
|
101
110
|
* @param {boolean} [settings.transparent] - draw in the transparent pass (blended, back-to-front, no depth write) instead of the opaque one. Omit and the sprite goes transparent whenever its draw alpha is fractional; `true` for a soft-alpha sprite such as an additive glow; `false` to stay opaque however faded.
|
|
111
|
+
* @param {boolean} [settings.depthTest=true] - whether geometry in front of this sprite hides it. `false` draws it over whatever is already there, for a glow or an overlay with no surface to be occluded ON — a flat billboard left depth tested is cut along a hard straight line wherever nearer geometry crosses it. Separate from the depth WRITE the transparent pass turns off on its own. See {@link Mesh#depthTest}.
|
|
102
112
|
* @param {number} [settings.alphaCutoff=0.5] - alpha cutout threshold (see {@link Mesh}). The mesh pass is opaque (no alpha blending), so this defaults to `0.5` to discard a sprite's transparent background (clean cutout silhouette, correct depth, no sorting). Set `0` for a fully-opaque quad, or tune the threshold.
|
|
103
113
|
*/
|
|
104
114
|
constructor(x: number, y: number, settings: {
|
|
@@ -114,16 +124,26 @@ export default class Sprite3d extends Mesh {
|
|
|
114
124
|
anchorPoint?: string | Vector2d | {
|
|
115
125
|
x: number;
|
|
116
126
|
y: number;
|
|
117
|
-
};
|
|
127
|
+
} | undefined;
|
|
118
128
|
flipX?: boolean | undefined;
|
|
119
129
|
flipY?: boolean | undefined;
|
|
120
130
|
lit?: boolean | undefined;
|
|
121
131
|
emissive?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
122
132
|
shadowGroundY?: number | undefined;
|
|
123
133
|
shadowOpacity?: number | undefined;
|
|
134
|
+
shadowScale?: number | undefined;
|
|
135
|
+
shadowOffset?: number | undefined;
|
|
136
|
+
shadowStretch?: number | undefined;
|
|
137
|
+
shadowDirectionX?: number | undefined;
|
|
138
|
+
shadowDirectionZ?: number | undefined;
|
|
139
|
+
shadowGroundNormal?: number[] | Vector3d | undefined;
|
|
140
|
+
shadowGroundPoint?: number[] | Vector3d | undefined;
|
|
141
|
+
baseColorFactor?: number[] | Float32Array<ArrayBufferLike> | undefined;
|
|
142
|
+
shadowLight?: any;
|
|
124
143
|
castGroundShadow?: boolean | undefined;
|
|
125
144
|
fog?: boolean | undefined;
|
|
126
145
|
transparent?: boolean | undefined;
|
|
146
|
+
depthTest?: boolean | undefined;
|
|
127
147
|
alphaCutoff?: number | undefined;
|
|
128
148
|
});
|
|
129
149
|
/**
|
|
@@ -142,11 +162,14 @@ export default class Sprite3d extends Mesh {
|
|
|
142
162
|
*
|
|
143
163
|
* **Only applies under a `Camera3d`**; ignored on the 2D path.
|
|
144
164
|
*
|
|
145
|
-
* Note: while billboarding, orientation comes from the camera, so
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
165
|
+
* Note: while billboarding, **orientation** comes from the camera, so an
|
|
166
|
+
* in-plane `rotate()` has no effect (a card that faces the camera has no
|
|
167
|
+
* free rotation left to give) — use `billboard: false` and orient the quad
|
|
168
|
+
* yourself for a streak or an exhaust. Everything that is not an
|
|
169
|
+
* orientation still applies: `pos` / `depth`, `flipX` / `flipY`, the quad's
|
|
170
|
+
* authored size, and `scale()` / {@link Mesh#meshScale}, which size the
|
|
171
|
+
* card in its own plane. With billboarding `false` the standard
|
|
172
|
+
* {@link Mesh} world transform applies as usual.
|
|
150
173
|
* @type {boolean|string}
|
|
151
174
|
* @default false
|
|
152
175
|
*/
|
|
@@ -218,14 +241,6 @@ export default class Sprite3d extends Mesh {
|
|
|
218
241
|
* @returns {Sprite3d} Reference to this object for method chaining
|
|
219
242
|
*/
|
|
220
243
|
flipY(flip?: boolean): Sprite3d;
|
|
221
|
-
/**
|
|
222
|
-
* @returns {boolean} true if the sprite is mirrored horizontally.
|
|
223
|
-
*/
|
|
224
|
-
isFlippedX(): boolean;
|
|
225
|
-
/**
|
|
226
|
-
* @returns {boolean} true if the sprite is mirrored vertically.
|
|
227
|
-
*/
|
|
228
|
-
isFlippedY(): boolean;
|
|
229
244
|
/**
|
|
230
245
|
* Play (and optionally switch to) an animation, identical to {@link Sprite#play}.
|
|
231
246
|
* @param {string} [name] - animation id to play; omit to resume
|
|
@@ -270,7 +285,7 @@ export default class Sprite3d extends Mesh {
|
|
|
270
285
|
getCurrentAnimationFrame(): number;
|
|
271
286
|
}
|
|
272
287
|
import Mesh from "./mesh.js";
|
|
273
|
-
import FrameAnimation from "./frameAnimation.js";
|
|
274
|
-
import Camera3d from "../camera/camera3d.ts";
|
|
275
288
|
import Texture2d from "../video/texture/texture2d.ts";
|
|
289
|
+
import type { Vector2d } from "../math/vector2d.ts";
|
|
290
|
+
import { Vector3d } from "../math/vector3d.ts";
|
|
276
291
|
//# sourceMappingURL=sprite3d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sprite3d.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite3d.js"],"names":[],"mappings":"AAwEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,eAlCW,MAAM,KACN,MAAM,YAEd;QAAuE,KAAK;QAClD,KAAK;QACL,MAAM;QACN,UAAU;QACV,WAAW;QACX,MAAM;QACJ,KAAK;QACP,CAAC;QACO,SAAS;QACY,WAAW;eAAvC,MAAM;eAAG,MAAM;;QACf,KAAK;QACL,KAAK;QACL,GAAG;QACW,QAAQ;QACvB,aAAa;QACb,aAAa;QACb,WAAW;QACX,YAAY;QACZ,aAAa;QACb,gBAAgB;QAChB,gBAAgB;QACL,kBAAkB;QAClB,iBAAiB;QACb,eAAe;QAC7B,WAAW;QACX,gBAAgB;QAChB,GAAG;QACH,WAAW;QACX,SAAS;QACV,WAAW;KACvC,EAwUA;IAvMA;;;;;OAKG;IACH,QAJU,MAAM,CAIA;IAChB;;;OAGG;IACH,eAAgB;IAIhB;;;OAGG;IACH,uBAAmC;IACnC;;;OAGG;IACH,uBAAmC;IAInC;;;OAGG;IACH,gBAAgB;IAChB;;;OAGG;IACH,gBAAgB;IAoBhB;;;OAGG;IACH,eAAe;IACf;;;OAGG;IACH,eAAe;IAKf;;;OAGG;IACH,gBAAmB;IACnB;;;OAGG;IACH,gBAAmB;IAEnB;;;OAGG;IACH,uBAAmB;IAKnB;;;OAGG;IACH,kBAAwB;IACxB;;;;OAIG;IACH,YAA0B;IAM1B;;;;OAIG;IACH,kBAA6D;IAC7D;;;;OAIG;IACH,kBAAyC;IACzC;;;;OAIG;IACH,2BAEE;IAKF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,WAHU,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ED;;OAEG;IACH,4BAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,mCALW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;;OAYG;IACH,oBAJW,MAAM,QAgHhB;IA6BD;;;;;;;;;;OAUG;IACH,eALW,QAAQ,aACR,QAAQ,QAOlB;IAED;;;;;OAKG;IACH,sEAMC;IAED;;;;;;;;;;OAUG;IACH,mBAJa,OAAO,CA+CnB;IAkDD;;;;;;OAMG;IACH,yEAmBC;CACD;iBA9pCgB,WAAW;2BADD,qBAAqB;qBAN3B,uBAAuB;sBAItB,+BAA+B;8BAO1B,qBAAqB;yBARvB,qBAAqB"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import CanvasRenderer from "../../video/canvas/canvas_renderer.js";
|
|
4
|
+
* @import {Vector2d} from "../../math/vector2d.ts";
|
|
5
|
+
* @import WebGLRenderer from "../../video/webgl/webgl_renderer.js";
|
|
6
|
+
* @import {Bounds} from "../../physics/bounds.ts";
|
|
7
|
+
* @import Renderer from "../../video/renderer.js";
|
|
8
|
+
* @import {GlyphEffect, GlyphEffectContext, GlyphEffectOutput} from "./glypheffect.ts";
|
|
9
|
+
*/
|
|
1
10
|
/**
|
|
2
11
|
* a bitmap font object.
|
|
3
12
|
*
|
|
@@ -22,6 +31,7 @@ export default class BitmapText extends Renderable {
|
|
|
22
31
|
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
23
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"`.
|
|
24
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
|
|
25
35
|
* @param {(string|string[])} [settings.text] - a string, or an array of strings
|
|
26
36
|
* @example
|
|
27
37
|
* // Load the BMFont descriptor as a "binary" asset and its page as an "image".
|
|
@@ -51,8 +61,9 @@ export default class BitmapText extends Renderable {
|
|
|
51
61
|
anchorPoint?: string | Vector2d | {
|
|
52
62
|
x: number;
|
|
53
63
|
y: number;
|
|
54
|
-
};
|
|
64
|
+
} | undefined;
|
|
55
65
|
wordWrapWidth?: number | undefined;
|
|
66
|
+
glyphEffect?: GlyphEffect | null | undefined;
|
|
56
67
|
text?: string | string[] | undefined;
|
|
57
68
|
});
|
|
58
69
|
/**
|
|
@@ -128,6 +139,61 @@ export default class BitmapText extends Renderable {
|
|
|
128
139
|
*/
|
|
129
140
|
public get fillStyle(): Color;
|
|
130
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;
|
|
131
197
|
/**
|
|
132
198
|
* change the font settings
|
|
133
199
|
* @param {string} textAlign - ("left", "center", "right")
|
|
@@ -141,6 +207,8 @@ export default class BitmapText extends Renderable {
|
|
|
141
207
|
* @returns {BitmapText} this object for chaining
|
|
142
208
|
*/
|
|
143
209
|
setText(value?: number | string | string[]): BitmapText;
|
|
210
|
+
/** @inheritdoc */
|
|
211
|
+
update(dt: any): boolean;
|
|
144
212
|
public set visibleCharacters(value: number);
|
|
145
213
|
/**
|
|
146
214
|
* the number of characters to display (use -1 to show all).
|
|
@@ -169,14 +237,14 @@ export default class BitmapText extends Renderable {
|
|
|
169
237
|
* change the font display size
|
|
170
238
|
* @param {number} scale - a ratio against the font's authored size, NOT a
|
|
171
239
|
* pixel size: `1` is the page image at its native scale, `2` is double
|
|
172
|
-
* @returns {
|
|
240
|
+
* @returns {this} this object for chaining
|
|
173
241
|
* @example
|
|
174
242
|
* // a bitmap font is pixel art — whole-number ratios stay crisp, and
|
|
175
243
|
* // fractional ones resample the page image
|
|
176
244
|
* title.resize(3); // three times its authored size
|
|
177
245
|
* title.set("center", 2); // align and rescale in one call
|
|
178
246
|
*/
|
|
179
|
-
resize(scale: number):
|
|
247
|
+
resize(scale: number): this;
|
|
180
248
|
/**
|
|
181
249
|
* measure the given text size in pixels
|
|
182
250
|
* @param {string} [text]
|
|
@@ -189,11 +257,14 @@ export default class BitmapText extends Renderable {
|
|
|
189
257
|
measureText(text?: string): TextMetrics;
|
|
190
258
|
/**
|
|
191
259
|
* draw the bitmap font
|
|
192
|
-
* @param {
|
|
260
|
+
* @param {Renderer} renderer - Reference to the destination renderer instance
|
|
193
261
|
*/
|
|
194
|
-
draw(renderer:
|
|
262
|
+
draw(renderer: Renderer): void;
|
|
195
263
|
}
|
|
196
264
|
import Renderable from "../renderable.js";
|
|
197
265
|
import { Color } from "../../math/color.ts";
|
|
198
266
|
import TextMetrics from "./textmetrics.js";
|
|
267
|
+
import type { GlyphEffect } from "./glypheffect.ts";
|
|
268
|
+
import type Renderer from "../../video/renderer.js";
|
|
269
|
+
import type { Vector2d } from "../../math/vector2d.ts";
|
|
199
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;;;;;;;;;GASG;AACH;IACC
|
|
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,WAAW;eAAvC,MAAM;eAAG,MAAM;;QAChB,aAAa;QACH,WAAW;QACV,IAAI;KACzC,EAiJF;IA5HA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;;;OAKG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IAsUlE,4BAlBU,KAAK,EAyBd;IAjCD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,wBAfU,KAAK,CAiBd;IAtSA;;;OAGG;IACH,2BAA4B;IAG5B,qBAAoC;IAOpC,wCAAwC;IACxC,qBAAwB;IACxB,eAAe;IACf,yBAAyB;IACzB;;;;OAIG;IACH,0BAAkC;IA8GnC,wBAjCU,WAAW,GAAC,IAAI,EAoDzB;IA5ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;IACH,mBA7BU,WAAW,GAAC,IAAI,CA+BzB;IArGD;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAwBtB;IAgFD,kBAAkB;IAClB,yBAMC;IAoBD,oCAdU,MAAM,EAmBf;IAvBD;;;;;;;;;;;;;OAaG;IACH,gCAVU,MAAM,CAYf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAsGD;;;;;;;;;;OAUG;IACH,cATW,MAAM,GAEJ,IAAI,CAiBhB;IAED;;;;;;;;OAQG;IACH,mBAPW,MAAM,GACJ,WAAW,CAQvB;IAED;;;OAGG;IACH,eAFW,QAAQ,QA6GlB;IAED;;;;;;;;;;OAUG;IACH,yBA0CC;IAED;;;;OAIG;IACH,gBAUC;CACD;uBAxqBsB,kBAAkB;sBAHnB,qBAAqB;wBAKnB,kBAAkB;iCAS2B,kBAAkB;0BAD9D,yBAAyB;8BAHvB,wBAAwB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Glyph from "./glyph.ts";
|
|
2
1
|
/**
|
|
3
2
|
* a bitmap font data object — parses the AngelCode BMFont format in both its
|
|
4
3
|
* text (`.fnt`) and XML serialisations (the flavour is auto-detected).
|
|
@@ -14,11 +13,8 @@ export default class BitmapTextData {
|
|
|
14
13
|
descent: number;
|
|
15
14
|
glyphMinTop: number;
|
|
16
15
|
glyphMaxBottom: number;
|
|
17
|
-
glyphs: {
|
|
18
|
-
[key: number]: Glyph;
|
|
19
|
-
};
|
|
20
16
|
constructor(data: string);
|
|
21
17
|
parse(fontData: string): void;
|
|
22
18
|
}
|
|
23
|
-
export declare const bitmapTextDataPool: import("../../
|
|
19
|
+
export declare const bitmapTextDataPool: import("../../index.ts").Pool<BitmapTextData, [fontData: string]>;
|
|
24
20
|
//# sourceMappingURL=bitmaptextdata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptextdata.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptextdata.ts"],"names":[],"mappings":"
|
|
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"}
|