I recently spent some time studying craft.voxels and found that it was well designed, but it didn’t seem to have many users working on formal projects, and I wanted to use it to develop an educational app, but in the process of learning to use it encountered many difficulties, but also some gains. I’d like to share it here so that more users are interested in craft.voxels and we can talk about all the voxels issues together.
For everyone who wants to get to know craft.voxels better, here’s a document I’ve compiled of all the voxels’available functions. This is the most comprehensive information I have been able to gather so far. If you know something I missed, please add it. Thank you.
The hierarchy of Voxels system
The `Voxels system has three levels:
- voxel?
craft.voxels
- block?
craft.blocks
- volume?
craft.volume
voxels
is the most basic unit and provides many basic properties and methods?
- read-only property:
- blocks
- visibleChunks
- generatingChunks
- meshingChunks
- read-write property:
- coordinates
- visibleRadius
- method:
- resize()
- set()
- get()
- fill()
- fillstyle
- find()
- block()
- sphere()
- box()
- line()
- updateBlock()
- raycast()
- generate()
- isRegionLoaded()
- iterateBounds()
- enableStorage()
- disableStorage()
- deleteStorage()
Based on craft.voxels
?craft.blocks
?made up of multiple voxels
, there are two types?
- The default block type built into the system:
- SOLID
- EMPTY
- User-defined type of box: freely named
For user-defined block type
? Have the following properties and methods?
- read-only property:
- id
- name
- state
- model
- read-write property:
- geometry
- renderPass
- tinted
- dynamic
- scripted
- position property:
- x
- y
- z
- method:
- setTexture()
- setColor()
- craft.block.directionToFace()
- craft.block.faceToDirection()
Because block type
supports scripting, there are methods that can only be used for scripting?
- methods for
blockType
internal scripts:- blockType:created()
- blockType:destroyed()
- blockType:buildModel()
- blockType:placed()
- blockType:interact()
- blockType:blockUpdate()
- blockType:update()
- set()
- get()
- schedule()
- xyz()
-
block.state
provides the method:- blockType.state.addFlag()
- blockType.state.addRange()
- blockType.state.addList()
-
block.model
provides the method:- clear()
- rotateY()
- rotateX()
- addElement() There are special parameters required(I am not so clear if there are other parameters?)
- lower = vec3(128,128,128)
- upper = vec3(255,255,255)
- collision = STEP
- textures = “Blocks:Grass”
- ao = false
craft.volume
is the higher level of abstraction provided by the craft.voxels` system, which is designed as a component that can be attached to an entity (providing three forms of syntax for attaching) . It provides the following properties and methods:
- property:
- model
- method:
- size()
- get ()
- set ()
- raycast ()
- clear ()
- resize ()
- load ()
- save ()
- loadSnapshot ()
- saveSnapshot ()
- blockID ()
- setWithNoise ()
- updateBlock ()
There is also a constructor?VolumeSnapshot()
An global method: bounds(min, max)
- read-only property:
- min: vec3
- max: vec3
- valid: Boolean
- center: vec3
- offset: vec3
- size: - method:
- intersects(),
- encapsulate(),
- translate(),
- set()