# Cryptovoxels Scripting API The scripting API has three main components: * Parcel * Feature * VoxelField This page describes the APIs. APIs are described using Typescript (so you can deduce the types), but is implemented in Javascript. There are more methods in the current implementation of the API, but you should try and only use the methods listed below as non-documented methods and accessors may be removed in future versions of the API. ## Parcel The main controller class for a parcel. A parcel has a voxelfield and multiple features (eg signs, polytext, .vox models, images). #### `id : string` Returns the token ID of the current parcel. #### `getFeatureById(id: string) : Feature` Returns a feature with the specified id if it exists in this parcel. let f = parcel.getFeatureById('elon') #### `getFeatureByUuid (uuid: string) : Feature` Returns a feature with the specified uuid if it exists in this parcel. We recommend that you use getFeatureById - but there are cases where you may want to use UUIDs. UUIDs are stable between edits and mutations to the parcel. let f = parcel.getFeatureByUuid('123e4567-e89b-12d3-a456-426655440000') #### `getFeatures() : Array<Feature>` Returns all the feature objects in a parcel. console.log(parcel.getFeatures().length) ## Feature Features are items that are attached to a parcel. They have a `position`, `rotation`, `scale` and `description`. The first three are of type [BABYLON.Vector3](https://doc.babylonjs.com/api/classes/babylon.vector3), the `description` is a javascript object. Position, rotation and scale are watched with an ES6 Proxy so will notice and reflect changes in world. #### `id : string` Return the scripting id of a feature. #### `uuid : string` Return the UUID of the feature. #### `position : BABYLON.Vector3` The position of the feature inside the parcel. eg - Move parcel 25cm to right: feature.position.x += 0.25 eg - Move parcel 1 metre up, left and into the screen: feature.position.addInPlace(new B.Vector3(1, 1, 1)) #### `rotation : BABYLON.Vector3` The rotation of the feature. Rotations are in [radians](https://www.mathsisfun.com/geometry/radians.html) (which is confusing I know I'm sorry but I'm used to them now). eg - Rotate parcel 90° feature.rotation.y += Math.PI / 2 eg - Rotate parcel 180° feature.rotation.x += 3.14 #### `scale : BABYLON.Vector3` The scale of the feature. eg - double size of feature feature.scale.multiplyInPlace(new BABYLON.Vector3(2, 2, 2)) eg - half width of feature feature.scale.x /= 2