Canvas

Canvas

Namespace

A global namespace handling miscellaneous functionality related to the 3D preview

PropertyTypeDescription
materialsSee types
emptyMaterialsSee types
meshesSee types
bonesSee types
sceneTHREE.SceneMain scene, shared across all tabs
gizmosArrayList of the gizmos (control and UI elements) in the 3D scene
outlineMaterialTHREE.LineBasicMaterialThe material used for all selection outlines
meshOutlineMaterialTHREE.LineBasicMaterial
onionSkinEarlierMaterialTHREE.LineBasicMaterial
onionSkinLaterMaterialTHREE.LineBasicMaterial
wireframeMaterialTHREE.MeshBasicMaterialThe material used for the wireframe view
solidMaterialTHREE.ShaderMaterial
normalHelperMaterialTHREE.ShaderMaterial
uvHelperMaterialTHREE.ShaderMaterial
meshVertexMaterialTHREE.PointsMaterial
transparentMaterialTHREE.MeshBasicMaterial
gridMaterialTHREE.LineBasicMaterialThe material used for the grids
pivot_markerTHREE.Object3D
global_light_colorTHREE.Color
global_light_sidenumber
face_orderArray

raycast( event )

Raycast on the currently selected preview

Arguments:

Returns: any

withoutGizmos( cb )

Execute the callback function without any gizmos, grids and helpers visible

Arguments:

clear()

Clear all elements from the scene

buildGrid()

updateShading()

updateView( options )

Updates selected aspects of the preview

Arguments:
  • options: UpdateViewOptions -
    • elements: Array of OutlinerElement (Optional) - List of elements to update
    • element_aspects: See types (Optional) - Which aspects of the elements to update
    • groups: Array of Group (Optional) - Groups to update
    • selection: boolean (Optional) - Whether to update the selection (updates the selection outlines and interface)

updateAll()

Regenerate all elements in the scene. Very unoptimized, use with care

updateAllPositions()

Update the position and shape of all elements

updateVisibility()

Update the visibility of all elements

updateAllFaces( [texture] )

Update all faces in the scene

Arguments:
  • texture: Texture (Optional) - Texture filter. If specified, only faces with this texture will be updated

updateAllUVs()

Update all UV maps in the scene

getRenderSide()

Returns the three.js render sides based on the current settings and state

Returns: number

updateRenderSides()

Update render sides of all materials

updateSelected( arr )

Redraw the selected elements in the scene

Arguments:
  • arr: any - Optionally specify an array of elements to update

updatePositions( [y] )

Update positions and shapes of the selected elements

Arguments:
  • y: number (Optional)

updateSelectedFaces()

Update the faces of all selected elements (material, UV map)

updateUVs()

Update the UV maps of all selected elements

updateAllBones()

Update the hierarchy and position of all bones

updateOrigin()

Update the position of the origin / pivot point gizmo

Returns: boolean

adaptObjectPosition( cube[, mesh] )

Update the position and shape of the specified cube

Arguments:
  • cube: Cube - Cube to update
  • mesh: Mesh (Optional) - Mesh instance of the cube

adaptObjectFaceGeo( cube )

Update the geometry faces of the specified cube

Arguments:
  • cube: any - Cube to update

adaptObjectFaces( cube, mesh )

Update the faces (material) of the specified cube

Arguments:
  • cube: any - Cube to update
  • mesh: any - Mesh instance of the cube

updateLayeredTextures()

Update the layered or not layered material of all elements

updateUV( cube[, animation] )

Update the UV map of the specified cube

Arguments:
  • cube: Cube - Cube to update
  • animation: boolean (Optional) - Whether to display the current animated texture frame

Returns: any

updateMarkerColorMaterials()

Update the materials of marker colors if new colors were added

outlineObjects( arr )

Create an additional outline around the specified cubes

Arguments:
  • arr: Array of Cube - List of cubes to outline

getModelSize()

Calculate the size of the model, in the currently displayed shape. Returns [width, height] in blockbench units

Returns: Array

TickUpdates

Namespace

Marks a specific aspect of the interface to be updated in the next tick. Useful to avoid an update function getting called multiple times in the same task.

PropertyTypeDescription
outlinerundefined or true
selectionundefined or true
main_uvundefined or true
texture_listundefined or true
keyframesundefined or true
keyframe_selectionundefined or true
keybind_conflictsundefined or true

NodePreviewController

new NodePreviewController( type, options )

Creates a new NodePreviewController

Arguments:
  • type: or
  • options: NodePreviewControllerOptions
    • mesh: THREE.Object3D or Mesh (Optional) - NOTE: This option is just for type checking and should not be set in the options object. It should be set inside of the setup function via this.mesh
setup(element) {
  this.mesh = new THREE.Mesh()
}
* `setup`: Function (Optional)
* `remove`: Function (Optional)
* `updateAll`: Function (Optional)
* `updateTransform`: Function (Optional)
* `updateVisibility`: Function (Optional)
* `updateSelection`: Function (Optional)
* `updateGeometry`: Function (Optional)
* `updateUV`: Function (Optional)
* `updateFaces`: Function (Optional)
* `updatePaintingGrid`: Function (Optional)
* `updateHighlight`: Function (Optional)
PropertyTypeDescription
type
eventsSee types
meshTHREE.Object3D or Mesh

dispatchEvent( event_name, data )

Arguments:
  • event_name: string
  • data: Record

on( event_name, cb )

Adds an event listener

Arguments:

once( event_name, cb )

Adds a single-use event listener

Arguments:

removeListener( event_name, cb )

Removes an event listener

Arguments:

setup( element )

Arguments:

remove( element )

Arguments:

updateAll( element )

Arguments:

updateTransform( element )

Arguments:

updateVisibility( element )

Arguments:

updateSelection( element )

Arguments:

updateGeometry( instance )

Arguments:

updateUV( instance )

Arguments:

updateFaces( instance )

Arguments:

updatePaintingGrid( instance )

Arguments:

updateHighlight( instance, args )

Arguments: