页面简介
What is a GLB file? A 3D model in binary glTF, with mesh, textures and animations in one file. See why every 3D browser game EvonX makes uses the GLB format.
正文摘录
Part of a 3D game buildThe GLB file in a 3D browser gameThe model is in the game, not in a folder.Getting a 3D model into a browser game is normally a chain of chores: convert it to GLB, fix its scale, turn it the right way, load it, hook up its animations. When EvonX builds a 3D game it does that chain itself. Each model is made or picked for the game, stored as a GLB and placed in the scene by the same AI that writes the game's code.Make a 3D gameConvert an FBX to GLB, freeMy 3D gameevonx.ai/games/my-3d-gamePlayingGLBcharacter.glb · 757 KBGLB757 KB3 clipsload("character.glb")// 24 joints, 3 clipsscale(model, box)// measured, not trustedground(model)// lowest point on the floorplay("run")// clip by namePlaying run · walk, run, idle in the fileHow it worksFrom a sentence to a model in the scene.These are the steps EvonX runs for every 3D model a game needs. You see the result in the game, not the pipeline.Step 1You describe the gameSay what the game is and what is in it: a knight, a kart, a row of market stalls. The build works out which 3D models the game needs and what role each one plays.Step 2Each model is made or pickedA model is either generated for your game, which means reconstructed from views the AI draws of it, or taken from EvonX's free asset library. Either way it lands in the game as one GLB file.Step 3It is sized and stood on the groundThe game does not trust the numbers in the file. It measures the model's bounding box, scales it to the height or width the game wants and puts its lowest point on the ground.Step 4It is turned to face forwardIf a model looks the wrong way, it is turned once in the game's asset list, in degrees, not patched in code at every place it appears.Step 5Its animations are wired by nameA rigged character's clips are played by name: idle, walk, run, attack. A check refuses a game that asks for a clip the file does not contain, so a missing animation is caught before you play.Opened upWhat is inside a GLB file.What is a GLB file? The question is easier to answer with one open on the table. This is character.glb, the rigged character from our own builds, laid out byte by byte. The first 12 bytes are the header: the letters glTF, the version number 2 and the length of the whole file, 774,864 bytes. Two chunks follow. The JSON chunk, 78,664 bytes, is the description: 26 nodes, one mesh, one skin, three animations, three images and 209 accessors saying where each piece of data starts.The BIN chunk, 696,172 bytes, is the data itself. Hover a block to see its parts: vertex positions, normals and UVs, the weights that tie the mesh to its 24 bones, three WebP textures that together take 302,122 bytes, the largest share, and the keyframes of idle, walk and run. Nothing points outside the file, so a game fetches it with a single request.character.glb774,864 BglTF 2.0 · binary0x000BD2D0 Header · 12 B JSON · 78,664 B BIN · 696,172 B67 6C 54 46magic “glTF”02 00 00 00version 2D0 D2 0B 00file length 774,86448 33 01 00chunk 0: 78,664 bytes4A 53 4F 4Echunk 0 type: JSONThe JSON chunk declares26nodes1meshes1skins3animations3images1materials209accessors212bufferViewsThe BIN chunk holds Mesh · 3,496 triangles239,324 BPOSITION38,532NORMAL38,532TANGENT51,376TEXCOORD_025,688JOINTS_012,844WEIGHTS_051,376indices20,976 Skin · 24 joints1,792 BinverseBindMatrices1,792 Textures · 3 WebP302,122 Btexture_diffuse124,534texture_normal100,268texture_metallic-texture_roughness77,320 Animations · 3 clips152,932 Bidle106,964walk28,288run17,680Four formatsGLB, glTF, FBX, OBJ: what each one holds.The table fills in what each format can carry. GLB and glTF are one Khronos standard in two packagings: glTF keeps the description as readable JSON and leaves the geometry in a .bin and the textures in image files next to it, while GLB packs all of that into one binary file. Our character would ship as five files in the first form and one in the second. Press GLB vs glTF and only the packaging rows light up.Press GLB vs FBX and the difference moves elsewhere. FBX, Autodesk's format, also holds meshes, skeletons and animation, but its textures often travel beside it and its materials are usually the older Phong and Lambert kinds rather than glTF's PBR. OBJ is the oldest of the four: plain-text geometry with a .mtl for materials and no skeleton or animation at all, so a character never survives the trip.All fourGLB vs glTFGLB vs FBX.glb.gltf.fbx.objStored asbinaryJSON textbinary or textplain textFiles to ship1.gltf + .bin + images1, images often beside.obj + .mtl + imagesMesh✓✓✓✓MaterialsPBRPBR✓in a .mtlTexturesinsidebeside, or base64inside or besidebesideSkeleton and skin✓✓✓✕Animation clips✓✓✓✕Defined byKhronos, openKhronos, openAutodeskWavefront, openthree.js loaderGLTFLoaderGLTFLoaderFBXLoaderOBJLoadercharacter.glb as GLB: 1 file, 774,864 Bunpacked as glTF: 5 files (.gltf, .bin, 3 images)In the browser3D browser games built from GLB files.Each tab is one of our own 3D game templates, recorded while it plays: Crowd runner, Endless runner, Tower defense and Car match. They run in an ordinary browser tab on three.js, with nothing to install, and every model on screen arrives as a GLB from the template's own models folder, listed on the right with its real size, biggest first.The counts show how much a small game leans on the format. Crowd runner ships 5 models, the endless runner 14, Tower defense 13 and Car match 19, from a 58 KB street lamp to a 606 KB soldier. When you start from one of these templates its models stay in place, and any model generated for your idea lands in the same folder as a GLB too, so a new character stands beside the old ones without a conversion step.Crowd runnerEndless runnerTower defenseCar matchevonx.ai/games/templates/crowd-runnerthree.js · GLBpublic/assets/models/5 GLB files · 818,104 BGLBarch.glb401 KBGLBflag.glb178 KBGLBrunner.glb124 KBGLBhedge.glb63 KBGLBtree.glb53 KBLoad pathWhat a game does with a GLB, step by step.Pick a file and follow it down the line. First the bytes are fetched: 774,864 for the rigged character, 311,752 for the cannon from our Conveyor Smash template. The loader then splits the file at its chunk markers, reads the JSON to learn what is inside and hands each texture to the browser's image decoder, three WebP pictures for the character and one for the cannon.Next the geometry is built straight from the BIN chunk, because the GLB format stores vertices the way a graphics card reads them: 3,496 triangles for the character, 11,044 for the cannon. Last, the game measures the model's bounding box, sets it in the scene and, when it has a skeleton, plays a clip by name. The console under the steps shows the calls our games really make, starting with createGLTFLoader().loadAsync().character.glbcannon.glba rigged character✓Fetch the bytes774,864 B✓Split JSON and BINJSON 78,664 B · BIN 696,172 B✓Decode the textures3 × WebP 1024 px · 302,122 B✓Build the geometry3,496 triangles · 3,211 vertices✓Place it and play24 joints · idle · walk · runconst gltf = await createGLTFLoader().loadAsync("character.glb"); const box = new THREE.Box3().setFromObject(gltf.scene); scene.add(gltf.scene); player.play("run"); What you getA 3D game that loads in a browser tab.GLB, the web's 3D formatEvery model in an EvonX game is a GLB, loaded with three.js's glTF loader. No plug-in, no install: the game opens from a link on a phone or a laptop.Models at the size the game needsBecause models are fitted by their measured size, a model made in centimetres and one made in metres end up at the right height next to each other.Clips that match the codeThe game logic and the model agree on clip names, and the build checks that they do. You do not find out in the middle of a level that the jump has no animation.Nothing to convert or importYou never handle an FBX, an OBJ or an export dialog. The format, the scale and the direction are settled inside the build.Working in your own engine?Convert FBX to GLB, free, in your browser.If you are building the game yourself, the first chore is the format. The free converter turns an FBX into a GLB with its skeleton and animation clips, fixes scale and up axis, and never uploads your file.Open the FBX to GLB converterHonest limitsWhat it does not do.No upload of your own model fileToday the chat does not accept a 3D model file as an attachment. Models in an EvonX game are generated in the build or come from the asset library.A picture works insteadYou can attach a picture of your character or object. It can be used in the game as it is, or serve as the reference a new 3D model is built from.Generated 3D needs a paid planGenerating new 3D models is part of the paid plans and uses credits. Library models and the models a game template ships with are not behind that line.GLB onlyA game holds GLB files and nothing else. FBX, OBJ and loose glTF folders are not loaded by a game; that is what the converter is for in your own projects.QuestionsGLB files and 3D browser games, answered.What is a GLB file?A GLB file is a 3D model saved in the binary form of glTF 2.0. One .glb holds everything the model needs: the mesh, its materials and textures and, for a character, its skeleton and animations. Because nothing sits in a separate file, a GLB loads, travels and drops into a game as a single file. Every 3D model in an EvonX game is a GLB.What is the GLB format used for in a browser game?It is how 3D models reach the web. GLB stores geometry the way a graphics card reads it and packs meshes, materials, textures and animation into one file, so a game in a browser tab loads it directly, with nothing to install. three.js, the 3D library EvonX games run on, loads it with its GLTFLoader. That is why EvonX stores every model in a game as GLB.GLB vs glTF: what is the difference?They are the same format in two packages. A .gltf file is JSON text that describes the model and usually points to separate files: a .bin with the geometry and image files for the textures. A .glb packs that JSON, the