resourcepack.ai
DOCS

3D models

3D Engine

3D Engine puts real 3D models into vanilla Minecraft. Drop a .glb, .gltf or .obj file into a folder on your server, run /3d reload, and it is in the game: the actual mesh, with its own textures and animations, not a blocky remake. Furniture, statues, vehicles, props and creatures, anything you can download from Sketchfab or export from Blender.

A real 3D car model standing on grass in Minecraft

The plugin bakes each file into a form the game can draw, builds a resource pack from them and sends it to players as they join. Players install nothing.

What you need#

  • Spigot or Paper on Minecraft 26.3, with Java 21. Players need to be on 26.3 too.
  • Nothing else. Models that walk use Paper's pathfinding on Paper and the engine's own on Spigot; everything else is the same on both.

Installing#

  1. 1

    Get the jar

    Download 3DEngine.jar (always the current release), or get it from SpigotMC.

  2. 2

    Drop it in and start the server

    Put it in plugins/. On first start it makes:

    plugins/3DEngine/
      config.yml
      models/     ← your 3D files
      effects/    ← shader effects, optional
      cache/      ← baked models, kept between restarts
      pack.zip    ← the resource pack it built
  3. 3

    The pack reaches players by itself

    The plugin uploads its pack to ResourcePack AI's free pack host (packs.resourcepack.ai) and players download it from there, so there is no port to open. It is only uploaded again when it changes, it is kept while your server uses it, and only the Minecraft client can download it.

    The host takes packs up to 95 MB. A bigger pack (lots of animated models) is served by your server instead, on port 8163: open that port and set pack.url to the address players reach it on, such as http://play.example.com:8163. The console says when this happens. To always serve it yourself, set pack.host: serve.

  4. 4

    Add a model

    Put a model file in plugins/3DEngine/models/ and run /3d reload. Then look at a block and run /3d place <model>.

The resource pack#

Every /3d reload builds a new pack, writes it to plugins/3DEngine/pack.zip and serves it. Players get it as they join, and everyone online is sent the new one when a reload changes it.

Already sending your own pack? Set pack.send: false and merge pack.zip into yours after every reload. /3d pack sends you the engine's pack again, to check it arrives.

Adding your own files to it. Anything in plugins/3DEngine/pack/ goes into the pack at the same path, on the next reload: assets/myserver/sounds.json and its sounds, a font, an item model. Use a namespace of your own. A file at a path the engine writes itself (its shaders and models) is left out.

The pack replaces some of the game's shaders

Models are drawn by core shaders, so the pack replaces the game's block, entity, item and terrain shaders, and also text when you have any shader effects.

Only one pack can replace a given shader. If another pack on the same client replaces one of these, whichever is higher in the list wins and the other's drawing breaks. That includes other plugins that use the text shader, such as RP Engine's shader objects. The models themselves live in a 3dengine namespace and override nothing vanilla.

Adding models#

  • Formats: .glb, .gltf and .obj. Put an .obj file's .mtl and textures, or a .gltf file's .bin and textures, beside it.
  • Names: a model's name is its path under models/, lower case, without the extension: models/furniture/armchair.glb is furniture/armchair.
  • Sketchfab downloads go in as they come. Drop the .zip into the models folder and the next reload unpacks it into a folder of the same name. A scene.gltf (what every Sketchfab download contains) takes its folder's name, and its .yml is scene.yml beside it. Delete the unpacked folder to unpack the zip again.
  • Baking is cached. A reload only re-bakes models whose file, .yml or detail settings changed. It runs off the main thread, and /3d reload reports how many models and effects are ready, which failed and why, and how big the pack is.

/3d list shows every model with its height and states. /3d info <model> adds its width, points, seats, hitboxes and what it costs the client.

Placing models#

/3d place <model> [scale] puts a model on the block you look at, facing you. /3d give <model> [player] gives a model item: right-click a block to put the model there. The item shows the model as its icon and is not used up. Placed models are saved with the world.

To change a placed model, look at it (within eight blocks) and use /3d remove, /3d scale <n>, /3d rotate <degrees>, /3d state <state> or /3d sit [seat].

Sitting down. Right-click a model with seats to sit in the nearest free one (everyone has 3dengine.ride by default). Sneak to get off. Right-clicking while sneaking never sits you down.

The model's .yml#

