melonjs 19.9.1 → 20.0.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 +25 -14
- package/build/application/application.d.ts +70 -16
- package/build/application/application.d.ts.map +1 -1
- package/build/application/defaultApplicationSettings.d.ts +2 -2
- package/build/application/settings.d.ts +150 -53
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +13 -11
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/const.d.ts +55 -26
- package/build/const.d.ts.map +1 -1
- package/build/geometries/box3d.d.ts +156 -0
- package/build/geometries/box3d.d.ts.map +1 -0
- package/build/index.d.ts +33 -23
- package/build/index.d.ts.map +1 -1
- package/build/index.js +21839 -8025
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts +4 -0
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts +42 -6
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/gltf/srgb.d.ts +20 -0
- package/build/level/gltf/srgb.d.ts.map +1 -0
- package/build/level/level.d.ts +21 -2
- package/build/level/level.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +61 -13
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +49 -21
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts +18 -0
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/loader/parsers/obj.d.ts +49 -0
- package/build/loader/parsers/obj.d.ts.map +1 -1
- package/build/loader/parsers/pbr.d.ts +63 -0
- package/build/loader/parsers/pbr.d.ts.map +1 -0
- package/build/loader/parsers/shader.d.ts +32 -24
- package/build/loader/parsers/shader.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +12 -1
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/broadphase/octree.d.ts +35 -0
- package/build/physics/broadphase/octree.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +123 -6
- 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 +12 -0
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts +59 -0
- package/build/physics/builtin/sat3d.d.ts.map +1 -0
- package/build/physics/response.d.ts +32 -0
- package/build/physics/response.d.ts.map +1 -1
- package/build/physics/world.d.ts +1 -0
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/groundshadow.d.ts +92 -0
- package/build/renderable/groundshadow.d.ts.map +1 -0
- package/build/renderable/instanced_mesh.d.ts +286 -0
- package/build/renderable/instanced_mesh.d.ts.map +1 -0
- package/build/renderable/mesh.d.ts +242 -23
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +6 -4
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +17 -6
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/system/device.d.ts +11 -40
- package/build/system/device.d.ts.map +1 -1
- package/build/system/platform.d.ts +0 -16
- package/build/system/platform.d.ts.map +1 -1
- package/build/utils/utils.d.ts +2 -0
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +22 -16
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/{webgl/effects → effects}/blur.d.ts +2 -2
- package/build/video/effects/blur.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/chromaticAberration.d.ts +2 -2
- package/build/video/effects/chromaticAberration.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/colorMatrix.d.ts +3 -3
- package/build/video/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/desaturate.d.ts +1 -1
- package/build/video/effects/desaturate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dissolve.d.ts +2 -2
- package/build/video/effects/dissolve.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/dropShadow.d.ts +2 -2
- package/build/video/effects/dropShadow.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/flash.d.ts +2 -2
- package/build/video/effects/flash.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/glow.d.ts +2 -2
- package/build/video/effects/glow.d.ts.map +1 -0
- package/build/video/effects/glsl_realization.d.ts +18 -0
- package/build/video/effects/glsl_realization.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/hologram.d.ts +2 -2
- package/build/video/effects/hologram.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/invert.d.ts +1 -1
- package/build/video/effects/invert.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/outline.d.ts +2 -2
- package/build/video/effects/outline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/pixelate.d.ts +2 -2
- package/build/video/effects/pixelate.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/radialGradient.d.ts +3 -4
- package/build/video/effects/radialGradient.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/scanline.d.ts +2 -2
- package/build/video/effects/scanline.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/sepia.d.ts +1 -1
- package/build/video/effects/sepia.d.ts.map +1 -0
- package/build/video/{webgl → effects}/shadereffect.d.ts +133 -25
- package/build/video/effects/shadereffect.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/shine.d.ts +2 -2
- package/build/video/effects/shine.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/tintPulse.d.ts +2 -2
- package/build/video/effects/tintPulse.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/vignette.d.ts +2 -2
- package/build/video/effects/vignette.d.ts.map +1 -0
- package/build/video/{webgl/effects → effects}/wave.d.ts +2 -2
- package/build/video/effects/wave.d.ts.map +1 -0
- package/build/video/effects/wgsl/layout.d.ts +28 -0
- package/build/video/effects/wgsl/layout.d.ts.map +1 -0
- package/build/video/effects/wgsl/parse.d.ts +9 -0
- package/build/video/effects/wgsl/parse.d.ts.map +1 -0
- package/build/video/effects/wgsl/scaffold.d.ts +43 -0
- package/build/video/effects/wgsl/scaffold.d.ts.map +1 -0
- package/build/video/effects/wgsl_realization.d.ts +83 -0
- package/build/video/effects/wgsl_realization.d.ts.map +1 -0
- package/build/video/gpu/batcher.d.ts +71 -0
- package/build/video/gpu/batcher.d.ts.map +1 -0
- package/build/video/gpu/instancerecord.d.ts +164 -0
- package/build/video/gpu/instancerecord.d.ts.map +1 -0
- package/build/video/gpu/meshchunk.d.ts +49 -0
- package/build/video/gpu/meshchunk.d.ts.map +1 -0
- package/build/video/gpu/meshvertex.d.ts +54 -0
- package/build/video/gpu/meshvertex.d.ts.map +1 -0
- package/build/video/gpu/primitives.d.ts +60 -0
- package/build/video/gpu/primitives.d.ts.map +1 -0
- package/build/video/gpu/quadcorners.d.ts +11 -0
- package/build/video/gpu/quadcorners.d.ts.map +1 -0
- package/build/video/gpu/textureslots.d.ts +122 -0
- package/build/video/gpu/textureslots.d.ts.map +1 -0
- package/build/video/gpu/texturestore.d.ts +139 -0
- package/build/video/gpu/texturestore.d.ts.map +1 -0
- package/build/video/gpu/topology.d.ts +43 -0
- package/build/video/gpu/topology.d.ts.map +1 -0
- package/build/video/gpu/vertexformat.d.ts +72 -0
- package/build/video/gpu/vertexformat.d.ts.map +1 -0
- package/build/video/gradient.d.ts +14 -5
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts +153 -8
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +7 -6
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +2 -2
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
- package/build/video/rendertarget/webglrendertarget.d.ts +38 -2
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/webgpurendertarget.d.ts +83 -0
- package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/texture/cache.d.ts +20 -2
- package/build/video/texture/cache.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +2 -2
- package/build/video/utils/autodetect.d.ts.map +1 -1
- package/build/video/video.d.ts +1 -55
- package/build/video/video.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +132 -35
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +14 -0
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +63 -36
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/material_batcher.d.ts +29 -20
- package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +308 -14
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/primitive_batcher.d.ts +2 -2
- package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +1 -1
- package/build/video/webgl/buffer/instance_buffer.d.ts +54 -0
- package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts +83 -0
- package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgl/buffer/uniformblock.d.ts +81 -0
- package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -0
- package/build/video/webgl/buffer/vertexstate.d.ts +101 -0
- package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts +101 -8
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +20 -8
- package/build/video/webgl/lighting/constants.d.ts.map +1 -1
- package/build/video/webgl/lighting/pack.d.ts +1 -1
- package/build/video/webgl/lighting/pack3d.d.ts +27 -11
- package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
- package/build/video/webgl/lighting/std140.d.ts +110 -0
- package/build/video/webgl/lighting/std140.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +7 -3
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgl/texture/store.d.ts +52 -0
- package/build/video/webgl/texture/store.d.ts.map +1 -0
- package/build/video/webgl/utils/maxtextures.d.ts +37 -0
- package/build/video/webgl/utils/maxtextures.d.ts.map +1 -0
- package/build/video/webgl/utils/samplercache.d.ts +69 -0
- package/build/video/webgl/utils/samplercache.d.ts.map +1 -0
- package/build/video/webgl/utils/string.d.ts +16 -0
- package/build/video/webgl/utils/string.d.ts.map +1 -1
- package/build/video/webgl/utils/topology.d.ts +24 -0
- package/build/video/webgl/utils/topology.d.ts.map +1 -0
- package/build/video/webgl/utils/vertexformat.d.ts +27 -0
- package/build/video/webgl/utils/vertexformat.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +148 -30
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +40 -0
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +82 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +301 -0
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts +39 -0
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts +143 -0
- package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts +70 -0
- package/build/video/webgpu/batchers/webgpu_batcher.d.ts.map +1 -0
- package/build/video/webgpu/buffer/arena.d.ts +64 -0
- package/build/video/webgpu/buffer/arena.d.ts.map +1 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts +65 -0
- package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts +55 -0
- package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -0
- package/build/video/webgpu/buffer/uniformring.d.ts +68 -0
- package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -0
- package/build/video/webgpu/effect_binding.d.ts +17 -0
- package/build/video/webgpu/effect_binding.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts +36 -0
- package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -0
- package/build/video/webgpu/pipeline/cache.d.ts +173 -0
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +90 -0
- package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts +60 -0
- package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -0
- package/build/video/webgpu/texture/compressed.d.ts +33 -0
- package/build/video/webgpu/texture/compressed.d.ts.map +1 -0
- package/build/video/webgpu/texture/frametexture.d.ts +65 -0
- package/build/video/webgpu/texture/frametexture.d.ts.map +1 -0
- package/build/video/webgpu/texture/store.d.ts +149 -0
- package/build/video/webgpu/texture/store.d.ts.map +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts +536 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -0
- package/package.json +2 -2
- package/build/video/webgl/effects/blur.d.ts.map +0 -1
- package/build/video/webgl/effects/chromaticAberration.d.ts.map +0 -1
- package/build/video/webgl/effects/colorMatrix.d.ts.map +0 -1
- package/build/video/webgl/effects/desaturate.d.ts.map +0 -1
- package/build/video/webgl/effects/dissolve.d.ts.map +0 -1
- package/build/video/webgl/effects/dropShadow.d.ts.map +0 -1
- package/build/video/webgl/effects/flash.d.ts.map +0 -1
- package/build/video/webgl/effects/glow.d.ts.map +0 -1
- package/build/video/webgl/effects/hologram.d.ts.map +0 -1
- package/build/video/webgl/effects/invert.d.ts.map +0 -1
- package/build/video/webgl/effects/outline.d.ts.map +0 -1
- package/build/video/webgl/effects/pixelate.d.ts.map +0 -1
- package/build/video/webgl/effects/radialGradient.d.ts.map +0 -1
- package/build/video/webgl/effects/scanline.d.ts.map +0 -1
- package/build/video/webgl/effects/sepia.d.ts.map +0 -1
- package/build/video/webgl/effects/shine.d.ts.map +0 -1
- package/build/video/webgl/effects/tintPulse.d.ts.map +0 -1
- package/build/video/webgl/effects/vignette.d.ts.map +0 -1
- package/build/video/webgl/effects/wave.d.ts.map +0 -1
- package/build/video/webgl/shadereffect.d.ts.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether two axis-aligned 3D boxes collide.
|
|
3
|
+
*
|
|
4
|
+
* This is the only narrowphase in the engine that can produce a **Z**
|
|
5
|
+
* pushback. The separating-axis set of two AABBs is just the three world axes,
|
|
6
|
+
* so there is no projection loop: penetration on each axis is
|
|
7
|
+
* `(halfA + halfB) - |centerDelta|`, a non-positive value on any axis means
|
|
8
|
+
* separated, and the minimum translation vector is the axis with the smallest
|
|
9
|
+
* positive penetration.
|
|
10
|
+
*
|
|
11
|
+
* The MTV is a single axis, so exactly one of `overlapN.x`, `overlapN.y` and
|
|
12
|
+
* `overlapNZ` comes back non-zero — see {@link ResponseObject#overlapNZ}. When
|
|
13
|
+
* that axis is Z the 2D fields stay at zero, which is what makes a legacy 2D
|
|
14
|
+
* `onCollision` handler safely inert on a depth-only contact rather than
|
|
15
|
+
* wrong.
|
|
16
|
+
* @ignore
|
|
17
|
+
* @param {Renderable} a - a reference to the object A.
|
|
18
|
+
* @param {Box3d} boxA - a reference to the object A Box3d to be tested
|
|
19
|
+
* @param {Renderable} b - a reference to the object B.
|
|
20
|
+
* @param {Box3d} boxB - a reference to the object B Box3d to be tested
|
|
21
|
+
* @param {object} [response] - Response object that will be populated if they intersect.
|
|
22
|
+
* @returns {boolean} true if they intersect, false if they don't.
|
|
23
|
+
*/
|
|
24
|
+
export function testBox3dBox3d(a: Renderable, boxA: Box3d, b: Renderable, boxB: Box3d, response?: object): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check whether a {@link Box3d} collides with a planar shape.
|
|
27
|
+
*
|
|
28
|
+
* The planar shape is treated as **unbounded along Z** — an infinitely
|
|
29
|
+
* extruded prism of its own outline — so the pair reduces to the ordinary 2D
|
|
30
|
+
* test between the box's XY footprint and that outline, and the box's z can
|
|
31
|
+
* never make it miss. See {@link Box3d} for why that is the compatible
|
|
32
|
+
* reading: it is what keeps an existing 2D game's world shapes colliding
|
|
33
|
+
* unchanged the moment one `Box3d` body is introduced.
|
|
34
|
+
*
|
|
35
|
+
* `overlapZ` is left at `0` by construction, since neither participant has a
|
|
36
|
+
* finite depth to resolve against.
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
export function testBox3dPolygon(a: any, boxA: any, b: any, polyB: any, response: any): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Planar-shape-first form of {@link testBox3dPolygon}.
|
|
42
|
+
* @ignore
|
|
43
|
+
*/
|
|
44
|
+
export function testPolygonBox3d(a: any, polyA: any, b: any, boxB: any, response: any): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* {@link Box3d} against an {@link Ellipse}, with the ellipse unbounded along
|
|
47
|
+
* Z. See {@link testBox3dPolygon}.
|
|
48
|
+
* @ignore
|
|
49
|
+
*/
|
|
50
|
+
export function testBox3dEllipse(a: any, boxA: any, b: any, ellipseB: any, response: any): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* {@link Ellipse} against a {@link Box3d}, with the ellipse unbounded along
|
|
53
|
+
* Z. See {@link testBox3dPolygon}.
|
|
54
|
+
* @ignore
|
|
55
|
+
*/
|
|
56
|
+
export function testEllipseBox3d(a: any, ellipseA: any, b: any, boxB: any, response: any): boolean;
|
|
57
|
+
import type Renderable from "../../renderable/renderable.js";
|
|
58
|
+
import type { Box3d } from "../../geometries/box3d.ts";
|
|
59
|
+
//# sourceMappingURL=sat3d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sat3d.d.ts","sourceRoot":"","sources":["../../../src/physics/builtin/sat3d.js"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,kCAPW,UAAU,QACV,KAAK,KACL,UAAU,QACV,KAAK,aACL,MAAM,GACJ,OAAO,CA6EnB;AAED;;;;;;;;;;;;;GAaG;AACH,gGAEC;AAED;;;GAGG;AACH,gGAEC;AAED;;;;GAIG;AACH,mGAEC;AAED;;;;GAIG;AACH,mGAEC;4BAtK0B,gCAAgC;2BAHnC,2BAA2B"}
|
|
@@ -23,6 +23,14 @@ export type ResponseObject = {
|
|
|
23
23
|
* The shortest colliding axis (unit-vector)
|
|
24
24
|
*/
|
|
25
25
|
overlapN: Vector2d;
|
|
26
|
+
/**
|
|
27
|
+
* The Z component of the shortest colliding axis, as a unit scalar (`-1`, `0` or `1`). Always `0` for a collision between planar shapes
|
|
28
|
+
*/
|
|
29
|
+
overlapNZ: number;
|
|
30
|
+
/**
|
|
31
|
+
* The Z component of the overlap vector (i.e. `overlapNZ * overlap`). Always `0` for a collision between planar shapes
|
|
32
|
+
*/
|
|
33
|
+
overlapZ: number;
|
|
26
34
|
/**
|
|
27
35
|
* Whether the first object is entirely inside the second
|
|
28
36
|
*/
|
|
@@ -48,6 +56,8 @@ export type ResponseObject = {
|
|
|
48
56
|
* @property {number} overlap Magnitude of the overlap on the shortest colliding axis
|
|
49
57
|
* @property {Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
|
|
50
58
|
* @property {Vector2d} overlapN The shortest colliding axis (unit-vector)
|
|
59
|
+
* @property {number} overlapNZ The Z component of the shortest colliding axis, as a unit scalar (`-1`, `0` or `1`). Always `0` for a collision between planar shapes
|
|
60
|
+
* @property {number} overlapZ The Z component of the overlap vector (i.e. `overlapNZ * overlap`). Always `0` for a collision between planar shapes
|
|
51
61
|
* @property {boolean} aInB Whether the first object is entirely inside the second
|
|
52
62
|
* @property {boolean} bInA Whether the second object is entirely inside the first
|
|
53
63
|
* @property {number} indexShapeA The index of the colliding shape for the object a body
|
|
@@ -58,10 +68,32 @@ declare class ResponseObject {
|
|
|
58
68
|
b: any;
|
|
59
69
|
overlapN: Vector2d;
|
|
60
70
|
overlapV: Vector2d;
|
|
71
|
+
/**
|
|
72
|
+
* Z half of the minimum translation axis.
|
|
73
|
+
*
|
|
74
|
+
* Z arrives as **scalars beside** `overlapN` / `overlapV` rather than
|
|
75
|
+
* by widening them to {@link Vector3d}, because `Vector3d` is not a
|
|
76
|
+
* subclass of {@link Vector2d} — retyping them would break every
|
|
77
|
+
* existing consumer of a 2D collision response.
|
|
78
|
+
*
|
|
79
|
+
* The minimum translation axis is a single axis, so at most one of
|
|
80
|
+
* `overlapN.x`, `overlapN.y` and `overlapNZ` is ever non-zero. The 2D
|
|
81
|
+
* invariant `overlapV = overlapN * overlap` therefore extends
|
|
82
|
+
* unchanged as `overlapZ = overlapNZ * overlap`, and a collision
|
|
83
|
+
* resolved along Z leaves `overlapN` / `overlapV` at zero — a legacy
|
|
84
|
+
* 2D handler reading them applies no push, which is correct, because
|
|
85
|
+
* there is no 2D push to apply.
|
|
86
|
+
*
|
|
87
|
+
* Only ever non-zero when both shapes are a {@link Box3d}; every
|
|
88
|
+
* planar shape pair leaves these at `0`.
|
|
89
|
+
*/
|
|
90
|
+
overlapNZ: number;
|
|
91
|
+
overlapZ: number;
|
|
61
92
|
aInB: boolean;
|
|
62
93
|
bInA: boolean;
|
|
63
94
|
indexShapeA: number;
|
|
64
95
|
indexShapeB: number;
|
|
96
|
+
isTriggerContact: boolean;
|
|
65
97
|
overlap: number;
|
|
66
98
|
/**
|
|
67
99
|
* Set some values of the response back to their defaults. <br>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/physics/response.js"],"names":[],"mappings":";;;;;;;;OAKc,UAAU;;;;OACV,UAAU;;;;aACV,MAAM;;;;cACN,QAAQ;;;;cACR,QAAQ;;;;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/physics/response.js"],"names":[],"mappings":";;;;;;;;OAKc,UAAU;;;;OACV,UAAU;;;;aACV,MAAM;;;;cACN,QAAQ;;;;cACR,QAAQ;;;;eACR,MAAM;;;;cACN,MAAM;;;;UACN,OAAO;;;;UACP,OAAO;;;;iBACP,MAAM;;;;iBACN,MAAM;;AAbpB;;;;;;;;;;;;;;GAcG;AACH;IAEE,OAAa;IACb,OAAa;IACb,mBAA8B;IAC9B,mBAA8B;IAC9B;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB;IAClB,iBAAiB;IACjB,cAAgB;IAChB,cAAgB;IAChB,oBAAqB;IACrB,oBAAqB;IACrB,0BAA6B;IAC7B,gBAA+B;IAGhC;;;;;;;;OAQG;IACH,gBAFa,MAAM,CAelB;CACD;yBA3EwB,qBAAqB"}
|
package/build/physics/world.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ export default class World extends Container {
|
|
|
100
100
|
* @type {import("./broadphase/broadphase.ts").Broadphase}
|
|
101
101
|
*/
|
|
102
102
|
broadphase: import("./broadphase/broadphase.ts").Broadphase;
|
|
103
|
+
onLevelLoaded: () => void;
|
|
103
104
|
/**
|
|
104
105
|
* Active physics bodies in this simulation. Backed by the active
|
|
105
106
|
* adapter; mutating this set directly is no longer the recommended
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/physics/world.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"world.d.ts","sourceRoot":"","sources":["../../src/physics/world.js"],"names":[],"mappings":"AA8BA;;;GAGG;AACH;IACC;;;;;;OAMG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,YACN,cAAc,EAuIxB;IArHA;;;OAGG;IACH,KAFU,WAAW,CAED;IAEpB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QANU,MAAM,CAMO;IAEvB;;;;;OAKG;IACH,YAAa;IAEb;;;;;;;OAOG;IACH,WAHU,OAAO,CAGK;IAEtB;;;;;;;;;;;;;;OAcG;IACH,YAHU,OAAO,CAGK;IAEtB;;;;;;OAMG;IACH,SAFU,cAAc,CAEsB;IAG9C;;;;;;;;;;;;;;;OAeG;IACH,YAFU,OAAO,4BAA4B,EAAE,UAAU,CAEjB;IAcxC,0BAMC;IA2CF;;;;;;;;;;;OAWG;IACH,cAFa,GAAG,CAAC,IAAI,CAAC,CAOrB;IASD,eALa,QAAQ,EAOpB;IATD;;;OAGG;IACH,eAFa,QAAQ,CAIpB;IAKD;;;;OAIG;IACH,gBAFa,QAAQ,GAAG,SAAS,CAIhC;IAsCD;;;;;;;OAOG;IACH,cAHW,IAAI,GACF,KAAK,CASjB;IAED;;;;;OAKG;IACH,iBAHW,IAAI,GACF,KAAK,CASjB;IAED;;;;;OAKG;IACH,yBAIC;IAuBD;;;OAGG;IACH,SAFW,MAAM,QAWhB;CACD;sBAjXqB,4BAA4B;6BAatB,iCAAiC;oCAI1B,cAAc;sBAH5B,mBAAmB;8BAEX,qBAAqB;0BADzB,uBAAuB"}
|
|
@@ -104,6 +104,7 @@ export default class Container extends Renderable {
|
|
|
104
104
|
* this.backgroundColor.setColor(255, 0, 0);
|
|
105
105
|
*/
|
|
106
106
|
backgroundColor: Color;
|
|
107
|
+
onCanvasResize: (() => void) | undefined;
|
|
107
108
|
set sortOn(value: "x" | "y" | "z" | "depth");
|
|
108
109
|
/**
|
|
109
110
|
* The property of the child object that should be used to sort on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/renderable/container.js"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;GASG;AACH;IACC;;;;;;;OAOG;IACH,gBAPW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,SACN,OAAO,
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/renderable/container.js"],"names":[],"mappings":"AA8GA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;GASG;AACH;IACC;;;;;;;OAOG;IACH,gBAPW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,SACN,OAAO,EA+GjB;IAxGA;;;OAGG;IACH,iBAAuB;IAEvB;;;;OAIG;IACH,MAHU,OAAO,CAGD;IAEhB;;;OAGG;IACH,4BAAyB;IAEzB;;;;;OAKG;IACH,SAHU,MAAM,CAGE;IAClB,wCAA8B;IAE9B;;;;OAIG;IACH,UAHU,OAAO,CAGG;IAEpB;;;;OAIG;IACH,WAHU,OAAO,CAGI;IAErB;;;;OAIG;IACH,UAHU,OAAO,CAGI;IAErB;;;OAGG;IACH,0BAEC;IAED;;;;;;OAMG;IACH,yBAHU,OAAO,CAGmB;IAEpC;;;;;;;OAOG;IACH,iBANU,KAAK,CAMmC;IAqBjD,yCAMC;IAiCH,kBANU,GAAG,GAAC,GAAG,GAAC,GAAG,GAAC,OAAO,EAm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;;;;;;OAQG;IACH,oBAFW,OAAO,QAoBjB;IAgBD;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,sCAEC;IAED;;;;;;;;;;;;;;;OAeG;IACH,mCAiBC;IAED;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,+BAEC;CA0KD;uBA7uCsB,iBAAiB;2BAyGhB,oBAAoB;wBACrB,oBAAoB;wBACpB,aAAa;6BACR,kBAAkB;yBACtB,cAAc;+BACR,gBAAgB;gCACf,gBAAgB;iCACf,sBAAsB;4BAC3B,iBAAiB;4BACjB,iBAAiB;+BAEd,uBAAuB;iCACrB,yBAAyB;8BAC5B,sBAAsB;sBAC9B,gBAAgB;4BACV,sBAAsB;4BACxB,wBAAwB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bake (once) a radial alpha ramp: opaque white at the centre, fading to
|
|
3
|
+
* fully transparent at the rim.
|
|
4
|
+
*
|
|
5
|
+
* White rather than black because the colour comes from the draw tint — that
|
|
6
|
+
* way the same bake serves a black shadow, a tinted one, or a coloured pool
|
|
7
|
+
* of light, and nothing has to be re-baked to change it.
|
|
8
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas} the shared falloff canvas
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export function getShadowFalloff(): HTMLCanvasElement | OffscreenCanvas;
|
|
12
|
+
/**
|
|
13
|
+
* Drop the shared bake. Only the tests need this — the canvas is CPU-side and
|
|
14
|
+
* costs 64 KB, so an application never has a reason to release it.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export function resetShadowFalloff(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a mesh's geometry has any vertical extent at all.
|
|
20
|
+
*
|
|
21
|
+
* The test a **blanket** opt-in needs: a ground shadow says "this object is
|
|
22
|
+
* standing above the floor", and a flat plane lying in the floor is the floor.
|
|
23
|
+
* Shadowing it with itself smears a blob the size of the whole ground across
|
|
24
|
+
* it, which is what a scene-wide `castGroundShadow` would otherwise do to
|
|
25
|
+
* every glTF scene that ships one. A per-object opt-in bypasses this — that
|
|
26
|
+
* one is an explicit instruction.
|
|
27
|
+
*
|
|
28
|
+
* Deliberately model-space and unrotated: the caller asks about the geometry,
|
|
29
|
+
* not about where it currently sits.
|
|
30
|
+
* @param {Float32Array} vertices - model-space vertex positions (x, y, z)
|
|
31
|
+
* @param {number} vertexCount - how many vertices to read
|
|
32
|
+
* @returns {boolean} true when the geometry is not flat in Y
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
export function hasVerticalExtent(vertices: Float32Array, vertexCount: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Borrow the shadow quad for a renderer, building it on first use.
|
|
38
|
+
*
|
|
39
|
+
* Cached **on the renderer**, not at module level, for two reasons: a `Mesh`
|
|
40
|
+
* resolves its texture through the active renderer's texture cache, so a
|
|
41
|
+
* module-level one would bind itself to whichever application happened to
|
|
42
|
+
* construct it first; and hanging it off the renderer means it dies with the
|
|
43
|
+
* renderer instead of outliving it.
|
|
44
|
+
*
|
|
45
|
+
* Two are kept — lit and unlit — so the shadow can be drawn through whichever
|
|
46
|
+
* mesh batcher its owner is already using. Sharing one unlit quad between lit
|
|
47
|
+
* owners would force a `litMesh → mesh → litMesh` batcher transition per
|
|
48
|
+
* shadowed object, each costing a bind/unbind pair and a flush: far more than
|
|
49
|
+
* the single draw the shadow is supposed to be.
|
|
50
|
+
*
|
|
51
|
+
* Retained geometry is keyed per mesh object, so one quad uploads once and
|
|
52
|
+
* every shadow in the scene redraws it at a different matrix for free.
|
|
53
|
+
* @param {object} renderer - the active renderer
|
|
54
|
+
* @param {boolean} lit - whether the owning mesh draws lit
|
|
55
|
+
* @param {Function} MeshClass - the `Mesh` constructor (passed in to avoid a
|
|
56
|
+
* circular import: `Mesh` owns the shadow, not the other way round)
|
|
57
|
+
* @returns {object} the shared shadow quad for that tier
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
export function getShadowQuad(renderer: object, lit: boolean, MeshClass: Function): object;
|
|
61
|
+
/**
|
|
62
|
+
* The blob quad an `InstancedMesh` draws from — sized to the prototype's own
|
|
63
|
+
* footprint (#1515).
|
|
64
|
+
*
|
|
65
|
+
* The shared quad is a unit square, and the instanced vertex stage scales it by
|
|
66
|
+
* each record's horizontal scale alone. That silently assumes the prototype
|
|
67
|
+
* geometry is exactly 1 unit across, which is true of almost nothing: glTF
|
|
68
|
+
* meshes load with `normalize: false` and keep their authored size, so a tree
|
|
69
|
+
* 3 units wide got a blob sized for a 1-unit tree. It also skipped the contact
|
|
70
|
+
* spread and the minor-axis floor the per-object tier applies, so the SAME
|
|
71
|
+
* asset drew a different shadow depending on whether it was instanced.
|
|
72
|
+
*
|
|
73
|
+
* Baking the extents into four vertices fixes it with no shader change and no
|
|
74
|
+
* per-draw uniform: retained geometry is keyed per mesh object, so this uploads
|
|
75
|
+
* once per `InstancedMesh` and is redrawn for free.
|
|
76
|
+
* @param {object} mesh - the InstancedMesh casting the shadows
|
|
77
|
+
* @param {Function} MeshClass - the `Mesh` constructor (avoids a circular import)
|
|
78
|
+
* @param {number} halfX - model-space half-extent along X, spread applied
|
|
79
|
+
* @param {number} halfZ - model-space half-extent along Z, spread applied
|
|
80
|
+
* @param {number} version - the prototype's geometry version
|
|
81
|
+
* @returns {object} the quad to draw this scatter's blobs from
|
|
82
|
+
* @ignore
|
|
83
|
+
*/
|
|
84
|
+
export function getInstancedShadowQuad(mesh: object, MeshClass: Function, halfX: number, halfZ: number, version: number): object;
|
|
85
|
+
/**
|
|
86
|
+
* Release the shadow quads a renderer built, if any. Called from renderer
|
|
87
|
+
* teardown so the retained GPU geometry goes with it.
|
|
88
|
+
* @param {object} renderer - the renderer being torn down
|
|
89
|
+
* @ignore
|
|
90
|
+
*/
|
|
91
|
+
export function releaseShadowQuads(renderer: object): void;
|
|
92
|
+
//# sourceMappingURL=groundshadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groundshadow.d.ts","sourceRoot":"","sources":["../../src/renderable/groundshadow.js"],"names":[],"mappings":"AAyCA;;;;;;;;;GASG;AACH,oCAHa,iBAAiB,GAAC,eAAe,CAsC7C;AAED;;;;GAIG;AACH,2CAEC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,4CALW,YAAY,eACZ,MAAM,GACJ,OAAO,CA8BnB;AAiBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wCAPW,MAAM,OACN,OAAO,wBAGL,MAAM,CAiClB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,6CARW,MAAM,8BAEN,MAAM,SACN,MAAM,WACN,MAAM,GACJ,MAAM,CAsClB;AAED;;;;;GAKG;AACH,6CAHW,MAAM,QAUhB"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A {@link Mesh} drawn many times from one copy of its geometry.
|
|
3
|
+
*
|
|
4
|
+
* Ordinary meshes pay for every repeat: a forest of five thousand trees is
|
|
5
|
+
* five thousand geometries on the GPU, each re-uploaded when it changes. An
|
|
6
|
+
* `InstancedMesh` uploads the geometry **once** and stamps out copies from a
|
|
7
|
+
* small per-instance record, so cost scales with the number of instances
|
|
8
|
+
* rather than with `instances × vertices`, and the whole thing draws in a
|
|
9
|
+
* single call.
|
|
10
|
+
*
|
|
11
|
+
* Every `Mesh` setting works unchanged — `model` + `material` from an OBJ,
|
|
12
|
+
* raw `vertices`/`uvs`/`indices`, `lit`, `cullBackFaces`, `rightHanded`,
|
|
13
|
+
* `tint`, `textureRepeat`, the lot. What an instanced mesh adds is the
|
|
14
|
+
* instance buffer:
|
|
15
|
+
*
|
|
16
|
+
* - a **transform** per instance, always present;
|
|
17
|
+
* - a **colour** per instance, when `instanceColors` is declared, multiplied
|
|
18
|
+
* into the mesh tint;
|
|
19
|
+
* - an opaque **`vec4`** per instance, when `instanceData` is declared. The
|
|
20
|
+
* built-in lit shading reads its `rgb` as emissive; a custom
|
|
21
|
+
* {@link Mesh#shader} may read it as a wind phase, an atlas offset, a
|
|
22
|
+
* random seed — whatever the shader wants.
|
|
23
|
+
*
|
|
24
|
+
* The mesh's own position, rotation and scale keep their ordinary meaning and
|
|
25
|
+
* act as the **group** transform: moving an `InstancedMesh` moves every
|
|
26
|
+
* instance with one uniform write and re-uploads nothing.
|
|
27
|
+
*
|
|
28
|
+
* Requires a GPU backend (`renderer.supportsInstancing`). Under the Canvas
|
|
29
|
+
* renderer the instances are drawn one at a time through the ordinary CPU
|
|
30
|
+
* mesh path — correct, but without any of the benefit.
|
|
31
|
+
* @augments Mesh
|
|
32
|
+
* @category Rendering
|
|
33
|
+
* @example
|
|
34
|
+
* const forest = new me.InstancedMesh(0, 0, {
|
|
35
|
+
* model: "tree",
|
|
36
|
+
* material: "tree",
|
|
37
|
+
* width: 64,
|
|
38
|
+
* lit: true,
|
|
39
|
+
* instanceCount: 5000, // pre-allocate
|
|
40
|
+
* instanceColors: true,
|
|
41
|
+
* instanceData: true,
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const placement = new me.Matrix3d(); // one scratch — zero allocation
|
|
45
|
+
* for (let i = 0; i < forest.instanceCount; i++) {
|
|
46
|
+
* placement.identity().translate(x, y, z).scale(s);
|
|
47
|
+
* forest.setInstance(i, placement);
|
|
48
|
+
* forest.setInstanceColor(i, autumnTint);
|
|
49
|
+
* forest.setInstanceData(i, windPhase, seed, 0, 0);
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // draw only the nearest 1200 — no re-upload, just a smaller draw
|
|
53
|
+
* forest.visibleInstanceCount = 1200;
|
|
54
|
+
* app.world.addChild(forest, 10);
|
|
55
|
+
*/
|
|
56
|
+
export default class InstancedMesh extends Mesh {
|
|
57
|
+
/**
|
|
58
|
+
* @param {number} x - the x coordinate of the group origin
|
|
59
|
+
* @param {number} y - the y coordinate of the group origin
|
|
60
|
+
* @param {object} settings - every {@link Mesh} setting, plus those below
|
|
61
|
+
* @param {number} [settings.instanceCount=0] - number of instances to pre-allocate. Instances start at the group origin (identity transform) until placed; `addInstance` grows past this.
|
|
62
|
+
* @param {boolean} [settings.instanceColors=false] - give each instance its own colour (16 bytes per instance), multiplied into the mesh tint
|
|
63
|
+
* @param {boolean} [settings.instanceData=false] - give each instance an opaque `vec4` (16 bytes per instance). Read as emissive by the built-in lit shading, or as anything at all by a custom mesh shader.
|
|
64
|
+
*/
|
|
65
|
+
constructor(x: number, y: number, settings: {
|
|
66
|
+
instanceCount?: number | undefined;
|
|
67
|
+
instanceColors?: boolean | undefined;
|
|
68
|
+
instanceData?: boolean | undefined;
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* How this mesh's per-instance records are laid out — record width and
|
|
72
|
+
* the offset of each opt-in slot. Consumed by the batchers to describe
|
|
73
|
+
* the instance vertex buffer.
|
|
74
|
+
* @type {object}
|
|
75
|
+
* @ignore
|
|
76
|
+
*/
|
|
77
|
+
instanceLayout: object;
|
|
78
|
+
/**
|
|
79
|
+
* The packed instance records, `instanceLayout.floats` per instance.
|
|
80
|
+
* Editable in place for bulk updates — announce those with
|
|
81
|
+
* {@link InstancedMesh#needsInstanceUpdate} or
|
|
82
|
+
* {@link InstancedMesh#markInstancesDirty}, since writing here bypasses
|
|
83
|
+
* the setters that track the dirty range.
|
|
84
|
+
* @type {Float32Array}
|
|
85
|
+
*/
|
|
86
|
+
instanceBuffer: Float32Array;
|
|
87
|
+
/**
|
|
88
|
+
* bumped whenever the buffer is reallocated, so a renderer holding a
|
|
89
|
+
* GPU copy knows its capacity assumption is stale
|
|
90
|
+
* @type {number}
|
|
91
|
+
* @ignore
|
|
92
|
+
*/
|
|
93
|
+
_instanceVersion: number;
|
|
94
|
+
/** @ignore */
|
|
95
|
+
_instanceRevision: number;
|
|
96
|
+
/** @ignore */
|
|
97
|
+
_spanFromRevision: number;
|
|
98
|
+
/** @ignore */
|
|
99
|
+
_dirtyFirst: number;
|
|
100
|
+
/** @ignore */
|
|
101
|
+
_dirtyLast: number;
|
|
102
|
+
/** @ignore */
|
|
103
|
+
_instanceCount: number;
|
|
104
|
+
/** @ignore */
|
|
105
|
+
_visibleInstanceCount: number;
|
|
106
|
+
/** @ignore */
|
|
107
|
+
_cullRevision: number;
|
|
108
|
+
set instanceCount(count: number);
|
|
109
|
+
/**
|
|
110
|
+
* How many instances this mesh holds.
|
|
111
|
+
*
|
|
112
|
+
* Growing pre-allocates the new records as identity transforms (an
|
|
113
|
+
* unplaced instance sits at the group origin rather than collapsing onto
|
|
114
|
+
* a zero matrix); shrinking keeps the allocation, so a count that
|
|
115
|
+
* oscillates does not thrash it.
|
|
116
|
+
* @type {number}
|
|
117
|
+
*/
|
|
118
|
+
get instanceCount(): number;
|
|
119
|
+
set visibleInstanceCount(count: number);
|
|
120
|
+
/**
|
|
121
|
+
* How many instances are actually drawn, counted from the first.
|
|
122
|
+
*
|
|
123
|
+
* The cheap culling and level-of-detail knob: sort the instances by
|
|
124
|
+
* distance once, then draw fewer of them by moving this single number —
|
|
125
|
+
* no re-upload, no rebuild. Defaults to every instance (`-1`).
|
|
126
|
+
* @type {number}
|
|
127
|
+
* @example
|
|
128
|
+
* forest.visibleInstanceCount = playerIsIndoors ? 0 : 1200;
|
|
129
|
+
*/
|
|
130
|
+
get visibleInstanceCount(): number;
|
|
131
|
+
/**
|
|
132
|
+
* Append an instance, growing the buffer as needed.
|
|
133
|
+
* @param {Matrix3d} [transform] - where this instance sits, relative to the group. Defaults to the group origin.
|
|
134
|
+
* @param {object} [options] - optional per-instance slots
|
|
135
|
+
* @param {Color} [options.color] - instance colour (requires `instanceColors`)
|
|
136
|
+
* @param {number[]} [options.data] - four numbers for the custom slot (requires `instanceData`)
|
|
137
|
+
* @returns {number} the new instance's index
|
|
138
|
+
*/
|
|
139
|
+
addInstance(transform?: Matrix3d, options?: {
|
|
140
|
+
color?: any;
|
|
141
|
+
data?: number[] | undefined;
|
|
142
|
+
}): number;
|
|
143
|
+
/**
|
|
144
|
+
* Remove an instance by moving the last one into its place.
|
|
145
|
+
*
|
|
146
|
+
* Swapping is what keeps this O(1) instead of shifting every record after
|
|
147
|
+
* the hole — but it means **indices are not stable across a removal**: the
|
|
148
|
+
* instance that was last now answers to `index`. Callers holding indices
|
|
149
|
+
* must re-read them, or avoid removal in favour of
|
|
150
|
+
* {@link InstancedMesh#visibleInstanceCount}.
|
|
151
|
+
* @param {number} index - the instance to remove
|
|
152
|
+
*/
|
|
153
|
+
removeInstance(index: number): void;
|
|
154
|
+
/**
|
|
155
|
+
* Place one instance.
|
|
156
|
+
* @param {number} index - the instance to place
|
|
157
|
+
* @param {Matrix3d} transform - where it sits, relative to the group
|
|
158
|
+
*/
|
|
159
|
+
setInstance(index: number, transform: Matrix3d): void;
|
|
160
|
+
/**
|
|
161
|
+
* Read one instance's transform back.
|
|
162
|
+
* @param {number} index - the instance to read
|
|
163
|
+
* @param {Matrix3d} [out] - matrix to write into; a new one is allocated when omitted
|
|
164
|
+
* @returns {Matrix3d|undefined} the transform, or `undefined` for an out-of-range index
|
|
165
|
+
*/
|
|
166
|
+
getInstance(index: number, out?: Matrix3d): Matrix3d | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* Set one instance's colour, multiplied into the mesh tint.
|
|
169
|
+
* @param {number} index - the instance to colour
|
|
170
|
+
* @param {Color} color - the instance colour
|
|
171
|
+
*/
|
|
172
|
+
setInstanceColor(index: number, color: Color): void;
|
|
173
|
+
/**
|
|
174
|
+
* Set one instance's custom `vec4`.
|
|
175
|
+
* @param {number} index - the instance to write
|
|
176
|
+
* @param {number} x - first component (emissive red, under the built-in lit shading)
|
|
177
|
+
* @param {number} y - second component
|
|
178
|
+
* @param {number} z - third component
|
|
179
|
+
* @param {number} [w=0] - fourth component
|
|
180
|
+
*/
|
|
181
|
+
setInstanceData(index: number, x: number, y: number, z: number, w?: number): void;
|
|
182
|
+
/**
|
|
183
|
+
* Announce that a span of instances was edited directly through
|
|
184
|
+
* {@link InstancedMesh#instanceBuffer}, so the next draw re-uploads it.
|
|
185
|
+
* The per-instance setters do this themselves.
|
|
186
|
+
* @param {number} first - first instance changed
|
|
187
|
+
* @param {number} count - how many
|
|
188
|
+
*/
|
|
189
|
+
markInstancesDirty(first: number, count: number): void;
|
|
190
|
+
/**
|
|
191
|
+
* Announce that the whole instance buffer was edited in place. The
|
|
192
|
+
* instancing counterpart of {@link Mesh#needsUpdate} — and, like it, a
|
|
193
|
+
* signal rather than a state, so it is write-only.
|
|
194
|
+
* @type {boolean}
|
|
195
|
+
* @example
|
|
196
|
+
* forest.instanceBuffer.set(myRecords);
|
|
197
|
+
* forest.needsInstanceUpdate = true;
|
|
198
|
+
*/
|
|
199
|
+
set needsInstanceUpdate(value: any);
|
|
200
|
+
/**
|
|
201
|
+
* The dirty span, in floats, as `[first, lastExclusive)`. Empty when
|
|
202
|
+
* nothing changed since the last upload.
|
|
203
|
+
* @returns {number[]} the span
|
|
204
|
+
* @ignore
|
|
205
|
+
*/
|
|
206
|
+
dirtyRange(): number[];
|
|
207
|
+
/**
|
|
208
|
+
* What one GPU buffer must upload to catch up, given the revision it last
|
|
209
|
+
* reached. Replaces a shared "clear the dirty flag" step, which the first
|
|
210
|
+
* consumer would drain out from under the second.
|
|
211
|
+
* @param {number} uploadedRevision - the revision that buffer holds
|
|
212
|
+
* @returns {object} `{first, count, full, revision}` — float span, or `full`
|
|
213
|
+
* @ignore
|
|
214
|
+
*/
|
|
215
|
+
instanceUpload(uploadedRevision: number): object;
|
|
216
|
+
/**
|
|
217
|
+
* Called by the batcher once the dirty span has been uploaded.
|
|
218
|
+
* @ignore
|
|
219
|
+
*/
|
|
220
|
+
clearInstanceDirty(): void;
|
|
221
|
+
/**
|
|
222
|
+
* The world-space bounding box of every instance, so the whole group
|
|
223
|
+
* frustum-culls as one object.
|
|
224
|
+
*
|
|
225
|
+
* Bounds the prototype geometry through each instance transform and then
|
|
226
|
+
* through the group placement — correct before the first draw, like the
|
|
227
|
+
* base implementation, and independent of what any draw left behind.
|
|
228
|
+
* @returns {AABB3d} the union of all instance bounds (reused instance)
|
|
229
|
+
*/
|
|
230
|
+
/**
|
|
231
|
+
* Resize the renderable's own 2D bounds box so it encloses every
|
|
232
|
+
* instance.
|
|
233
|
+
*
|
|
234
|
+
* This is what makes the group frustum-cull correctly. `Camera3d.isVisible`
|
|
235
|
+
* tests a sphere derived from `getBounds()` — the flat width/height box —
|
|
236
|
+
* **not** {@link InstancedMesh#getBounds3d}. Left at the prototype's size,
|
|
237
|
+
* a forest scattered over thousands of units presents a box a few tens of
|
|
238
|
+
* pixels across at the group origin: pan the camera just past that origin
|
|
239
|
+
* and every instance disappears at once, while still on screen.
|
|
240
|
+
* @ignore
|
|
241
|
+
*/
|
|
242
|
+
_refreshCullVolume(): any;
|
|
243
|
+
_cullRadius: number | undefined;
|
|
244
|
+
/**
|
|
245
|
+
* Draw the instanced mesh. Under a GPU backend this is one instanced
|
|
246
|
+
* draw call; the Canvas renderer has no instancing, so each instance is
|
|
247
|
+
* drawn through the ordinary mesh path instead.
|
|
248
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - a renderer instance
|
|
249
|
+
* @param {Camera2d} [viewport] - the camera rendering this frame
|
|
250
|
+
*/
|
|
251
|
+
draw(renderer: CanvasRenderer | WebGLRenderer, viewport?: Camera2d): void;
|
|
252
|
+
/**
|
|
253
|
+
* Fallback for renderers without instancing (Canvas): walk the instances
|
|
254
|
+
* and draw the prototype once per instance, composing the group and
|
|
255
|
+
* instance transforms by hand. Correct, and as slow as the uninstanced
|
|
256
|
+
* scene it replaces — the point is that a scene authored for instancing
|
|
257
|
+
* still renders everywhere.
|
|
258
|
+
* @param {CanvasRenderer} renderer - a renderer instance
|
|
259
|
+
* @param {Camera2d} [viewport] - the camera rendering this frame
|
|
260
|
+
* @ignore
|
|
261
|
+
*/
|
|
262
|
+
_drawInstancesIndividually(renderer: CanvasRenderer, viewport?: Camera2d): void;
|
|
263
|
+
/**
|
|
264
|
+
* Release the instance records along with the mesh.
|
|
265
|
+
* @ignore
|
|
266
|
+
*/
|
|
267
|
+
/**
|
|
268
|
+
* Draw a ground shadow for every visible instance — one call for the whole
|
|
269
|
+
* set, over the instance buffer the mesh itself just drew from (#1515).
|
|
270
|
+
*
|
|
271
|
+
* The group matrix is passed with its Y basis column zeroed and its
|
|
272
|
+
* translation Y set to the ground, so whatever Y the shadow vertex stage
|
|
273
|
+
* produces is flattened onto the floor. That is what lets the ground
|
|
274
|
+
* height reach the shader without a new uniform.
|
|
275
|
+
*
|
|
276
|
+
* One ground height serves the whole set — flat terrain. Per-instance
|
|
277
|
+
* ground height would have to ride the `instanceData` slot, which the
|
|
278
|
+
* built-in shading already reads as emissive.
|
|
279
|
+
* @param {WebGLRenderer} renderer - the active renderer
|
|
280
|
+
* @ignore
|
|
281
|
+
*/
|
|
282
|
+
_drawInstancedGroundShadow(renderer: WebGLRenderer): void;
|
|
283
|
+
}
|
|
284
|
+
import Mesh from "./mesh.js";
|
|
285
|
+
import { Matrix3d } from "../math/matrix3d.ts";
|
|
286
|
+
//# sourceMappingURL=instanced_mesh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanced_mesh.d.ts","sourceRoot":"","sources":["../../src/renderable/instanced_mesh.js"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH;IACC;;;;;;;OAOG;IACH,eAPW,MAAM,KACN,MAAM,YAEd;QAA0B,aAAa;QACZ,cAAc;QACd,YAAY;KACzC,EAiEA;IA7DA;;;;;;OAMG;IACH,gBAHU,MAAM,CAMf;IAED;;;;;;;OAOG;IACH,gBAFU,YAAY,CAEmB;IAEzC;;;;;OAKG;IACH,kBAHU,MAAM,CAGS;IAUzB,cAAc;IACd,0BAA0B;IAG1B,cAAc;IACd,0BAA0B;IAE1B,cAAc;IACd,oBAA2B;IAC3B,cAAc;IACd,mBAAmB;IAEnB,cAAc;IACd,uB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