Skip to content

Models - Geometry Module

anvil.api.models.geometry

Builders for Bedrock geometry files (*.geo.json).

The tree structure is enforced by the API itself: a :class:Geometry only creates root bones, and a :class:_Bone creates child bones, cubes and locators. A child bone always knows its parent, so the parent field of the compiled output is never written by hand.

Example
geo = Geometry("my_mob", texture_size=(64, 64))

body = geo.bone("body", pivot=(0, 12, 0))
body.cube(origin=(-4, 12, -2), size=(8, 12, 4), uv=(16, 16))

arm = body.bone("arm", pivot=(5, 22, 0))  # parent is "body"
arm.cube(origin=(4, 12, -2), size=(4, 12, 4), uv=(40, 16))
arm.locator("hand", position=(6, 12, 0))

geo.queue()

Geometry

Bases: AddonObject

A Bedrock geometry file (*.geo.json) built from a tree of bones.

bones property

All bones, parents always before their children.

geometry_identifier property

How entities and blocks reference this geometry: geometry.<namespace>.<name>.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

bone(name, pivot=(0, 0, 0), **options)

Creates a root bone (no parent) and returns it.

clone(name=None)

Returns an independent copy, optionally under a new name.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self 'AddonObject'

The instance of the current AddonObject.

merge(other, *, parent=None, prefix='')

Copies the bones of other into this geometry.

They become root bones, or children of parent. prefix is added to every copied bone name to avoid clashes. Texture size and bounds of this geometry are kept.

queue(directory=None)

Queues the addon object for processing and logs the event.

Parameters:

Name Type Description Default
directory str

The directory of the addon object.

None

Returns:

Name Type Description
self 'AddonObject'

The instance of the current AddonObject.

scale(factor, origin=(0, 0, 0))

Scales the whole model by factor around origin.

set_identifier_data(data)

Sets the data of the addon object.

Parameters:

Name Type Description Default
data any

The data to be set for the addon object.

required

translate(offset)

Moves the whole model by offset.