Any model file can have a .yml of the same name beside it: armchair.glb and armchair.yml. Every key is optional. Without one, a model comes in at its own size with one looping state per animation in the file (or a single still one).

Positions in blocks (seats, hitboxes) are measured from the middle of the model's base: x to its right, y up, z forward.

Any key 3D Engine doesn't use is kept for plugins to read, so an addon can keep its own settings beside a model.

Size and placement#

height: 1.8            # resize to this many blocks tall
# scale: 0.5           # or: blocks per unit in the file (ignored when height is set)
yaw: 90                # turn it so its front faces the way it is placed
offset: [0, 0, 0]      # move it, in blocks, after resizing
hide: [Ground, Camera] # leave out parts of the file by node or bone name
icon-scale: 1          # how big it is drawn as an item icon; fitted if left out

hide is for the extras a downloaded file often carries: a ground plane, a backdrop, a camera. Everything under a hidden node goes with it.

States and animation#

A state is an animation the model loops: idle, walk, open. Without a states: block every clip in the file becomes one, named after the clip in lower case.

default-state: idle
states:
  idle: {clip: Idle, fps: 10, syncs: 2}
  walk: {clip: Walk, fps: 20, wait: true}
  sit:  {clip: Idle, pose: {Body: {rotate: [-40, 0, 0], translate: [0, -0.3, 0]}}}
  shuffle: {clip: Walk, blend: {clip: Idle, weight: 0.45}}
transition-frames: 6
transitions:
  - idle <-> walk
  - {from: idle, to: sit, frames: 12}
KeyDefaultWhat it does
clipThe animation in the file. A state with no clip is a still pose
fps10Frames baked per second. More is smoother and makes a bigger pack
syncs1How many evenly spaced points in the loop it can leave from
sync-atOr the exact ticks it can leave from
waitfalseWait for a sync point before leaving, rather than cutting at the nearest
poseBones turned (degrees) or moved on top of the clip
blendMix in another clip: clip, weight (0 to 1) and at (seconds into it)

default-state is where a model starts: idle if there is one, otherwise the first state.

A transition is a short blend from one state into another. a -> b is one way, a <-> b both ways, and the map form takes frames and both-ways: true. Each lasts transition-frames ticks (default 6) unless it says otherwise. Without one, a state change cuts straight across.

Animations from another file. animations-from: other.glb drives this model with that file's clips, matched by bone name, and the other file is not loaded as a model. retarget: {translate: [Body]} limits which bones' movement carries over (all by default), and rebind: [Bone] moves the vertices of a bone nothing animates onto its neighbors. legs: lists IK chains, {chain: [Upper, Lower], target: IKFoot}, that keep feet planted.

Points#

Named places that follow a bone through every animation, such as a mouth or a hand, for plugins to attach things to:

points:
  mouth: {bone: Head, at: [0, 2.1, 2.4]}

Looking at players#

look:
  bone: Head           # only the head turns; leave out to turn the whole model
  with: [Jaw]          # more bones that turn with the head
  yaw: 70              # the most it turns either way, in degrees
  pitch: 35
  range: 8             # blocks
  speed: 9             # degrees per tick
  states: [idle, sit]  # the states it looks in; all if left out

look: true turns the whole model with these defaults, and look: Head does the same with a head bone. A turning head is drawn as a second model, so it costs one more item model per animation. Bones beside the head whose vertices sit inside it (a jaw, ears) turn with it anyway; with: adds any it misses.

Seats and driving#

seats:
  driver: {at: [-0.4, 0.5, 0.2]}
  passenger: {at: [0.4, 0.5, 0.2], bone: Body, pose: standing}
drive:
  seat: driver         # whose rider steers; the first seat if left out
  speed: 0.2           # blocks per tick
  sprint: 0.32
  back: 0.08
  turn: 7              # degrees per tick
  jump: 0.42           # 0 = it can't jump
  brain: horse         # the invisible mob that carries it; picked by size if left out

A seat's at is where the rider's hips go, or their feet with pose: standing. With a bone the seat follows that bone through every animation.

With drive:, whoever sits in the driving seat steers: the model goes where they look while they hold forward. drive: true uses the defaults above. The brain is an invisible mob under the model that does the moving, and its size decides which gaps the model fits through.

If riders sit a little high or low, seats.height-offset in config.yml moves every seat at once.

Hitboxes and solid models#

hitboxes:
  - {at: [0, 0, 0.6], width: 1, height: 1.2}
