6
3
Fork
You've already forked PolyModLoader
6
9 Blocks
0rangy edited this page 2025年10月09日 17:31:45 +02:00

Blocks

You can add Blocks to PolyTrack using PolyModLoader

Making a Category

You can create a new block category using pml.editorExtras.registerCategory

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

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

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
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:

{
 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} Note that Y and Z are switched and that scale is divided by two.