melonjs 20.4.0 → 20.5.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/build/audio/backend/sound.d.ts.map +1 -1
- package/build/audio/procedural.d.ts +7 -2
- package/build/audio/procedural.d.ts.map +1 -1
- package/build/audio/types.d.ts +22 -0
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +28 -0
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +24 -3
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +7 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1061 -166
- package/build/index.js.map +4 -4
- package/build/level/gltf/GLTFModel.d.ts +50 -7
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +20 -47
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +106 -6
- package/build/loader/loader.d.ts.map +1 -1
- package/build/renderable/animation.d.ts +21 -6
- package/build/renderable/animation.d.ts.map +1 -1
- package/build/renderable/container.d.ts +27 -5
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +34 -9
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +131 -94
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +17 -0
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite3d.d.ts +12 -2
- package/build/renderable/sprite3d.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +32 -7
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +78 -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/text/textstyle.d.ts.map +1 -1
- package/build/state/stage.d.ts +21 -0
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/device.d.ts +1 -1
- package/build/system/device.d.ts.map +1 -1
- package/build/system/save.d.ts +44 -1
- package/build/system/save.d.ts.map +1 -1
- package/build/video/effects/glsl_realization.d.ts.map +1 -1
- package/build/video/effects/mesh_splice.d.ts +2 -0
- package/build/video/effects/mesh_splice.d.ts.map +1 -0
- package/build/video/effects/shadereffect.d.ts +12 -128
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/effects/wgsl_realization.d.ts.map +1 -1
- package/build/video/gradient.d.ts +19 -0
- package/build/video/gradient.d.ts.map +1 -1
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/texture/noise_texture2d.d.ts +101 -34
- package/build/video/texture/noise_texture2d.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/glshader.d.ts +7 -2
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts +6 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-3d/SKILL.md +152 -3
- package/skills/melonjs-3d-assets/SKILL.md +139 -0
- package/skills/melonjs-audio/SKILL.md +17 -0
- package/skills/melonjs-camera-and-drawing/SKILL.md +45 -0
- package/skills/melonjs-effects-and-shaders/SKILL.md +93 -1
- package/skills/melonjs-loading-assets/SKILL.md +97 -1
- package/skills/melonjs-performance/SKILL.md +55 -1
- package/skills/melonjs-physics/SKILL.md +78 -0
- package/skills/melonjs-renderables/SKILL.md +63 -1
- package/skills/melonjs-renderer-backends/SKILL.md +19 -0
- package/skills/melonjs-scenes-and-state/SKILL.md +56 -0
- package/skills/melonjs-ui-and-text/SKILL.md +124 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_renderer.js"],"names":[],"mappings":"AA6GA;;;GAGG;AACH;IAQE;;;;;OAKG;IACH,oBAJU,MAAM,CAIU;IAU1B;;;OAGG;IACH,IAFU,qBAAqB,CAEI;IAiBnC;;;OAGG;IACH,oCAIE;IAEF;;;;;OAKG;IAIH;;;OAGG;IACH,8BAAgC;IAChC;;;OAGG;IACH,yBAAyB;IAEzB;;;;;;;;;;;;;OAaG;IACH,8CAAqC;IACrC;;;OAGG;IACH,2BAAsC;IACtC;;;OAGG;IACH,oDAAqC;IACrC;;;OAGG;IACH,4BAA+B;IAC/B;;;OAGG;IACH,2BAA2B;IAC3B;;;OAGG;IACH,2FAAgC;IAChC;;;OAGG;IACH,+BAAkC;IAClC;;;OAGG;IACH,+BAAqC;IASrC;;;;;OAKG;IACH,UAHU,MAAM,CAGO;IAEvB;;;OAGG;IACH,cAFU,WAAW,CAEqB;IAE1C;;;;;;;;OAQG;IACH,cAJU,cAAc,CAIuB;IAE/C;;;;;;;;;;;;;;OAcG;IACH,cAJU,YAAY,CAI4B;IAElD;;;;OAIG;IACH,sBAHU,MAAM,CAMf;IACD;;;;;;;;;OASG;IACH,0BAJU,MAAM,CAIiB;IAEjC;;;;;OAKG;IACH,iBAJU,MAAM,CAOf;IAED;;;;OAIG;IACH;;;QAEE;IAIF;;;OAGG;IACH,kBAA6B;IAG7B;;;OAGG;IACH,kBAAoB;IAGpB;;;OAGG;IACH,sBAA4B;IAM5B;;;OAGG;IACH,wBAAwB;IAExB;;;;OAIG;IACH,kBAFU,QAAQ,CAEuC;IAEzD;;;OAGG;IACH,gBAFU,YAAY,CAES;
|
|
1
|
+
{"version":3,"file":"webgl_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgl/webgl_ren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AAM,MACN,MAAM,MACN,MAAM,QAKhB;IAED;;;;;;;;;OASG;IACH,aAPW,QAAQ,GAAC,QAAQ,GAAC,MAAM,MACxB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAmChB;IAsIE;;;OAGG;IACH,sCAA4B;;CAoD/B;qBAhnHoB,kBAAkB;6BACV,uCAAuC;wBAJ5C,2BAA2B;8BAKrB,sCAAsC;+BAoBrC,yBAAyB;uBA3CjC,yBAAyB;yBADvB,wBAAwB;6BAiCpB,uBAAuB;yBAP3B,uBAAuB;iCANf,8BAA8B;6BAKrB,uBAAuB;0CAevB,oCAAoC;6BAbjD,8BAA8B;sBA5B1B,uBAAuB;0BAiDjC,iCAAiC;+BAC5B,iCAAiC;6BACnC,6BAA6B;0BAChC,4BAA4B;6BACzB,+BAA+B;8BAC9B,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,kDAoBC;IAhBC,6CAA6B;IAU9B,iDAAiD;IACjD,qDAAqD;IAErD,2CAAgC;IAEhC;;;;yBAAwB;IAkDzB;;;;;OAKG;IACH,yCAkBC;
|
|
1
|
+
{"version":3,"file":"lit_mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/lit_mesh_batcher.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,kDAoBC;IAhBC,6CAA6B;IAU9B,iDAAiD;IACjD,qDAAqD;IAErD,2CAAgC;IAEhC;;;;yBAAwB;IAkDzB;;;;;OAKG;IACH,yCAkBC;CAsKD;8BA/R6B,mBAAmB"}
|
|
@@ -29,14 +29,19 @@ export default class WebGPUMeshBatcher extends WebGPUBatcher {
|
|
|
29
29
|
meshLayout: GPUBindGroupLayout | undefined;
|
|
30
30
|
vertexLayoutKey: string | undefined;
|
|
31
31
|
customShader: any;
|
|
32
|
+
hostedEffect: any;
|
|
32
33
|
indexData: Uint32Array<ArrayBuffer> | undefined;
|
|
33
34
|
indexCount: any;
|
|
34
35
|
currentMaterial: any;
|
|
35
36
|
uniformBinding: {
|
|
37
|
+
bindGroup: GPUBindGroup;
|
|
38
|
+
offsets: number[];
|
|
39
|
+
} | {
|
|
36
40
|
bindGroup: any;
|
|
37
|
-
|
|
41
|
+
offsets: any[];
|
|
38
42
|
} | null | undefined;
|
|
39
43
|
uniformBindGroups: Map<any, any> | undefined;
|
|
44
|
+
effectBindGroups: Map<any, any> | undefined;
|
|
40
45
|
meshState: {
|
|
41
46
|
cullMode: string;
|
|
42
47
|
frontFace: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/mesh_batcher.js"],"names":[],"mappings":"AA8BA;;;;;;;;;GASG;AACH,gCAAiC,GAAG,CAAC;AAWrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;OAGG;IACH,wBAHW,OAAO,uBAAuB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"mesh_batcher.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/batchers/mesh_batcher.js"],"names":[],"mappings":"AA8BA;;;;;;;;;GASG;AACH,gCAAiC,GAAG,CAAC;AAWrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;OAGG;IACH,wBAHW,OAAO,uBAAuB,EAAE,OAAO,uBAyFjD;IA/EA,2CAUE;IAuBF,oCAAsC;IAItC,kBAAwB;IACxB,kBAAwB;IAIxB,gDAA+D;IAC/D,gBAAmB;IAGnB,qBAA2B;IAE3B;mBA2dwB,YAAY;iBAAW,MAAM,EAAE;;;;yBA3d7B;IAE1B,6CAAkC;IAKlC,4CAAiC;IAGjC;;;kBAAuD;IAQv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;;OAQG;IACH,sBANW,MAAM,QACN,MAAM,UACN,MAAM,QAuEhB;IAED;;;;;;OAMG;IACH,uBAyEC;IAED;;;;;OAKG;IACH,4BAEC;IAED;;;;;;;;;OASG;IACH,8BANW,MAAM,OACN,YAAY,GACV,MAAM,CAMlB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,GACJ,sBAAsB,CAiBlC;IAED;;;;;;;;;;;;;;OAcG;IACH,uBANW,MAAM,eACN,QAAQ,QACR,MAAM,QA8EhB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,QAWhB;IAED;;;;OAIG;IACH,2BAMC;CAwBD;0BA5xCyB,qBAAqB;iCARd,8BAA8B;yBATtC,2BAA2B;mCAUjB,gCAAgC"}
|
|
@@ -168,6 +168,7 @@ export default class WebGPURenderer extends Renderer {
|
|
|
168
168
|
*/
|
|
169
169
|
setBatcher(name?: string): WebGPUBatcher;
|
|
170
170
|
drawMesh(mesh: any, modelMatrix: any): void;
|
|
171
|
+
instancedEffectWarned: boolean | undefined;
|
|
171
172
|
/**
|
|
172
173
|
* Release any retained geometry held for the given mesh (called from
|
|
173
174
|
* `Mesh.onDeactivateEvent` / `Mesh.destroy`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"AA0DA;;;;;;;;;;;;;;;GAeG;AACH,iDANW,OAAO,qBACP,OAAO,GACL;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CAYvD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH;IACC;;OAEG;IACH,qBAFW,mBAAmB,EA2U7B;IAnUA;;;;OAIG;IACH,kBAHU,UAAU,GAAC,SAAS,CAGN;IAExB;;;;OA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AIG;IACH,eAHW,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,GAAC,MAAM,SAC1C,OAAO,QA2BjB;IAED;;;OAGG;IACH,aAFW,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,GAAC,MAAM,QAIpD;IAmCD;;;;;OAKG;IACH,+BAwCC;IAED;;;OAGG;IACH,cAFa,gBAAgB,CAI5B;CAqFD;qBAjnHoB,gBAAgB;0CAyBK,oCAAoC;yBArBrD,qBAAqB;yBA1BrB,wBAAwB;uBAC1B,yBAAyB;gCA6CU,qBAAqB;8BAFjD,mBAAmB;8BACnB,yBAAyB;+BAKxB,oBAAoB;+BA1BpB,uCAAuC;wBAN9C,2BAA2B;sBAnBlB,qBAAqB;0BA4C5B,8BAA8B;iCAvBvB,8BAA8B;6BAKrB,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -20,9 +20,15 @@ This is the single most important thing on this page.
|
|
|
20
20
|
| vertical | **Y-down** — higher `y` is *lower* on screen | Y-up |
|
|
21
21
|
| depth | **+Z forward** — higher `z` is *farther* away | −Z forward |
|
|
22
22
|
|
|
23
|
-
Rotations are extrinsic XYZ
|
|
24
|
-
(X, look up/down)
|
|
25
|
-
|
|
23
|
+
Rotations are extrinsic XYZ, and `Camera3d` exposes all three: `camera.pitch`
|
|
24
|
+
(X, look up/down), `camera.yaw` (Y, look left/right) and `camera.roll` (Z, bank
|
|
25
|
+
the horizon). The view is `R(yaw) ∘ R(pitch) ∘ R(roll)` inverted, and the frustum
|
|
26
|
+
planes come off that same matrix — so culling follows a banked view.
|
|
27
|
+
|
|
28
|
+
`camera.rotate()` is NOT the way to bank a 3D camera. It writes the inherited
|
|
29
|
+
`currentTransform`, which a 3D view never reads, so the call is silently inert.
|
|
30
|
+
Set `roll`. (On a `Camera2d` it is the other way round: roll IS that transform's
|
|
31
|
+
rotation, which is why `worldToLocal` / `localToWorld` compensate for it.)
|
|
26
32
|
|
|
27
33
|
The payoff is that 2D code translates directly — anywhere you used `pos.x` /
|
|
28
34
|
`pos.y`, add `pos.z` and the maths still holds. The cost is that every
|
|
@@ -83,6 +89,10 @@ class GameStage extends Stage {
|
|
|
83
89
|
`camera.setClipPlanes(near, far)`.
|
|
84
90
|
- **`camera.pos.set(x, y)` is 2-argument and zeroes z.** Use `camera.depth` —
|
|
85
91
|
the documented z accessor — or assign `pos.x`/`pos.y` individually.
|
|
92
|
+
- **`worldToLocal` does not project.** It is a 2D camera's offset subtraction.
|
|
93
|
+
To pin a label or marker to a point in the scene use
|
|
94
|
+
`camera.worldToScreen(x, y, z)`, which applies the projection and returns
|
|
95
|
+
`null` behind the camera. See `melonjs-camera-and-drawing`.
|
|
86
96
|
|
|
87
97
|
## Depth sorting
|
|
88
98
|
|
|
@@ -388,6 +398,67 @@ is no *partial* mesh transparency though — the mesh path renders opaque, so a
|
|
|
388
398
|
mesh at `alpha = 0.5` draws fully opaque rather than half see-through. Fade a
|
|
389
399
|
mesh out and it will stay solid until it vanishes.
|
|
390
400
|
|
|
401
|
+
## Moving a mesh in 3D
|
|
402
|
+
|
|
403
|
+
`Mesh` and `Sprite3d` inherit the ordinary `Renderable` transform helpers, and
|
|
404
|
+
both are already 3D:
|
|
405
|
+
|
|
406
|
+
```js
|
|
407
|
+
mesh.rotate(Math.PI / 2, new Vector3d(1, 0, 0)); // axis overload
|
|
408
|
+
mesh.scale(2, 1, 0.5); // z is a real argument
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
`rotate(angle)` alone is the 2D case (about Z); pass a `Vector3d` and it
|
|
412
|
+
rotates about that axis. Both write to `currentTransform`, a **`Matrix3d`**,
|
|
413
|
+
which `Mesh` folds into its model matrix — so orienting a mesh costs a matrix
|
|
414
|
+
update, not new geometry.
|
|
415
|
+
|
|
416
|
+
This matters most for the case it is least obvious for: a horizontal plane.
|
|
417
|
+
`Sprite3d` with `billboard: false` is a quad in the sprite plane — upright —
|
|
418
|
+
and the way to lay one flat (water, a road, a shadow decal) is to rotate it a
|
|
419
|
+
quarter turn about X, **not** to hand-build vertices. The one reason to build
|
|
420
|
+
geometry instead is tiling: a `Sprite3d` bakes its UVs 0..1 from its atlas
|
|
421
|
+
frame, so a surface that needs `textureRepeat` across many world units still
|
|
422
|
+
wants an explicit `vertices`/`uvs` mesh.
|
|
423
|
+
|
|
424
|
+
## The mesh pass is opaque
|
|
425
|
+
|
|
426
|
+
Worth stating plainly, because the symptom does not look like a blending
|
|
427
|
+
problem: **the mesh pass disables blending**. A soft-edged texture — a glow, a
|
|
428
|
+
sun, a halo, anything with a gradient alpha — composites as a hard-edged disc
|
|
429
|
+
with a grey rim, which reads as a broken texture rather than as a missing
|
|
430
|
+
feature.
|
|
431
|
+
|
|
432
|
+
`transparent: true` routes it through the transparent pass, and `blendMode:
|
|
433
|
+
"additive"` on top of that makes a light source add to the sky instead of
|
|
434
|
+
sitting on it. This is the same feature a translucent water surface needs.
|
|
435
|
+
|
|
436
|
+
## Textures under a perspective camera
|
|
437
|
+
|
|
438
|
+
A tiling texture on a large ground plane is seen at a grazing angle, and that
|
|
439
|
+
changes which detail survives:
|
|
440
|
+
|
|
441
|
+
- **Nothing straight and parallel to the direction of travel.** Every such run
|
|
442
|
+
converges on the vanishing point, so a few current bands on a river become a
|
|
443
|
+
fan of rays radiating out of the horizon. Narrowing them and tiling more
|
|
444
|
+
often only multiplies the rays. Short, scattered, direction-free detail
|
|
445
|
+
minifies into an even shimmer instead.
|
|
446
|
+
- **`textureFilter: "linear"`** for a floor — `"nearest"` opts out of mipmaps
|
|
447
|
+
and anisotropy, and detail aliases into a wash exactly where the camera looks
|
|
448
|
+
most.
|
|
449
|
+
|
|
450
|
+
## Ground must outlast the props standing on it
|
|
451
|
+
|
|
452
|
+
Scenery scattered up a slope is placed by its own rule, and terrain is built by
|
|
453
|
+
another. When the planting reaches further than the mesh does, a low camera
|
|
454
|
+
sees trees standing over open sky at the corners of the frame. Build the ground
|
|
455
|
+
wider than the widest thing planted on it — past the profile's clamp it is a
|
|
456
|
+
flat plateau, so the extra columns cost two triangles and no silhouette.
|
|
457
|
+
|
|
458
|
+
Recycling has the same trap in Z: an endless runner that recycles tiles a fixed
|
|
459
|
+
distance behind the *player* forgets that the camera trails further back still,
|
|
460
|
+
and the bottom of the frame falls off the world.
|
|
461
|
+
|
|
391
462
|
## Sprite3d and billboards
|
|
392
463
|
|
|
393
464
|
`Sprite3d` is the 2.5D workhorse: a flat sprite living at a real depth, with
|
|
@@ -413,8 +484,37 @@ default), `"ambient"`, `"point"` and `"spot"`.
|
|
|
413
484
|
```js
|
|
414
485
|
world.addChild(new Light3d({ type: "directional", direction: [0.3, 1, 0.2] }));
|
|
415
486
|
world.addChild(new Light3d({ type: "ambient", intensity: 0.3 }));
|
|
487
|
+
// a Vector3d works too, wherever the game already has one
|
|
488
|
+
world.addChild(new Light3d({ type: "spot", position: torch.pos, range: 400 }));
|
|
416
489
|
```
|
|
417
490
|
|
|
491
|
+
`direction` and `position` take an `[x, y, z]` array **or** a `Vector3d`, and
|
|
492
|
+
`color` takes a `Color`, a CSS string or an `[r, g, b]` array — so a value the
|
|
493
|
+
game already holds can go straight in. Each is read, not retained: move your
|
|
494
|
+
vector afterwards and the light stays where it was.
|
|
495
|
+
|
|
496
|
+
Two things still bite, both silently:
|
|
497
|
+
|
|
498
|
+
- `new Light3d(0, 0, {…})` — the constructor takes **options alone**. JavaScript
|
|
499
|
+
drops the extra arguments, so `options` becomes the number `0` and every
|
|
500
|
+
setting in your literal is discarded. The light still appears, on pure
|
|
501
|
+
defaults: a `type: "ambient"` written this way is a second DIRECTIONAL light,
|
|
502
|
+
and the scene looks plausible enough that nobody checks. TypeScript stops
|
|
503
|
+
checking a literal once the argument count is wrong, so nothing inside it is
|
|
504
|
+
verified either.
|
|
505
|
+
- **`direction` is where the light GOES, and this is a Y-down space** — so a sun
|
|
506
|
+
overhead travels *downward* and its Y is **positive**. Get the sign wrong and
|
|
507
|
+
the scene is lit from underneath: faces that should be in shade are bright,
|
|
508
|
+
the ground glows and the sky-facing surfaces go dark.
|
|
509
|
+
|
|
510
|
+
```js
|
|
511
|
+
direction: [-0.35, 0.8, 0.45] // sun overhead, late afternoon
|
|
512
|
+
direction: [-0.35, -0.8, 0.45] // lit from below — almost never what you want
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
`position` follows the same convention: a lamp above the floor has a
|
|
516
|
+
**smaller** y than the floor.
|
|
517
|
+
|
|
418
518
|
Use **both halves**: with a key light but no ambient, the shadow side of a mesh
|
|
419
519
|
goes black. With no `Light3d` in the world at all, a `lit: true` mesh falls back
|
|
420
520
|
to a white ambient and renders fullbright — indistinguishable from unlit, which
|
|
@@ -445,6 +545,37 @@ units it projects over the top of the caster as a dark halo ringing it. If an
|
|
|
445
545
|
object needs a visible shadow, give it a smaller footprint relative to its
|
|
446
546
|
height, or accept that a boulder bedded in the ground has none.
|
|
447
547
|
|
|
548
|
+
### Get the sign right: the floor is a GREATER y
|
|
549
|
+
|
|
550
|
+
Render space is **Y-down**, so the floor an object stands on is a *larger* y
|
|
551
|
+
than the object itself. Nudging a shadow plane below a surface is therefore a
|
|
552
|
+
**plus**:
|
|
553
|
+
|
|
554
|
+
```js
|
|
555
|
+
mesh.shadowGroundY = WATER_LEVEL + 8; // just under the surface — correct
|
|
556
|
+
mesh.shadowGroundY = mesh.pos.y - 8; // eight units ABOVE its own base — wrong
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
Get it backwards and the blob becomes a horizontal quad slicing through the
|
|
560
|
+
caster's own body. It is still drawn at full strength — the height fade sees a
|
|
561
|
+
*negative* height and clamps to 1, so nothing warns you — but the depth test
|
|
562
|
+
hides every part of it that falls inside the caster's silhouette. What survives
|
|
563
|
+
is a thin ring, only as wide as the blob overhangs the object.
|
|
564
|
+
|
|
565
|
+
The symptom is distinctive and easy to misread: **shadows appear to switch on as
|
|
566
|
+
casters approach the camera.** That ring is a few pixels on the nearest object
|
|
567
|
+
and sub-pixel further out, so a scene reads as "only nearby things have
|
|
568
|
+
shadows" — which looks like culling, an LOD stage or a fog problem, none of
|
|
569
|
+
which it is. Before chasing any of those, dump `shadowGroundY` against the
|
|
570
|
+
caster's own y and check which one is larger.
|
|
571
|
+
|
|
572
|
+
## Collision in 3D
|
|
573
|
+
|
|
574
|
+
Use `Box3d` bodies, not a hand-rolled distance check. `Box3d`-vs-`Box3d` is
|
|
575
|
+
the engine's 3D narrowphase and the only contact that pushes back along Z; the
|
|
576
|
+
response carries `overlapNZ` / `overlapZ` for the depth axis. See the physics
|
|
577
|
+
skill for the contract and the mixed-pair caveat.
|
|
578
|
+
|
|
448
579
|
## glTF / GLB scenes
|
|
449
580
|
|
|
450
581
|
Loaded through the same level director as everything else:
|
|
@@ -456,6 +587,23 @@ level.load("diorama", { scale, castGroundShadow, shadowGroundY, onLoaded });
|
|
|
456
587
|
|
|
457
588
|
`.obj` / `.mtl` are also supported loader types.
|
|
458
589
|
|
|
590
|
+
An **animated** asset instantiates as a `GLTFModel`, which is a game object as
|
|
591
|
+
much as a scene: construct it straight from the parsed descriptor, and place it
|
|
592
|
+
with `pos` / `depth` / `rotate` / `scale` like any other renderable — the
|
|
593
|
+
placement drives the whole rig and composes with the playing clip.
|
|
594
|
+
|
|
595
|
+
```js
|
|
596
|
+
const model = new GLTFModel(loader.getGLTF("boat"), { scale: 40, lit: false });
|
|
597
|
+
model.setCurrentAnimation("paddle", { loop: true });
|
|
598
|
+
model.pos.set(x, y);
|
|
599
|
+
model.depth = z;
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
To scatter an authored mesh yourself, read the geometry off the descriptor and
|
|
603
|
+
hand it to an `InstancedMesh` — `loader.getGLTF(name).nodes[0]` carries
|
|
604
|
+
`vertices` / `uvs` / `normals` / `indices`. That wants a single merged
|
|
605
|
+
primitive exported at the origin; see `melonjs-3d-assets`.
|
|
606
|
+
|
|
459
607
|
`melonjs-3d-assets` covers the rest: every `level.load` option, which material
|
|
460
608
|
features are imported, imported lights and their intensity units, node-TRS
|
|
461
609
|
animation (and the skinning that is out of scope), and OBJ/MTL.
|
|
@@ -490,6 +638,7 @@ To branch rather than fail, read `app.renderer.supportsDepthBuffer` after
|
|
|
490
638
|
|
|
491
639
|
| symptom | cause |
|
|
492
640
|
|---|---|
|
|
641
|
+
| scene lit from underneath | `direction` Y sign — this is Y-down, so a sun overhead is **+Y** |
|
|
493
642
|
| a `lit` mesh renders fullbright | it had no normals — supply them, or let the engine generate them |
|
|
494
643
|
| a gradient across one mesh is impossible | `tint` is per object — use `vertexColors` / `setVertexColor` |
|
|
495
644
|
| a mesh stays solid as you fade it out | meshes render opaque; only `alpha` 0 (hidden) and 1 differ |
|
|
@@ -144,6 +144,27 @@ model.pause();
|
|
|
144
144
|
an explicit `loop: false` stops looping. `setCurrentAnimation` **throws** on a
|
|
145
145
|
clip name the asset does not define — check `getAnimationNames()` first.
|
|
146
146
|
|
|
147
|
+
### Placing and moving a model
|
|
148
|
+
|
|
149
|
+
A `GLTFModel` is placed like any other renderable — `pos`, `depth`, `rotate`
|
|
150
|
+
and `scale` move the **whole rig**, and compose with whatever the active clip
|
|
151
|
+
is doing, so a walk cycle plays wherever the character stands:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
const boat = new me.GLTFModel(me.loader.getGLTF("boat"), { scale: 40, lit: false });
|
|
155
|
+
boat.setCurrentAnimation("paddle", { loop: true });
|
|
156
|
+
app.world.addChild(boat);
|
|
157
|
+
|
|
158
|
+
boat.pos.set(steerX, waterLevel);
|
|
159
|
+
boat.depth = travelled;
|
|
160
|
+
boat.rotate(lean - lastLean, AXIS_Z); // `rotate` is RELATIVE — feed it the delta
|
|
161
|
+
boat.animationspeed = 0.85 + 0.9 * pace; // one authored tempo, many run speeds
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Constructing one directly from `loader.getGLTF(name)` is fine and is the way to
|
|
165
|
+
go when the model is a game object rather than a scene — `level.load` is for
|
|
166
|
+
loading a whole scene into the world.
|
|
167
|
+
|
|
147
168
|
**Vertex skinning is out of scope** — `JOINTS_0` / `WEIGHTS_0` are not read, and
|
|
148
169
|
neither are morph targets. A smoothly-deforming character will not deform. The
|
|
149
170
|
options are: rig it hierarchically instead (separate meshes parented into a
|
|
@@ -219,6 +240,117 @@ MTL contributes `Kd` (diffuse tint), `d` / `Tr` (opacity), `Ke` (emissive),
|
|
|
219
240
|
want it directly. OBJ has no scene graph, no lights, no animation — use glTF for
|
|
220
241
|
anything beyond a single static model.
|
|
221
242
|
|
|
243
|
+
## Authoring assets for the engine
|
|
244
|
+
|
|
245
|
+
Notes from modelling props and a rigged character against this loader. They are
|
|
246
|
+
Blender-specific in the API details, general in the traps.
|
|
247
|
+
|
|
248
|
+
### One clip means one action
|
|
249
|
+
|
|
250
|
+
glTF names an animation after the **action** it came from, so three objects
|
|
251
|
+
each carrying their own action export as three separate clips — and a game can
|
|
252
|
+
only play one clip at a time, so the other two never move. Put every animated
|
|
253
|
+
object in **one action**, using slots (Blender 4.4+):
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
shared = bpy.data.actions.new("paddle")
|
|
257
|
+
for ob in (pivot, shoulder_l, shoulder_r, body):
|
|
258
|
+
ad = ob.animation_data_create()
|
|
259
|
+
ad.action = shared
|
|
260
|
+
ad.action_slot = shared.slots.new('OBJECT', ob.name)
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Exporting with the scene/whole-timeline mode does **not** merge per-object
|
|
264
|
+
actions into one clip — it still emits one per action. Slots are the fix.
|
|
265
|
+
|
|
266
|
+
In Blender 5.x, `action.fcurves` no longer exists; curves live under
|
|
267
|
+
`action.layers[].strips[].channelbags[].fcurves`, and a channelbag identifies
|
|
268
|
+
its slot as `cb.slot.identifier` (there is no `slot_identifier`).
|
|
269
|
+
|
|
270
|
+
### Never re-parent or join a rig that is mid-pose
|
|
271
|
+
|
|
272
|
+
Both parenting and joining bake the objects' **current world transforms**.
|
|
273
|
+
Parenting a child while the parent sits in an animated pose writes the inverse
|
|
274
|
+
of that pose into `matrix_parent_inverse`, which silently cancels the animation
|
|
275
|
+
— the part renders rigid while the curves still exist. Detach the action, zero
|
|
276
|
+
the rig, do the surgery, then reattach:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
saved = [(o, o.animation_data.action_slot) for o in animated]
|
|
280
|
+
for ob, _ in saved:
|
|
281
|
+
ob.animation_data.action = None
|
|
282
|
+
ob.rotation_euler = (0, 0, 0)
|
|
283
|
+
# ...re-parent / join here...
|
|
284
|
+
for ob, slot in saved:
|
|
285
|
+
ob.animation_data.action = act
|
|
286
|
+
ob.animation_data.action_slot = slot
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
A joined mesh also inherits the **active** object's scale, so joining into a
|
|
290
|
+
box that was scaled to `(0.8, 2.0, 0.1)` leaves a node with that non-uniform
|
|
291
|
+
scale and geometry divided back through it. It renders in the right place but
|
|
292
|
+
skews flat-shaded normals — apply transforms (`rotation=True, scale=True`)
|
|
293
|
+
after joining. Watch for a related trap: setting `ob.scale.x` on a mesh whose
|
|
294
|
+
size was already applied *multiplies* rather than replaces it.
|
|
295
|
+
|
|
296
|
+
### A model only needs to stay split where something animates it
|
|
297
|
+
|
|
298
|
+
Every glTF primitive is a draw call. Merge everything static into one mesh and
|
|
299
|
+
keep separate nodes only for the parts a clip actually drives — a boat with a
|
|
300
|
+
rabbit and a paddle went from 28 primitives to 5 that way, with no visible
|
|
301
|
+
change.
|
|
302
|
+
|
|
303
|
+
### One palette strip beats one material per colour
|
|
304
|
+
|
|
305
|
+
An `InstancedMesh` is **one geometry and one material**, so a prop that wants
|
|
306
|
+
five colours cannot use five materials. Give the whole model a single material
|
|
307
|
+
whose image is an *N*×1 strip, one pixel per shade, and point each face's UVs
|
|
308
|
+
at a cell centre (`u = (cell + 0.5) / N`, `v = 0.5`) with the sampler set to
|
|
309
|
+
nearest. A whole scene's palette then costs one tiny texture, a merged mesh can
|
|
310
|
+
be twenty colours, and there is nothing to bleed between cells.
|
|
311
|
+
|
|
312
|
+
Colour-space trap when generating that strip programmatically: Blender's
|
|
313
|
+
`image.pixels` are scene-linear floats, but this export path writes them out
|
|
314
|
+
**verbatim**, so pre-converting sRGB→linear darkens every colour. White is the
|
|
315
|
+
tell — it is the one value identical in both spaces, so if white survives and
|
|
316
|
+
everything else came out dark, that is the bug. Verify by decoding the PNG back
|
|
317
|
+
out of the GLB and comparing bytes to the source palette.
|
|
318
|
+
|
|
319
|
+
### Feeding an authored mesh into an `InstancedMesh`
|
|
320
|
+
|
|
321
|
+
`EXT_mesh_gpu_instancing` covers instances authored *in the file*. When the
|
|
322
|
+
game places them itself, take the geometry off the parsed descriptor instead:
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
const node = me.loader.getGLTF("palm").nodes[0];
|
|
326
|
+
const trees = new me.InstancedMesh(0, groundY, {
|
|
327
|
+
vertices: node.vertices, uvs: node.uvs,
|
|
328
|
+
normals: node.normals, indices: node.indices,
|
|
329
|
+
texture: palette, textureFilter: "nearest", scale: 40,
|
|
330
|
+
instanceCount: count,
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
`nodes` is one entry **per primitive**, each in its own local space with a
|
|
335
|
+
separate `world` matrix — so this only works cleanly when the asset is a single
|
|
336
|
+
merged primitive exported with an identity node transform. Model it at the
|
|
337
|
+
origin, base on the floor, and apply transforms before exporting.
|
|
338
|
+
|
|
339
|
+
One geometry stamped out hundreds of times reads as one object *copied*
|
|
340
|
+
hundreds of times, so vary each instance in its transform. Rotate **after**
|
|
341
|
+
translating, or the instance swings around the group origin instead of turning
|
|
342
|
+
where it stands:
|
|
343
|
+
|
|
344
|
+
```js
|
|
345
|
+
placement.identity().translate(x / s, -y / s, z / s)
|
|
346
|
+
.rotate(math.randomFloat(0, Math.PI * 2), AXIS_Y);
|
|
347
|
+
const j = math.randomFloat(0.82, 1.18);
|
|
348
|
+
placement.scale(j, j, j);
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Sizing every prop against **one** scale constant, rather than giving each its
|
|
352
|
+
own, keeps "this looks wrong" a modelling question instead of a scaling one.
|
|
353
|
+
|
|
222
354
|
## Packaging
|
|
223
355
|
|
|
224
356
|
A self-contained GLB is one file with nothing to resolve — the safest thing to
|
|
@@ -243,7 +375,14 @@ need a prefix.
|
|
|
243
375
|
| a character does not deform | vertex skinning is out of scope; rig hierarchically or billboard |
|
|
244
376
|
| animation names come back empty | the asset has no node-TRS channels (skin-only rig) |
|
|
245
377
|
| a hundred copies tank the frame rate | exported without `EXT_mesh_gpu_instancing` |
|
|
378
|
+
| a whole scatter looks like one object repeated | every instance shares the group transform — vary yaw/scale per instance, rotating *after* the translate |
|
|
379
|
+
| three clips where you authored one | one action per object; use a single action with a slot each |
|
|
380
|
+
| one part of a rig renders rigid while its curves exist | it was re-parented mid-pose, baking the inverse into `matrix_parent_inverse` |
|
|
381
|
+
| a merged mesh lights wrong along one axis | it inherited the active object's non-uniform scale on join — apply transforms |
|
|
382
|
+
| an authored palette comes out uniformly dark, but white is correct | linear values written to a strip that is saved verbatim |
|
|
383
|
+
| `getGLTF(name).nodes[0]` geometry lands in the wrong place | `nodes` is per primitive, each with its own `world`; merge to one primitive and export at the origin |
|
|
246
384
|
| a prop casts no visible shadow | wide and flat-bottomed — the blob is under it; `shadowGroundY` haloes it rather than revealing it |
|
|
385
|
+
| shadows only show on casters near the camera | `shadowGroundY` is on the wrong side — Y-down means the floor is a **greater** y, so a `pos.y - lift` puts the blob inside the caster and the depth test leaves only a hairline ring |
|
|
247
386
|
| a shadow smeared across the whole floor | a ground plane cast its own blob — use the scene-wide opt-in |
|
|
248
387
|
| `onLoaded` gets a string, not the scene | it is called with the level id; load into your own container instead |
|
|
249
388
|
| scene renders flat and unlit | no `Camera3d` — the 2D-camera path is CPU-projected and unlit (with a `Camera3d` on Canvas you get a black canvas instead) |
|
|
@@ -141,6 +141,23 @@ audio.noise({ duration: 0.5, filter: { type: "lowpass", frequency: 800 } });
|
|
|
141
141
|
`"white"`), `attack`, `pan`, `filter` and `filterSweep`. `gain` defaults to `0.1`
|
|
142
142
|
on both.
|
|
143
143
|
|
|
144
|
+
### Sequencing: `delay`, not `setTimeout`
|
|
145
|
+
|
|
146
|
+
Both take `delay` — seconds before the sound starts, scheduled on the **audio
|
|
147
|
+
clock**. That is what builds a multi-part sound: a stinger's second note, an
|
|
148
|
+
explosion's double-tap.
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
audio.tone({ freq: 392, duration: 0.12 });
|
|
152
|
+
audio.tone({ freq: 587, duration: 0.18, delay: 0.11 });
|
|
153
|
+
audio.tone({ freq: [784, 1176], duration: 0.75, delay: 0.23 });
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Do not reach for `setTimeout` here. A timer fires on the main thread, so a busy
|
|
157
|
+
frame slips the note late and the sequence audibly loses time — the fault is
|
|
158
|
+
easy to blame on the sound design rather than the scheduling. `delay` is
|
|
159
|
+
sample-accurate because the whole envelope is scheduled up front.
|
|
160
|
+
|
|
144
161
|
Both are **silent no-ops** when there is no WebAudio context — they bail on
|
|
145
162
|
`getAudioContext() === null` rather than throwing. Neither needs the clip to be
|
|
146
163
|
loaded; neither goes through the file-playback path at all.
|
|
@@ -78,6 +78,30 @@ whichever of world/screen matches the region — screen for a `floating` region,
|
|
|
78
78
|
world otherwise. Use the screen pair for anything that *moves* the camera, or
|
|
79
79
|
the drag feeds back on itself.
|
|
80
80
|
|
|
81
|
+
### In 3D: `Camera3d#worldToScreen`
|
|
82
|
+
|
|
83
|
+
`worldToLocal` is a 2D camera's offset subtraction — it knows nothing about a
|
|
84
|
+
perspective projection. To pin a label, damage number or marker to a point in a
|
|
85
|
+
3D scene, project it:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
const p = camera.worldToScreen(x, y, z); // view + projection, divide included
|
|
89
|
+
if (p !== null) { // null = at or BEHIND the camera
|
|
90
|
+
label.pos.set(p.x, p.y);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
It returns canvas pixels with the origin top-left and **y down**, which is the
|
|
95
|
+
engine's own 2D draw space — so the result feeds a `floating` renderable or the
|
|
96
|
+
immediate-mode API directly, with no flip.
|
|
97
|
+
|
|
98
|
+
**Always check for `null`.** A point at or behind the camera (clip `w <= 0`)
|
|
99
|
+
has no honest screen position, and projecting it anyway yields a mirrored
|
|
100
|
+
coordinate that puts your label on the wrong side of the screen. Skip it.
|
|
101
|
+
|
|
102
|
+
Do not hand-roll this with `Matrix3d` — the perspective divide and the behind-
|
|
103
|
+
camera case are exactly what gets it wrong.
|
|
104
|
+
|
|
81
105
|
## Secondary cameras
|
|
82
106
|
|
|
83
107
|
Cameras are first-class — a minimap is a second camera with `autoResize = false`
|
|
@@ -118,6 +142,27 @@ of them and throw `Invalid geometry for fill/stroke` for anything else.
|
|
|
118
142
|
noise — including seamless tiling and `asNormalMap` — so you rarely need to ship
|
|
119
143
|
noise PNGs.
|
|
120
144
|
|
|
145
|
+
Two things to get right when one is animated:
|
|
146
|
+
|
|
147
|
+
- **Drive it yourself.** `update(dt)` advances the time axis and re-bakes; the
|
|
148
|
+
engine never calls it. An `animated: true` texture nobody updates is a still
|
|
149
|
+
image, with no error to say so.
|
|
150
|
+
- **Hand consumers the texture, not its canvas.** Re-baking bumps the
|
|
151
|
+
`Texture2d`'s `version`, and that bump is what tells the renderer to
|
|
152
|
+
re-upload. `getTexture()` returns the baked canvas, which carries no version
|
|
153
|
+
— so a mesh given the canvas shows frame one forever.
|
|
154
|
+
|
|
155
|
+
Set `seamless: true` for anything tiled by UVs past 1, or every repeat carries a
|
|
156
|
+
visible seam.
|
|
157
|
+
|
|
158
|
+
**And it still will not animate on a `Mesh`.** Driving `update(dt)` genuinely
|
|
159
|
+
re-bakes the field — the pixels change, the version increments — but the mesh
|
|
160
|
+
path does not pick the new copy up, so a 3D surface textured with an animated
|
|
161
|
+
noise renders frozen while every counter reports success. Verify with a
|
|
162
|
+
checksum of `getTexture()` before concluding the animation is broken; it is the
|
|
163
|
+
upload that is missing, not the bake. For a moving 3D surface, scroll the UVs
|
|
164
|
+
or move the geometry instead.
|
|
165
|
+
|
|
121
166
|
## Clipping and masking
|
|
122
167
|
|
|
123
168
|
```js
|