solid: true

Hitboxes make a model clickable. Unless you write your own they are fitted to the model: one box, or a row of up to six along a long model, so a car can be clicked at either end. hitbox: {at, width, height} is a single box of your own, and hitbox: false makes the model unclickable.

solid: true fills a placed model's boxes with barrier blocks so nobody walks through it. Barriers only go in empty blocks, never where a rider sits, and are removed when the model is removed, moved or resized. A model that moves is never solid.

Held as an item#

item: true lets the model be held. To set how it sits in each view, give a map of display contexts, as a block model's display does:

item:
  thirdperson_righthand: {rotation: [0, 90, 0], translation: [0, 2, 1], scale: 0.6}
  firstperson_righthand: {rotation: [0, 90, 0], scale: 0.5}

Walking#

locomotion: tells a model that walks which states to play and when:

locomotion:
  idle: idle
  walk: walk
  run: run
  turn: turn          # turning on the spot
  walk-above: 0.035   # blocks per tick
  run-above: 0.13

Each name defaults to the state of that name, if there is one. Plugins make models walk through the API.

Detail and pack size#

Each model is cut to a number of triangles, and its texture to a width, when it is baked. More is sharper, but makes the pack bigger and the game heavier for players. An animated model stores its whole mesh once per frame and its texture once per animation, so the texture is usually what makes a pack big.

SettingWhereWins over
/3d quality <model> <triangles> [texture width]In game, saved to quality.models in config.ymleverything
triangles: and texture-width:The model's .ymlthe server defaults
quality.triangles and quality.texture-widthconfig.yml (20,000 and 512)nothing

Nothing keeps more than quality.max-triangles (200,000) or quality.max-texture-width (2,048).

/3d quality alone shows the defaults and every per-model setting; with a model it shows that model's. Setting one re-bakes it straight away. Because it lives in config.yml, a plugin that re-copies its own model files cannot undo it. /3d quality <model> reset goes back to the model's own settings.

Shader effects#

An effect is a small GLSL program drawn into the world: a fireball, a puff of flame, a black hole. Put .glsl files in plugins/3DEngine/effects/ and run /3d reload. /3d effect <name> [size] puts one where you look, size blocks across. /3d effect alone lists them, and /3d effect clear removes every one the command put down. Effects are not saved, so a restart clears them too.

An effect file defines one function, from a ray to a color:

vec4 object(vec3 ro, vec3 rd, float t0, float t1, float time, vec3 light, inout float depth) {
    // ...
}

Each file is checked before it reaches anybody's graphics card and refused if it breaks a rule. The reload names any that were refused and why.

  • No while or do loops. Every for loop needs a literal bound of at most 160.
  • No preprocessor directives, uniforms, samplers, textures or gl_ built-ins.
  • No main() and no discard (return an alpha of 0 instead).
  • At most 20,000 characters, and up to 255 effects.

Effects replace the text shader

The text shader is only replaced when the effects folder has an effect in it. Leave the folder empty if another plugin on your server needs that shader.

Commands#

/3d, or /engine3d. /3d alone lists the subcommands you may use. From the console, a player's name at the end runs a command as that player: /3d effect fire 2 Steve.

CommandWhat it doesPermission
/3d listEvery model, its height and states, and any that failed to bake3dengine.list
/3d place <model> [scale]Places a model on the block you look at3dengine.place.command
/3d give <model> [player]A model item that places the model where it is used3dengine.give (.give.others for another player)
/3d removeRemoves the model you look at3dengine.remove
/3d scale <n>Resizes it. 1 is normal size3dengine.scale
/3d rotate <degrees>Turns it3dengine.rotate
/3d state <state>Plays one of its states3dengine.state
/3d sit [seat]Sits you in it, in a named seat or the nearest free one3dengine.sit
/3d info [model]Size, states, points, seats, hitboxes and client cost3dengine.info
/3d quality [model] [triangles|reset] [texture width]Shows detail settings, or sets one model's and re-bakes it3dengine.quality
/3d effect <name> [size]Puts down a shader effect. /3d effect clear removes them3dengine.effect
/3d reloadRe-reads config.yml, re-bakes the models folder and re-sends the pack3dengine.reload
/3d packSends you the pack again3dengine.pack

Permissions#

All op-only by default except 3dengine.ride. Somebody without a command's node is told which one they need.

