mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-12-01 16:12:33 +00:00
5b2b149b40
Improved UDBScript to version 5: - Added Plane class - Added BlockMap, BlockEntry, and BlackMapQueryResult classes - Sector class - Added getLabelPositions method to get the position of sector labels (where tags, effects etc. are displayed) - Added support for JavaScript BigInt for UDMF fields. This means it's not necessary anymore to use UniValue to assign integers to new UDMF fields. Instead it can be done like this: sector.fields.my_int_field = 1n; - Added type information file (udbscript.d.ts)
45 lines
No EOL
1 KiB
JavaScript
45 lines
No EOL
1 KiB
JavaScript
/// <reference path="../../../udbscript.d.ts" />
|
|
|
|
`#version 4`;
|
|
|
|
`#name Jitter Vertices`;
|
|
|
|
`#description Jitters the selected vertices. If no vertices are selected all vertices in the map are jittered. Does not make sure that the resulting geometry is still valid.`;
|
|
|
|
`#scriptoptions
|
|
|
|
min
|
|
{
|
|
description = "Minimum jitter";
|
|
default = 0;
|
|
type = 1; // Integer
|
|
}
|
|
|
|
max
|
|
{
|
|
description = "Maximum jitter";
|
|
default = 16;
|
|
type = 1; // Integer
|
|
}
|
|
`;
|
|
|
|
// Gets a random value between min and max, then randomly make it negative
|
|
function getRandomValue(min, max)
|
|
{
|
|
return (Math.floor(Math.random() * (max-min)) + min) * (Math.random() < 0.5 ? 1 : -1);
|
|
}
|
|
|
|
// Get selected vertices
|
|
let vertices = UDB.Map.getSelectedVertices();
|
|
|
|
// No vertices selected? Get all vertices!
|
|
if(vertices.length == 0)
|
|
vertices = UDB.Map.getVertices();
|
|
|
|
// Jitter each vertex
|
|
vertices.forEach(v => {
|
|
v.position += [
|
|
getRandomValue(UDB.ScriptOptions.min, UDB.ScriptOptions.max),
|
|
getRandomValue(UDB.ScriptOptions.min, UDB.ScriptOptions.max),
|
|
];
|
|
});
|