--- order:993 --- ## Blocks You can add Blocks to PolyTrack using PolyModLoader ## Making a Category You can create a new block category using `pml.editorExtras.registerCategory` ```js pml.editorExtras.registerCategory(id, defaultId); ``` `id` is the category id
`defaultId` is the id of the block to be used as the category icon in the editor sidebar ## Registering a model In order for your blocks to have a custom model, you first have to register the model file which contains the models. Note that image textures are not supported by PolyTrack, only solid colors
You can register a model using `pml.editorExtras.registerModel` ```js pml.editorExtras.registerModel(url); ``` `url` is the url to the model file, preferrably in .glb format. Please use a link to the model directly, not relative links, as those are not supported by some devices. ## Registering a block Blocks can be registered with `pml.editorExtras.registerBlock` ```js pml.editorExtras.registerBlock(id, categoryId, checksum, sceneName, modelName, editorOverlap, [extraSettings]); ``` `id` is the block id
`categoryId` is the id of the category the block should be registered in
`checksum` is the checksum of the block
`sceneName` is the name of the scene the object is in in the model, the scene name can be set inside blender as seen in the screenshot below
![Scene Name](images/scene_name.png)
`modelName` is the name of the object in the scene which should be used as the block's model
`editorOverlap` is a list of pairs of coordinnates that make up the editor collision box of the block for detecting block overlaps. One pair of coordinates looks like this: `[[0,0,0],[1,1,1]]` ( makes a box from 0,0,0 to 1,1,1). I'm still in the process of figuring stuff out for this. `extraSettings` is optional. Putting `{ ignoreOnExport: true }` here will cause the block to be ignored on export. This can be used for several purposes, like the copy and paste pillars in the advanced PolyEditor mod. You can also have special setings for checkpoints and finishes. For example, this would be `extraSettings` for the normal road finish: ```js { type: "Finish", center: [0, 2.2, 0], size: [10.5, 3.8, 2] } ``` This correlates to the image below in blender: ![{7CD1A314-9A99-4E8F-A051-BBF6667FF4D5}](https://github-production-user-asset-6210df.s3.amazonaws.com/86059513/499428112-992ca853-e6d4-43ce-a2b9-c5cd0a2566aa.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20251009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20251009T153119Z&X-Amz-Expires=300&X-Amz-Signature=bb11d292e12933ac3c79d0196fda586991fb8045e5f46a953dce37e6c252b4d7&X-Amz-SignedHeaders=host) Note that Y and Z are switched and that scale is divided by two.