3D Model

A 3D Model node is the 3D mesh that provides a shape for your character or object. An entity can contain many 3D Models.

Function Description
castsShadow()

Returns whether this 3D Model casts shadow.

color()

Returns the color of the 3D Model.

globalDepth()

Returns the depth of the 3D Model in a 2D World.

isVisible()

Returns if the 3D Model is visible.

localAABB()

Returns the local “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

mesh()
position()

Returns the 3D Model’s position relative to its Entity.

receivesShadows()

Returns whether this 3D Model receives shadows.

rotation()

Returns the rotation of the 3D model.

scale()

Returns the scale of the 3D model.

setCastShadow(value)

Enables/disables shadow casting of the 3D Model.

setColor(r, g, b, a)

Sets the color of the 3D Model.

setGlobalDepth(value)

Set the depth of the 3D Model in a 2D World.

setMesh(meshModel)

Sets the mesh by using a Mesh Attribute value. A Mesh Attribute can be added to your script node by clicking the script node, then clicking “Add Attribute” in the bottom right of the screen. It is recommended to use this method when setting a mesh programmatically, because it avoids potential issues with multiple meshes with the same name.

setMesh(value)

Sets the mesh by using a string name.

setPosition(x, y, z)

Sets the position {x, y, z} of the 3D Model.

setReceiveShadows(value)

Enables/disables shadow receiving of the 3D Model.

setRotation(x, y, z)

Sets the rotation {x, y, z} of the 3D Model.

setScale(x, y, z)

Sets the scale {x, y, z} of the 3D Model.

setTexture(name)

Sets the texture of the 3D Model.

setTextureOffset(x, y)

Sets the offset of the texture assigned to the 3D Model. The texture is repeated if this is used.

setTextureScale(x, y)

Sets the scale of the texture assigned to the 3D Model. If the value is less than 0, the texture will be repeated.

setVisible()

Sets the visibility of the 3D Model.

textureOffset()

Returns the texture offset of the 3D Model.

textureScale()

Returns the texture scale.

transformedAABB()

Returns the relative “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

transformedOBB()

Returns the “oriented bounding box” for the 3D Model relative to its parent. OBB is more precise but more performance-heavy than AABB.

worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

worldOBB()

Returns the “oriented bounding box” for the 3d Model. OBB is more precise but more performance-heavy than AABB.


castsShadow()

Returns whether this 3D Model casts shadow.

Returns

boolean – true if the 3D Model casts a shadow, false if not

↑ Back to top


color()

Returns the color of the 3D Model. Each {red, green, blue, alpha} component is range 0-255.

Returns

Object – the {r, g, b, a} representation of the color.

↑ Back to top


globalDepth()

Returns the global depth of the 3D Model. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Returns

number value – The global depth of the 3D Model

↑ Back to top


isVisible()

Returns if the 3D Model is visible.

Returns

boolean true if the 3D Model is visible, false if the 3D Model is not.

↑ Back to top


localAABB()

Returns the local “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


mesh()

Returns

Mesh Model the mesh object of the 3D Model

↑ Back to top


position()

Returns the 3D Model’s position relative to its Entity.

Returns

Vec3 the {x, y, z} relative coordinates of the 3D Model.

function start(){
  let pos = this.entity().component("3D Model").position();
  log("position x: ", pos.x, " y: ", pos.y, " z:", pos.z);
}

↑ Back to top


recievesShadows()

Returns whether this 3D Model receives shadows.

Returns

boolean – true if the 3D Model receives shadows, false if not

↑ Back to top


rotation()

Returns the rotation of the 3D model.

Returns

Vec3 the {x, y, z} rotation of the 3D Model.

↑ Back to top


scale()

Returns the scale of the 3D model.

Returns

Vec3 the {x, y, z} scale of the 3D Model.

↑ Back to top


setCastShadow(value)

Sets whether this 3D Model casts a shadow.

Parameters

boolean value – true if the 3D Model casts a shadow, false if not

↑ Back to top


setColor(r, g, b, a)

Sets the color of the 3D Model.

Parameters

number r – the red component of the color
number g the green component of the color
number b the blue component of the color
number a (Optional) The alpha component of the color. Range: 0-255

↑ Back to top


setGlobalDepth(value)

Sets the global depth of the 3D Model. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Parameters

number value – The global depth of the 3D Model

↑ Back to top


setMesh(meshModel)

Sets the mesh by using a Mesh Attribute value. A Mesh Attribute can be added to your script node by clicking the script node, then clicking “Add Attribute” in the bottom right of the screen. It is recommended to use this method when setting a mesh programmatically, because it avoids potential issues with multiple meshes with the same name.

Parameters

MeshModel mesh – The Mesh Attribute that the 3D Model will be set to.

let model = this.entity().component("CharacterBody");
model.setMesh(this.attribute("mySphere")); // mySphere was created in the right sidebar when the script node was open.

↑ Back to top


setMesh(value)

Sets the mesh by using a string name.

Parameters

string value – name of the mesh that the 3D Model will be set to.

↑ Back to top


setReceiveShadows(value)

Sets whether this 3D Model receives shadows.

Parameters

boolean value – true if the 3D Model receives shadows, false if not

↑ Back to top


setPosition(x, y, z)

Sets the position {x, y, z} of the 3D Model.

Parameters

number x – The x-axis component of the position
number y – The y-axis component of the position
number z – The z-axis component of the position

↑ Back to top


setRotation(x, y, z)

Sets the rotation {x, y, z} of the 3D Model.

Parameters

number x – The x-axis component of the rotation
number y – The y-axis component of the rotation
number z – The z-axis component of the rotation

↑ Back to top


setScale(x, y, z)

Sets the scale {x, y, z} of the 3D Model.

Parameters

number x – The x-axis component of the scale
number y – The y-axis component of the scale
number z – The z-axis component of the scale

↑ Back to top


setTexture(name)

Sets the texture of the 3D Model.

Parameters

string name – The name of the texture to be applied to the 3D Model.

↑ Back to top


setTextureOffset(x, y)

Sets the offset of the texture assigned to the 3D Model. The texture is repeated if this is used.

Parameters

number x – the x offset of the texture
number y – the y offset of the texture

↑ Back to top


setTextureScale(x, y)

Sets the scale of the texture assigned to the 3D Model. If the value is less than 0, the texture will be repeated.

Parameters

number x – the x scale of the texture
number y – the y scale of the texture

↑ Back to top


setVisible()

Sets the visibility of the 3D Model.

Parameters

boolean value – true for visible, false for not visible.

↑ Back to top


textureOffset()

Returns the texture offset of the 3D Model.

Returns

Vec2 the {x, y} texture offset of the 3D Model

↑ Back to top


textureScale()

Returns the texture scale.

Returns

Vec2 the {x, y} scale of the texture assigned to the 3D Model.

↑ Back to top


transformedAABB()

Returns the relative “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


transformedOBB()

Returns the “oriented bounding box” for the 3D Model relative to its parent. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing relative OBB data

↑ Back to top


worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing world AABB data

↑ Back to top


worldOBB()

Returns the “oriented bounding box” for the 3d Model. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing OBB data

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?