NodeWhat it allows
The command nodes aboveThat command
3dengine.placePlacing models with a model item from /3d give. A player without it can hold the item, but using it places nothing
3dengine.rideSitting in a model's seats by right-clicking it. Everyone by default
3dengine.updateBeing told on joining that a newer 3D Engine is out
3dengine.adminEvery command node and 3dengine.place, but not ride or update

3dengine.place.command (any model, anywhere) is separate from 3dengine.place (using an item you were given) so you can hand out model items without handing out /3d place.

/lp group builder permission set 3dengine.give true
/lp group builder permission set 3dengine.place true
/lp group admin permission set 3dengine.admin true

Configuration#

plugins/3DEngine/config.yml. /3d reload applies changes, except pack.host, pack.port and pack.bind, which need a restart (the reload tells you). If the file has a mistake, the reload says so and keeps the settings it had, and /3d quality refuses to save over it.

KeyDefaultWhat it does
pack.hostuploadupload to ResourcePack AI's pack host, serve from this server over HTTP, or none
pack.port8163The port it is served on (serve, or a pack too big to upload)
pack.bindemptyThe address to listen on. Empty is all of them
pack.urlemptyThe address players download it from
pack.sendtrueSend it to players as they join
pack.requiredfalseKick players who decline it
pack.promptemptyThe message on the download prompt
pack.format[97, 1]The pack format. Leave it alone
pack.description3D Engine modelsThe pack's description
quality.triangles20000Default triangles per model
quality.texture-width512Default texture width
quality.max-triangles200000The most any model may keep
quality.max-texture-width2048The widest any texture may be
quality.models{}Per-model settings, written by /3d quality
seats.height-offset0.0Raise (or, negative, lower) every seated rider, in blocks
update-checktrueAsk SpigotMC as the server starts for a newer version, and tell the console and anyone with 3dengine.update
telemetrytrueAn anonymous usage count sent to resourcepack.ai every 30 seconds: a random id, the number of players online and the names of plugins that depend on 3D Engine. No addresses, server names, player names or content

Developer API#

Add depend: [3DEngine] to your plugin.yml, compile against 3DEngine.jar as a compile-only dependency, and call Engine3D.get():

Engine3D engine = Engine3D.get();
engine.whenReady(() -> {
    ModelInstance chair = engine.place("furniture/armchair", location); // saved with the chunk
    chair.mount(player, null);              // into the nearest free seat
    chair.lookAt(player);                   // or lookAround(), lookAway()
 
    ModelInstance dog = engine.spawn("dog", location);                  // not saved
    Mover legs = engine.mover(dog, EntityType.WOLF);
    legs.follow(player);
});

whenReady runs once every model is baked, and again after every /3d reload, so you can respawn what you drew against the new models. A plugin can copy its own model files into engine.modelsFolder() in onEnable: the first bake waits for the first tick.

TypeWhat it is
Engine3DModels and instances: spawn (not saved), place (saved), mover, item(model, state) for an item that looks like the model, effect, particle and their variants, and packFolder() for files your plugin adds to the pack
ModelA baked model: its states, points, seats, height, and the extra keys from its .yml
ModelInstanceOne model in the world: change state, find where a point is on any frame, scale, seat riders, look at things, turn hitboxes on and off
MoverLegs for a model: an invisible mob that follows, goes to a place, faces, and plays walk, run and turn to match its speed
EffectInstance, ParticleShader effects placed in the world, and ones the engine moves

Engine3D.instance(entity) finds the model any of its entities belongs to: its display, head, a hitbox, a seat or its brain. Engine3D.near(location, radius) lists the models around a place, nearest first, and ModelInstance.mover() is the mover walking a model about, if it has one (both since 0.1.6).

Events#

All in ai.resourcepack.engine3d.api.event:

EventWhenCancel to
ModelInteractEventA player right-clicks a modelStop the default (sitting down)
ModelDamageEventA player punches it, or a projectile or mob hits itTell later listeners
ModelMountEventSomething is about to sit in a seatKeep them off
ModelDismountEventA rider is getting offKeep them on, when isCancellable()
ModelStateChangeEventA new state's loop starts
ModelSpawnEvent / ModelRemoveEventA model is put down / taken away

A model has no health of its own: what a hit does is up to you. 3D Pets is an addon built on nothing but this API.

Credits#

The meshes are drawn by obj³, after Godlander's objmc. Its core shaders ship in the pack, with their license.