melonjs-3d-assets
Ce qu’il fait
Ce guide explique comment intégrer des scènes et des modèles 3D dans un jeu melonJS, et ce que le chargeur prend ou non en charge. Il s'adresse aux développeurs de jeux qui veulent du contenu 3D dans leur jeu navigateur.
Quand l’utiliser
- ✓Quand un développeur veut charger une scène 3D au format glTF ou GLB dans un jeu melonJS.
- ✓Quand un développeur a besoin d'un modèle 3D statique simple au format OBJ.
- ✓Quand le modèle 3D d'un développeur apparaît trop petit ou trop grand dans le jeu.
Lien du skill
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-3d-assets/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Chargez cette scène GLB dans mon jeu melonJS et donnez-lui la bonne taille.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
Le skill montre comment précharger le fichier et le charger par le système de niveaux, avec des options d'échelle, de lumières et de gestion des coordonnées. Il liste ce que le chargeur prend en charge.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
Loading 3D assets
glTF/GLB is the primary path for 3D content, and it goes through the level director rather than the world directly:
level.load("scene"), the same call a Tiled map uses. OBJ/MTL is the simpler path for a single static model.
Loading a glTF/GLB scene
await loader.preload([
{ name: "diorama", type: "glb", src: "data/scenes/diorama.glb" },
]);
level.load("diorama", { scale: 50 });
type: "gltf" (JSON plus external buffers) and type: "glb" (single binary)
are both loader types. A self-contained GLB is the better shipping format — one
request, nothing to resolve relatively.
The scene loads under whatever camera the stage has; view it under a Camera3d
or it renders flat. See melonjs-3d for the camera.
level.load options for glTF/GLB
| option | default | what it does |
|---|---|---|
scale |
1 |
pixels per glTF unit, applied to the whole scene. Blender's metre-scale export usually needs 20–100. |
container |
game.world |
where the nodes are added |
onLoaded |
game.onLevelLoaded |
called with the level id, not the scene |
async |
false |
return a promise that settles once the scene is in the world, instead of a boolean |
rightHanded |
true |
see below |
lights |
true |
instantiate authored KHR_lights_punctual lights as Light3d world children |
lightIntensityScale |
— | keep authored intensity ratios instead of normalising every light to 1 |
Those game. defaults are the engine's, not a recommendation. game is
whichever Application finished init() last, so pass container
explicitly from a Stage, where the right one is in your hand:
level.load("sceneId", { container: this.app.world, scale: 40 });
| castGroundShadow | inherits the app setting (on) | blob shadows for this scene's meshes |
| shadowGroundY | each object's own base | world Y of the floor the blobs land on |
| shadowOpacity | 0.45 | how dark the blobs are |
| shadowScale | 1 | blob footprint multiplier; 0 or less hides them |
| shadowOffset | 0 | slide them along the light, in blob radii; needs shadowGroundY, which is the only way a scene load can name its floor |
| shadowStretch | 1 | lengthen them along it, clamped to 3 |
| shadowDirectionX / shadowDirectionZ | 0 | the ground direction they are cast along |
| shadowGroundNormal | world up | up normal of the floor, for a scene that is not level |
| shadowLight | — | a Light3d to take the direction from, re-read every draw |
shadowGroundPoint is not on that list, and a scene load drops it without
a warning. One floor POINT shared by every part of a scene would stack the
whole thing's blobs on a single spot, which is nonsense where one floor
HEIGHT is perfectly sensible. Ground that is not flat is a per-object answer:
set it on the parts you want once the load has finished.
onLoaded receives the level id — it is a "done" signal, not a handle on the
scene. You need it, or async: with the game loop running, level.load stops
the loop and defers the actual load to a timer, so by default it returns
before anything is in the world.
await level.load("diorama", { scale: 50, async: true });
// the scene is in the world here
Note await level.load("diorama") without the flag does not await the load — the
call returns a boolean, and await true resolves immediately. To get at what was
loaded, load into a container you own, or look the nodes up by their authored
names:
level.load("diorama", { scale: 50, onLoaded: () => {
const sun = app.world.getChildByName("Sun")[0]; // note: returns an array
sun.intensity = 2;
}});
The same options from a Tiled Trigger
A Trigger authored in Tiled forwards these to level.load(), so a trigger that
walks the player into a glTF level carries the scene's settings as Tiled
properties:
world.addChild(new Trigger(x, y, {
shapes: [new Rect(0, 0, 100, 100)],
to: "diorama", // the level id — `to`, not `level`
scale: 50,
rightHanded: false,
castGroundShadow: false,
}));
Every level.load option above travels, including the whole ground-shadow set,
and so do container, onLoaded, flatten and setViewportBounds. The list is
derived from level.loadOptions rather than restated, so an option added to
a level format arrives here for free. It used to be hand-written and had fallen
three releases behind the glTF pa
Questions fréquentes
Pourquoi mon modèle a-t-il la mauvaise taille ?
Le skill explique qu'un réglage d'échelle convertit les unités du modèle en pixels du jeu, avec souvent des valeurs entre 20 et 100 pour les exports de Blender.
Quel format vaut-il mieux livrer ?
Le skill indique qu'un fichier GLB autonome est préférable, car il ne nécessite qu'une seule requête.
Faut-il une caméra 3D ?
Oui. Sans caméra 3D, la scène s'affiche à plat.
Détails
Description originale de l’auteur
Use this skill when loading 3D models into melonJS — glTF and GLB scenes, OBJ/MTL models, materials, imported lights, node animation, ground shadows and GPU instancing. Covers level.load options including the async flag, the rightHanded conversion, and exactly what the loader does and does not support. Triggers on: glTF, gltf, glb, OBJ, MTL, 3D model, getGLTF, getOBJ, getMTL, GLTFModel, GLTFScene, level.load glb, rightHanded, lightIntensityScale, castGroundShadow, shadowGroundY, EXT_mesh_gpu_instancing, KHR_lights_punctual, skinning, Blender export, 3D asset.
repo: melonjs/melonJS
Popularité
- Étoiles GitHub
- 6.4k
- Position au classement
- #14195
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
melonjs-20-migration
6.4kAide votre agent à écrire du code de jeu melonJS pour la version 20 et à éviter les méthodes obsolètes des versions précédentes, comme le démarrage asynchrone obligatoire.
melonjs-3d
6.4kAide votre agent à construire des scènes 3D ou 2,5D dans un jeu melonJS, avec les caméras, les maillages, les lumières et la profondeur, selon les règles d'axes du moteur.
melonjs-audio
6.4kAide votre agent à ajouter des effets sonores et de la musique à un jeu melonJS, avec la configuration audio, les pistes de fond, le réglage du volume et le son spatial.
melonjs-camera-and-drawing
6.4kAide votre agent à contrôler la caméra d'un jeu melonJS, par exemple pour suivre un joueur, et à dessiner des formes et des lignes personnalisées dans le jeu.
Skills similaires
diffs
394kPermet à votre agent de produire un diff réel et partageable de vos modifications, sous forme de lien ou d'image, plutôt qu'un résumé écrit à la main.
coding-agent
394kAide votre agent à confier une tâche de programmation plus importante à Codex, Claude Code ou OpenCode comme travailleur en arrière-plan, puis à suivre sa progression.
gh-issues
394kAide votre agent à trouver des tickets GitHub, choisir ceux à traiter et ouvrir des pull requests avec des correctifs, y compris le suivi des commentaires de relecture.