UDBScript: Exported the classes Linedef, Sector, Sidedef, Thing, and Vertex, so that they can be used with instanceof

UDBScript: Map class: the getSidedefsFromSelectedLinedefs() method now correctly only returns the Sidedefs of selected Linedefs in visual mode (and not also the highlighted one)
UDBScript: Map class: added a new getSidedefsFromSelectedOrHighlightedLinedefs() method as the equivalent to the other getSelectedOrHighlighted*() methods
UDBScript: Sector class: added new floorSelected, ceilingSelected, floorHighlighted, and ceilingHighlighted properties. Those are mostly useful in visual mode, since they always return true when the Sector is selected or highlighted in the classic modes. The properties are read-only
UDBScript: Sidedef class: added new upperSelected, middleSelected, lowerSelected, upperHighlighted, middleHighlighted, and lowerHighlighted properties. Those are mostly useful in visual mode, since they always return true when the parent Linedef is selected or highlighted in the classic modes. The properties are read-only
UDBScript: added new example to apply textures for floor/ceiling and upper/middle/lower texture for selected map elements
UDBScript: updated documentation
This commit is contained in:
biwa 2021-12-25 14:43:56 +01:00
parent ca7b9e8b7e
commit 634225b77b
26 changed files with 1066 additions and 6 deletions

View file

@ -0,0 +1,41 @@
`#name Apply textures to selected surfaces`;
`#description Applies LAVA1 to the selected floors/ceilings, and FIREBLU1 to the selected upper/middle/lower sidedefs. Mostly useful in visual mode`;
`#version 3`;
// Get all selected or highlighted sectors and sidedefs
let elements = Map.getSelectedOrHighlightedSectors().concat(Map.getSidedefsFromSelectedOrHighlightedLinedefs());
// Since the array might contain both selected sectors and highlighted sidedefs (or vice versa)
// we have to filter the array, so that we really only work on the correct map elements, i.e.
// either the single highlighted one, or all selected ones
elements.filter(e => {
if( elements.length == 1 ||
(e instanceof Sector && (e.floorSelected || e.ceilingSelected)) ||
(e instanceof Sidedef && (e.upperSelected || e.middleSelected || e.lowerSelected))
) return true;
return false;
}).forEach(e => {
// Check for each sector and sidedef which part is selected/highlighted and
// apply the textures accordingly
if(e instanceof Sector)
{
if(e.floorSelected || e.floorHighlighted)
e.floorTexture = 'LAVA1';
if(e.ceilingSelected || e.ceilingHighlighted)
e.ceilingTexture = 'LAVA1';
}
else if(e instanceof Sidedef)
{
if(e.lowerSelected || e.lowerHighlighted)
e.lowerTexture = 'FIREBLU1';
if(e.middleSelected || e.middleHighlighted)
e.middleTexture = 'FIREBLU1';
if(e.upperSelected || e.upperHighlighted)
e.upperTexture = 'FIREBLU1';
}
});

View file

@ -2248,6 +2248,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
return sectors; return sectors;
} }
/// <summary>
/// Determines if the floor and/or ceiling of a sector is selected.
/// </summary>
/// <param name="sector">The sector to check</param>
/// <param name="floor">If floor is selected or not</param>
/// <param name="ceiling">If ceiling is selected or not</param>
public void GetSelectedSurfaceTypesBySector(Sector sector, out bool floor, out bool ceiling)
{
floor = ceiling = false;
foreach(IVisualEventReceiver i in selectedobjects)
{
if (i is VisualFloor && ((VisualFloor)i).Level.sector == sector)
floor = true;
else if (i is VisualCeiling && ((VisualCeiling)i).Level.sector == sector)
ceiling = true;
}
}
// This returns all selected linedefs, no doubles // This returns all selected linedefs, no doubles
public List<Linedef> GetSelectedLinedefs() public List<Linedef> GetSelectedLinedefs()
{ {
@ -2277,6 +2296,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
return linedefs; return linedefs;
} }
/// <summary>
/// Determines if the upper/middle/lower parts of a sidedef are selected.
/// </summary>
/// <param name="sidedef">The sidedef tzo check</param>
/// <param name="upper">If the upper part is selected</param>
/// <param name="middle">If the middle part is selected</param>
/// <param name="lower">If the lower part is selected</param>
public void GetSelectedSurfaceTypesBySidedef(Sidedef sidedef, out bool upper, out bool middle, out bool lower)
{
upper = middle = lower = false;
foreach(IVisualEventReceiver i in selectedobjects)
{
if (i is VisualUpper && ((VisualUpper)i).Sidedef == sidedef)
upper = true;
else if ((i is VisualMiddleSingle || i is VisualMiddleDouble || i is VisualMiddleBack) && ((BaseVisualGeometrySidedef)i).Sidedef == sidedef)
middle = true;
else if (i is VisualLower && ((VisualLower)i).Sidedef == sidedef)
lower = true;
}
}
// This returns all selected sidedefs, no doubles // This returns all selected sidedefs, no doubles
public List<Sidedef> GetSelectedSidedefs() public List<Sidedef> GetSelectedSidedefs()
{ {
@ -2293,11 +2334,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// Add highlight? // Add highlight?
/*
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef)) if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
{ {
Sidedef sd = ((BaseVisualGeometrySidedef)target.picked).Sidedef; Sidedef sd = ((BaseVisualGeometrySidedef)target.picked).Sidedef;
if(!added.Contains(sd)) sidedefs.Add(sd); if(!added.Contains(sd)) sidedefs.Add(sd);
} }
*/
return sidedefs; return sidedefs;
} }

View file

@ -924,9 +924,10 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
/// <summary> /// <summary>
/// Gets all `Sidedef`s from the selected `Linedef`s. /// Gets all `Sidedef`s from the selected `Linedef`s.
/// In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
/// </summary> /// </summary>
/// <param name="selected">`true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s</param> /// <param name="selected">`true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s</param>
/// <returns></returns> /// <returns>`Array` of `Sidedef`</returns>
public SidedefWrapper[] getSidedefsFromSelectedLinedefs(bool selected = true) public SidedefWrapper[] getSidedefsFromSelectedLinedefs(bool selected = true)
{ {
List<SidedefWrapper> sidedefs = new List<SidedefWrapper>(); List<SidedefWrapper> sidedefs = new List<SidedefWrapper>();
@ -948,6 +949,32 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
return sidedefs.ToArray(); return sidedefs.ToArray();
} }
/// <summary>
/// Gets the `Sidedef`s of the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, the `Sidedef`s of the currently highlighted `Linedef`.
/// In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
/// </summary>
/// <returns>`Array` of `Sidedef`s</returns>
/// <version>3</version>
public SidedefWrapper[] getSidedefsFromSelectedOrHighlightedLinedefs()
{
List<SidedefWrapper> sidedefs = new List<SidedefWrapper>(getSidedefsFromSelectedLinedefs(true));
if(sidedefs.Count > 0)
return sidedefs.ToArray();
// Nothing selected, so let's see if anything is highlighted
LinedefWrapper highlight = getHighlightedLinedef();
if (highlight != null)
{
if (highlight.front != null)
sidedefs.Add(highlight.front);
if (highlight.back != null)
sidedefs.Add(highlight.back);
}
return sidedefs.ToArray();
}
/// <summary> /// <summary>
/// Clears all selected map elements. /// Clears all selected map elements.
/// </summary> /// </summary>

View file

@ -27,8 +27,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Dynamic; using System.Dynamic;
using CodeImp.DoomBuilder.BuilderModes;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.VisualModes;
#endregion #endregion
@ -199,6 +202,122 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
} }
} }
/// <summary>
/// If the `Sector`'s floor is selected or not. Will always return `true` in classic modes if the `Sector` is selected. Read-only.
/// </summary>
/// <version>3</version>
public bool floorSelected
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the floorSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool f, c;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySector(sector, out f, out c);
return f;
}
else
{
return sector.Selected;
}
}
}
/// <summary>
/// If the `Sector`'s floor is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted. Read-only.
/// </summary>
/// <version>3</version>
public bool floorHighlighted
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the floorHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sector.Sector == sector && vs.GeometryType == VisualGeometryType.FLOOR);
}
else
{
Sector s = ((ClassicMode)General.Editing.Mode).HighlightedObject as Sector;
if(s == null)
return false;
return s == sector;
}
}
}
/// <summary>
/// If the `Sector`'s ceiling is selected or not. Will always return `true` in classic modes if the `Sector` is selected. Read-only.
/// </summary>
/// <version>3</version>
public bool ceilingSelected
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the ceilingSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool f, c;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySector(sector, out f, out c);
return c;
}
else
{
return sector.Selected;
}
}
}
/// <summary>
/// If the `Sector`'s ceiling is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted. Read-only.
/// </summary>
/// <version>3</version>
public bool ceilingHighlighted
{
get
{
if (sector.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sector is disposed, the ceilingHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sector.Sector == sector && vs.GeometryType == VisualGeometryType.CEILING);
}
else
{
Sector s = ((ClassicMode)General.Editing.Mode).HighlightedObject as Sector;
if (s == null)
return false;
return s == sector;
}
}
}
/// <summary> /// <summary>
/// If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry). /// If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
/// </summary> /// </summary>

View file

@ -27,8 +27,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Dynamic; using System.Dynamic;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.BuilderModes;
using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.VisualModes;
#endregion #endregion
@ -321,6 +324,180 @@ namespace CodeImp.DoomBuilder.UDBScript.Wrapper
} }
} }
/// <summary>
/// If the `Sidedef`'s upper part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool upperSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the upperSelected property can not be accessed.");
if(General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return u;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s upper part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool upperHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the upperHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && vs.GeometryType == VisualGeometryType.WALL_UPPER);
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
/// <summary>
/// If the `Sidedef`'s middle part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool middleSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the middleSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return m;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s middle part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool middleHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the middleHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && (vs.GeometryType == VisualGeometryType.WALL_MIDDLE || vs.GeometryType == VisualGeometryType.WALL_MIDDLE_3D));
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
/// <summary>
/// If the `Sidedef`'s lower part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool lowerSelected
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the lowerSelected property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
bool u, m, l;
((BaseVisualMode)General.Editing.Mode).GetSelectedSurfaceTypesBySidedef(sidedef, out u, out m, out l);
return l;
}
else
{
return sidedef.Line.Selected;
}
}
}
/// <summary>
/// If the `Sidedef`'s lower part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
/// </summary>
/// <version>3</version>
public bool lowerHighlighted
{
get
{
if (sidedef.IsDisposed)
throw BuilderPlug.Me.ScriptRunner.CreateRuntimeException("Sidedef is disposed, the lowerHighlighted property can not be accessed.");
if (General.Editing.Mode is BaseVisualMode)
{
VisualGeometry vs = (VisualGeometry)((BaseVisualMode)General.Editing.Mode).Highlighted;
if (vs == null)
return false;
return (vs.Sidedef == sidedef && vs.GeometryType == VisualGeometryType.WALL_LOWER);
}
else
{
Linedef ld = ((ClassicMode)General.Editing.Mode).HighlightedObject as Linedef;
if (ld == null)
return false;
return (ld.Front == sidedef || (ld.Back != null && ld.Back == sidedef));
}
}
}
#endregion #endregion
#region ================== Constructors #region ================== Constructors

View file

@ -70,7 +70,7 @@ namespace CodeImp.DoomBuilder.UDBScript
#region ================== Constants #region ================== Constants
private static readonly string SCRIPT_FOLDER = "udbscript"; private static readonly string SCRIPT_FOLDER = "udbscript";
public static readonly uint UDB_SCRIPT_VERSION = 2; public static readonly uint UDB_SCRIPT_VERSION = 3;
#endregion #endregion

View file

@ -241,6 +241,14 @@ namespace CodeImp.DoomBuilder.UDBScript
engine.SetValue("UniValue", TypeReference.CreateTypeReference(engine, typeof(UniValue))); engine.SetValue("UniValue", TypeReference.CreateTypeReference(engine, typeof(UniValue)));
engine.SetValue("Data", TypeReference.CreateTypeReference(engine, typeof(DataWrapper))); engine.SetValue("Data", TypeReference.CreateTypeReference(engine, typeof(DataWrapper)));
// These can not be directly instanciated and don't have static method, but it's required to
// for example use "instanceof" in scripts
engine.SetValue("Linedef", TypeReference.CreateTypeReference(engine, typeof(LinedefWrapper)));
engine.SetValue("Sector", TypeReference.CreateTypeReference(engine, typeof(SectorWrapper)));
engine.SetValue("Sidedef", TypeReference.CreateTypeReference(engine, typeof(SidedefWrapper)));
engine.SetValue("Thing", TypeReference.CreateTypeReference(engine, typeof(ThingWrapper)));
engine.SetValue("Vertex", TypeReference.CreateTypeReference(engine, typeof(VertexWrapper)));
#if DEBUG #if DEBUG
engine.SetValue("log", new Action<object>(Console.WriteLine)); engine.SetValue("log", new Action<object>(Console.WriteLine));
#endif #endif

View file

@ -80,7 +80,11 @@ for topic in topics:
if texttype == 'global': if texttype == 'global':
texts['global'] = f'{summary}\n' texts['global'] = f'{summary}\n'
else: else:
commenttext += '\n---\n'
if 'version' in d:
commenttext += f'<span style="float:right;font-weight:normal;font-size:66%">Version: {d["version"]}</span>\n'
commenttext += f'### {signature}\n' commenttext += f'### {signature}\n'
commenttext += f'{summary}\n' commenttext += f'{summary}\n'
if 'param' in d: if 'param' in d:
commenttext += '#### Parameters\n' commenttext += '#### Parameters\n'

View file

@ -1,24 +1,32 @@
# Angle2D # Angle2D
## Static methods ## Static methods
---
### degToRad(deg) ### degToRad(deg)
Converts degrees to radians. Converts degrees to radians.
#### Parameters #### Parameters
* deg: Angle in degrees * deg: Angle in degrees
#### Return value #### Return value
Angle in radians Angle in radians
---
### doomToReal(doomangle) ### doomToReal(doomangle)
Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north). Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north).
#### Parameters #### Parameters
* doomangle: Doom angle in degrees * doomangle: Doom angle in degrees
#### Return value #### Return value
Doom angle in degrees Doom angle in degrees
---
### doomToRealRad(doomangle) ### doomToRealRad(doomangle)
Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north) in radians. Converts a Doom angle (where 0° is east) to a real world angle (where 0° is north) in radians.
#### Parameters #### Parameters
* doomangle: Doom angle in degrees * doomangle: Doom angle in degrees
#### Return value #### Return value
Doom angle in radians Doom angle in radians
---
### getAngle(p1, p2, p3) ### getAngle(p1, p2, p3)
Returns the angle between three positions. Returns the angle between three positions.
#### Parameters #### Parameters
@ -27,6 +35,8 @@ Returns the angle between three positions.
* p3: Third position * p3: Third position
#### Return value #### Return value
Angle in degrees Angle in degrees
---
### getAngleRad(p1, p2, p3) ### getAngleRad(p1, p2, p3)
Returns the angle between three positions in radians. Returns the angle between three positions in radians.
#### Parameters #### Parameters
@ -35,30 +45,40 @@ Returns the angle between three positions in radians.
* p3: Third position * p3: Third position
#### Return value #### Return value
Angle in radians Angle in radians
---
### normalized(angle) ### normalized(angle)
Normalizes an angle in degrees so that it is bigger or equal to 0° and smaller than 360°. Normalizes an angle in degrees so that it is bigger or equal to 0° and smaller than 360°.
#### Parameters #### Parameters
* angle: Angle in degrees * angle: Angle in degrees
#### Return value #### Return value
Normalized angle in degrees Normalized angle in degrees
---
### normalizedRad(angle) ### normalizedRad(angle)
Normalizes an angle in radians so that it is bigger or equal to 0 and smaller than 2 Pi. Normalizes an angle in radians so that it is bigger or equal to 0 and smaller than 2 Pi.
#### Parameters #### Parameters
* angle: Angle in radians * angle: Angle in radians
#### Return value #### Return value
Normalized angle in radians Normalized angle in radians
---
### radToDeg(rad) ### radToDeg(rad)
Converts radians to degrees. Converts radians to degrees.
#### Parameters #### Parameters
* rad: Angle in radians * rad: Angle in radians
#### Return value #### Return value
Angle in degrees Angle in degrees
---
### realToDoom(realangle) ### realToDoom(realangle)
Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east). Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east).
#### Parameters #### Parameters
* realangle: Real world angle in degrees * realangle: Real world angle in degrees
#### Return value #### Return value
Doom angle in degrees Doom angle in degrees
---
### realToDoomRad(realangle) ### realToDoomRad(realangle)
Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east) in radians. Converts a real world angle (where 0° is north) to a Doom angle (where 0° is east) in radians.
#### Parameters #### Parameters

View file

@ -1,32 +1,44 @@
# Data # Data
## Static methods ## Static methods
---
### flatExists(name) ### flatExists(name)
Checks if a flat with the given name exists. Checks if a flat with the given name exists.
#### Parameters #### Parameters
* name: Flat name to check * name: Flat name to check
#### Return value #### Return value
`true` if the flat exists, `false` if it doesn't `true` if the flat exists, `false` if it doesn't
---
### getFlatInfo(name) ### getFlatInfo(name)
Returns an `ImageInfo` object for the given flat name. Returns an `ImageInfo` object for the given flat name.
#### Parameters #### Parameters
* name: Flat name to get the info for * name: Flat name to get the info for
#### Return value #### Return value
`ImageInfo` object containing information about the flat `ImageInfo` object containing information about the flat
---
### getFlatNames() ### getFlatNames()
Returns an `Array`of all flat names. Returns an `Array`of all flat names.
#### Return value #### Return value
`Array` of all flat names `Array` of all flat names
---
### getTextureInfo(name) ### getTextureInfo(name)
Returns an `ImageInfo` object for the given texture name. Returns an `ImageInfo` object for the given texture name.
#### Parameters #### Parameters
* name: Texture name to get the info for * name: Texture name to get the info for
#### Return value #### Return value
`ImageInfo` object containing information about the texture `ImageInfo` object containing information about the texture
---
### getTextureNames() ### getTextureNames()
Returns an `Array` of all texture names. Returns an `Array` of all texture names.
#### Return value #### Return value
`Array` of all texture names `Array` of all texture names
---
### textureExists(name) ### textureExists(name)
Checks if a texture with the given name exists. Checks if a texture with the given name exists.
#### Parameters #### Parameters

View file

@ -1,7 +1,11 @@
# GameConfiguration # GameConfiguration
## Properties ## Properties
---
### engineName ### engineName
Engine name, like `doom`, `boom`, `zdoom` etc. Used for the namespace in UDMF maps. Read-only. Engine name, like `doom`, `boom`, `zdoom` etc. Used for the namespace in UDMF maps. Read-only.
---
### hasLocalSidedefTextureOffsets ### hasLocalSidedefTextureOffsets
If the game configuration supports local sidedef texture offsets (distinct offsets for upper, middle, and lower sidedef parts). If the game configuration supports local sidedef texture offsets (distinct offsets for upper, middle, and lower sidedef parts).

View file

@ -1,13 +1,23 @@
# ImageInfo # ImageInfo
## Properties ## Properties
---
### height ### height
Height of the image. Height of the image.
---
### isFlat ### isFlat
If the image is a flat (`true`) or not (`false`). If the image is a flat (`true`) or not (`false`).
---
### name ### name
Name of the image. Name of the image.
---
### scale ### scale
Scale of the image as `Vector2D`. Scale of the image as `Vector2D`.
---
### width ### width
Width of the image. Width of the image.

View file

@ -1,6 +1,8 @@
# Line2D # Line2D
## Constructors ## Constructors
---
### Line2D(v1, v2) ### Line2D(v1, v2)
Creates a new `Line2D` from two points. Creates a new `Line2D` from two points.
@ -12,6 +14,8 @@ let line2 = new Line2D([ 32, 64 ], [ 96, 128 ]);
* v1: First point * v1: First point
* v2: Second point * v2: Second point
## Static methods ## Static methods
---
### areIntersecting(a1, a2, b1, b2, bounded=true) ### areIntersecting(a1, a2, b1, b2, bounded=true)
Checks if two lines defined by their start and end points intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Checks if two lines defined by their start and end points intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -22,6 +26,8 @@ Checks if two lines defined by their start and end points intersect. If `bounded
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
`true` if the lines intersect, `false` if they do not `true` if the lines intersect, `false` if they do not
---
### areIntersecting(line1, line2, bounded=true) ### areIntersecting(line1, line2, bounded=true)
Checks if two lines intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Checks if two lines intersect. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -30,6 +36,8 @@ Checks if two lines intersect. If `bounded` is set to `true` (default) the finit
* bounded: `true` to use finite length of lines, `false` to use infinite length of lines * bounded: `true` to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
`true` if the lines intersect, `false` if they do not `true` if the lines intersect, `false` if they do not
---
### getCoordinatesAt(v1, v2, u) ### getCoordinatesAt(v1, v2, u)
Returns the coordinate on a line defined by its start and end points as `Vector2D`. Returns the coordinate on a line defined by its start and end points as `Vector2D`.
#### Parameters #### Parameters
@ -38,6 +46,8 @@ Returns the coordinate on a line defined by its start and end points as `Vector2
* u: Offset coordinate relative to the first point of the line * u: Offset coordinate relative to the first point of the line
#### Return value #### Return value
Point on the line as `Vector2D` Point on the line as `Vector2D`
---
### getDistanceToLine(v1, v2, p, bounded=true) ### getDistanceToLine(v1, v2, p, bounded=true)
Returns the shortest distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Returns the shortest distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -47,6 +57,8 @@ Returns the shortest distance from point `p` to the line defined by its start an
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
The shortest distance to the line The shortest distance to the line
---
### getDistanceToLineSq(v1, v2, p, bounded = true) ### getDistanceToLineSq(v1, v2, p, bounded = true)
Returns the shortest square distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Returns the shortest square distance from point `p` to the line defined by its start and end points. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -56,6 +68,8 @@ Returns the shortest square distance from point `p` to the line defined by its s
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
The shortest square distance to the line The shortest square distance to the line
---
### getIntersectionPoint(a1, a2, b1, b2, bounded = true) ### getIntersectionPoint(a1, a2, b1, b2, bounded = true)
Returns the intersection point of two lines as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Returns the intersection point of two lines as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -66,6 +80,8 @@ Returns the intersection point of two lines as `Vector2D`. If the lines do not i
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
The intersection point as `Vector2D` The intersection point as `Vector2D`
---
### getNearestOnLine(v1, v2, p) ### getNearestOnLine(v1, v2, p)
Returns the offset coordinate on the line nearest to the given point. `0.0` being on the first point, `1.0` being on the second point, and `u = 0.5` being in the middle between the points. Returns the offset coordinate on the line nearest to the given point. `0.0` being on the first point, `1.0` being on the second point, and `u = 0.5` being in the middle between the points.
#### Parameters #### Parameters
@ -74,6 +90,8 @@ Returns the offset coordinate on the line nearest to the given point. `0.0` bein
* p: Point to get the nearest offset coordinate from * p: Point to get the nearest offset coordinate from
#### Return value #### Return value
The offset value relative to the first point of the line. The offset value relative to the first point of the line.
---
### getSideOfLine(v1, v2, p) ### getSideOfLine(v1, v2, p)
Returns which the of the line defined by its start and end point a given point is on. Returns which the of the line defined by its start and end point a given point is on.
#### Parameters #### Parameters
@ -83,25 +101,37 @@ Returns which the of the line defined by its start and end point a given point i
#### Return value #### Return value
`< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line `< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line
## Properties ## Properties
---
### v1 ### v1
`Vector2D` position of start of the line. `Vector2D` position of start of the line.
---
### v2 ### v2
`Vector2D` position of end of the line. `Vector2D` position of end of the line.
## Methods ## Methods
---
### getAngle() ### getAngle()
Return the angle of the `Line2D` in degrees. Return the angle of the `Line2D` in degrees.
#### Return value #### Return value
Angle of the `Line2D` in degrees Angle of the `Line2D` in degrees
---
### getAngleRad() ### getAngleRad()
Returns the angle of the `Line2D` in radians. Returns the angle of the `Line2D` in radians.
#### Return value #### Return value
Angle of `Line2D` in radians Angle of `Line2D` in radians
---
### getCoordinatesAt(u) ### getCoordinatesAt(u)
Returns the coordinates on the line, where `u` is the position between the first and second point, `u = 0.0` being on the first point, `u = 1.0` being on the second point, and `u = 0.5` being in the middle between the points. Returns the coordinates on the line, where `u` is the position between the first and second point, `u = 0.0` being on the first point, `u = 1.0` being on the second point, and `u = 0.5` being in the middle between the points.
#### Parameters #### Parameters
* u: Position on the line, between 0.0 and 1.0 * u: Position on the line, between 0.0 and 1.0
#### Return value #### Return value
Position on the line as `Vector2D` Position on the line as `Vector2D`
---
### getIntersectionPoint(a1, a2, bounded = true) ### getIntersectionPoint(a1, a2, bounded = true)
Returns the intersection point of of the given line defined by its start and end points with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Returns the intersection point of of the given line defined by its start and end points with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -110,6 +140,8 @@ Returns the intersection point of of the given line defined by its start and end
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
The intersection point as `Vector2D` The intersection point as `Vector2D`
---
### getIntersectionPoint(ray, bounded=true) ### getIntersectionPoint(ray, bounded=true)
Returns the intersection point of of the given line with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Returns the intersection point of of the given line with this line as `Vector2D`. If the lines do not intersect the `x` and `y` properties of the `Vector2D` are `NaN`. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -117,20 +149,28 @@ Returns the intersection point of of the given line with this line as `Vector2D`
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
The intersection point as `Vector2D` The intersection point as `Vector2D`
---
### getLength() ### getLength()
Returns the length of the `Line2D`. Returns the length of the `Line2D`.
#### Return value #### Return value
Length of the `Line2D` Length of the `Line2D`
---
### getPerpendicular() ### getPerpendicular()
Returns the perpendicular of this line as `Vector2D`. Returns the perpendicular of this line as `Vector2D`.
#### Return value #### Return value
Perpendicular of this line as `Vector2D` Perpendicular of this line as `Vector2D`
---
### getSideOfLine(p) ### getSideOfLine(p)
Returns which the of the line defined by its start and end point a given point is on. Returns which the of the line defined by its start and end point a given point is on.
#### Parameters #### Parameters
* p: Point to check * p: Point to check
#### Return value #### Return value
`< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line `< 0` if `p` is on the front (right) side, `> 0` if `p` is on the back (left) side, `== 0` if `p` in on the line
---
### isIntersecting(a1, a2, bounded = true) ### isIntersecting(a1, a2, bounded = true)
Checks if the given line intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Checks if the given line intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters
@ -139,6 +179,8 @@ Checks if the given line intersects this line. If `bounded` is set to `true` (de
* bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines * bounded: `true` (default) to use finite length of lines, `false` to use infinite length of lines
#### Return value #### Return value
`true` if the lines intersect, `false` if they do not `true` if the lines intersect, `false` if they do not
---
### isIntersecting(ray, bounded=true) ### isIntersecting(ray, bounded=true)
Checks if the given `Line2D` intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used. Checks if the given `Line2D` intersects this line. If `bounded` is set to `true` (default) the finite length of the lines is used, otherwise the infinite length of the lines is used.
#### Parameters #### Parameters

View file

@ -1,20 +1,36 @@
# Linedef # Linedef
## Properties ## Properties
---
### action ### action
`Linedef` action. `Linedef` action.
---
### activate ### activate
The activation flag. Hexen format only. The activation flag. Hexen format only.
---
### angle ### angle
The `Linedef`'s angle in degree. Read-only. The `Linedef`'s angle in degree. Read-only.
---
### angleRad ### angleRad
The `Linedef`'s angle in radians. Read-only. The `Linedef`'s angle in radians. Read-only.
---
### args ### args
`Array` of arguments of the `Linedef`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only. `Array` of arguments of the `Linedef`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only.
---
### back ### back
The `Linedef`'s back `Sidedef`. Is `null` when there is no back. The `Linedef`'s back `Sidedef`. Is `null` when there is no back.
---
### end ### end
The linedef's end `Vertex`. The linedef's end `Vertex`.
---
### fields ### fields
UDMF fields. It's an object with the fields as properties. UDMF fields. It's an object with the fields as properties.
@ -43,6 +59,8 @@ To remove a field you have to assign `null` to it:
```js ```js
s.fields.user_myintfield = null; s.fields.user_myintfield = null;
``` ```
---
### flags ### flags
`Linedef` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name. `Linedef` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name.
Doom and Hexen: Doom and Hexen:
@ -56,43 +74,75 @@ UDMF:
ld.flags['blocksound'] = true; // Set the block sound flag ld.flags['blocksound'] = true; // Set the block sound flag
ld.flags.blocksound = true; // Also works ld.flags.blocksound = true; // Also works
``` ```
---
### front ### front
The `Linedef`'s front `Sidedef`. Is `null` when there is no front (should not happen). The `Linedef`'s front `Sidedef`. Is `null` when there is no front (should not happen).
---
### index ### index
The linedef's index. Read-only. The linedef's index. Read-only.
---
### length ### length
The `Linedef`'s length. Read-only. The `Linedef`'s length. Read-only.
---
### lengthInv ### lengthInv
1.0 / length. Read-only. 1.0 / length. Read-only.
---
### lengthSq ### lengthSq
The `Linedef`'s squared length. Read-only. The `Linedef`'s squared length. Read-only.
---
### line ### line
The `Line2D` from the `start` to the `end` `Vertex`. The `Line2D` from the `start` to the `end` `Vertex`.
---
### marked ### marked
If the `Linedef` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry). If the `Linedef` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### selected ### selected
If the `Linedef` is selected or not. If the `Linedef` is selected or not.
---
### start ### start
The linedef's start `Vertex`. The linedef's start `Vertex`.
---
### tag ### tag
`Linedef` tag. UDMF only. `Linedef` tag. UDMF only.
## Methods ## Methods
---
### addTag(tag) ### addTag(tag)
Adds a tag to the `Linedef`. UDMF only. Supported game configurations only. Adds a tag to the `Linedef`. UDMF only. Supported game configurations only.
#### Parameters #### Parameters
* tag: Tag to add * tag: Tag to add
#### Return value #### Return value
`true` when the tag was added, `false` when the tag already exists `true` when the tag was added, `false` when the tag already exists
---
### applySidedFlags() ### applySidedFlags()
Automatically sets the blocking and two-sided flags based on the existing `Sidedef`s. Automatically sets the blocking and two-sided flags based on the existing `Sidedef`s.
---
### clearFlags() ### clearFlags()
Clears all flags. Clears all flags.
---
### copyPropertiesTo(other) ### copyPropertiesTo(other)
Copies the properties of this `Linedef` to another `Linedef`. Copies the properties of this `Linedef` to another `Linedef`.
#### Parameters #### Parameters
* other: The `Linedef` to copy the properties to * other: The `Linedef` to copy the properties to
---
### delete() ### delete()
Deletes the `Linedef`. Note that this will result in unclosed `Sector`s unless it has the same `Sector`s on both sides. Deletes the `Linedef`. Note that this will result in unclosed `Sector`s unless it has the same `Sector`s on both sides.
---
### distanceTo(pos, bounded) ### distanceTo(pos, bounded)
Gets the shortest distance from `pos` to the line. Gets the shortest distance from `pos` to the line.
#### Parameters #### Parameters
@ -100,6 +150,8 @@ Gets the shortest distance from `pos` to the line.
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used * bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value #### Return value
Distance to the line Distance to the line
---
### distanceToSq(pos, bounded) ### distanceToSq(pos, bounded)
Gets the shortest squared distance from `pos` to the line. Gets the shortest squared distance from `pos` to the line.
#### Parameters #### Parameters
@ -107,26 +159,40 @@ Gets the shortest squared distance from `pos` to the line.
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used * bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value #### Return value
Squared distance to the line Squared distance to the line
---
### flip() ### flip()
Flips the `Linedef`'s vertex attachments and `Sidedef`s. This is a shortcut to using both `flipVertices()` and `flipSidedefs()`. Flips the `Linedef`'s vertex attachments and `Sidedef`s. This is a shortcut to using both `flipVertices()` and `flipSidedefs()`.
---
### flipSidedefs() ### flipSidedefs()
Flips the `Linedef`'s `Sidedef`s. Flips the `Linedef`'s `Sidedef`s.
---
### flipVertices() ### flipVertices()
Flips the `Linedef`'s vertex attachments. Flips the `Linedef`'s vertex attachments.
---
### getCenterPoint() ### getCenterPoint()
Gets a `Vector2D` that's in the center of the `Linedef`. Gets a `Vector2D` that's in the center of the `Linedef`.
#### Return value #### Return value
`Vector2D` in the center of the `Linedef` `Vector2D` in the center of the `Linedef`
---
### getSidePoint(front) ### getSidePoint(front)
Gets a `Vector2D` for testing on one side. The `Vector2D` is on the front when `true` is passed, otherwise on the back. Gets a `Vector2D` for testing on one side. The `Vector2D` is on the front when `true` is passed, otherwise on the back.
#### Parameters #### Parameters
* front: `true` for front, `false` for back * front: `true` for front, `false` for back
#### Return value #### Return value
`Vector2D` that's either on the front of back of the Linedef `Vector2D` that's either on the front of back of the Linedef
---
### getTags() ### getTags()
Returns an `Array` of the `Linedef`'s tags. UDMF only. Supported game configurations only. Returns an `Array` of the `Linedef`'s tags. UDMF only. Supported game configurations only.
#### Return value #### Return value
`Array` of tags `Array` of tags
---
### nearestOnLine(pos) ### nearestOnLine(pos)
Get a `Vector2D` that's *on* the line, closest to `pos`. `pos` can either be a `Vector2D`, or an array of numbers. Get a `Vector2D` that's *on* the line, closest to `pos`. `pos` can either be a `Vector2D`, or an array of numbers.
@ -138,12 +204,16 @@ var v2 = ld.nearestOnLine([ 32, 64 ]);
* pos: Point to check against * pos: Point to check against
#### Return value #### Return value
`Vector2D` that's on the linedef `Vector2D` that's on the linedef
---
### removeTag(tag) ### removeTag(tag)
Removes a tag from the `Linedef`. UDMF only. Supported game configurations only. Removes a tag from the `Linedef`. UDMF only. Supported game configurations only.
#### Parameters #### Parameters
* tag: Tag to remove * tag: Tag to remove
#### Return value #### Return value
`true` when the tag was removed successfully, `false` when the tag did not exist `true` when the tag was removed successfully, `false` when the tag did not exist
---
### safeDistanceTo(pos, bounded) ### safeDistanceTo(pos, bounded)
Gets the shortest "safe" distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end. Gets the shortest "safe" distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end.
#### Parameters #### Parameters
@ -151,6 +221,8 @@ Gets the shortest "safe" distance from `pos` to the line. If `bounded` is `true`
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used * bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value #### Return value
Distance to the line Distance to the line
---
### safeDistanceToSq(pos, bounded) ### safeDistanceToSq(pos, bounded)
Gets the shortest "safe" squared distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end. Gets the shortest "safe" squared distance from `pos` to the line. If `bounded` is `true` that means that the not the whole line's length will be used, but `lengthInv` less at the start and end.
#### Parameters #### Parameters
@ -158,12 +230,16 @@ Gets the shortest "safe" squared distance from `pos` to the line. If `bounded` i
* bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used * bounded: `true` if only the finite length of the line should be used, `false` if the infinite length of the line should be used
#### Return value #### Return value
Squared distance to the line Squared distance to the line
---
### sideOfLine(pos) ### sideOfLine(pos)
Tests which side of the `Linedef` `pos` is on. Returns < 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line. Tests which side of the `Linedef` `pos` is on. Returns < 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line.
#### Parameters #### Parameters
* pos: Point to check against * pos: Point to check against
#### Return value #### Return value
< 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line < 0 for front (right) side, > for back (left) side, and 0 if `pos` is on the line
---
### split(pos) ### split(pos)
Splits the `Linedef` at the given position. This can either be a `Vector2D`, an array of numbers, or an existing `Vertex`. The result will be two lines, from the start `Vertex` of the `Linedef` to `pos`, and from `pos` to the end `Vertex` of the `Linedef`. Splits the `Linedef` at the given position. This can either be a `Vector2D`, an array of numbers, or an existing `Vertex`. The result will be two lines, from the start `Vertex` of the `Linedef` to `pos`, and from `pos` to the end `Vertex` of the `Linedef`.
#### Parameters #### Parameters

View file

@ -1,49 +1,81 @@
# Map # Map
## Properties ## Properties
---
### camera ### camera
`VisualCamera` object with information about the position of the camera in visual mode. Read-only. `VisualCamera` object with information about the position of the camera in visual mode. Read-only.
---
### isDoom ### isDoom
`true` if the map is in Doom format, `false` if it isn't. Read-only. `true` if the map is in Doom format, `false` if it isn't. Read-only.
---
### isHexen ### isHexen
`true` if the map is in Hexen format, `false` if it isn't. Read-only. `true` if the map is in Hexen format, `false` if it isn't. Read-only.
---
### isUDMF ### isUDMF
`true` if the map is in UDMF, `false` if it isn't. Read-only. `true` if the map is in UDMF, `false` if it isn't. Read-only.
---
### mousePosition ### mousePosition
The map coordinates of the mouse position as a `Vector2D`. Read-only. The map coordinates of the mouse position as a `Vector2D`. Read-only.
## Methods ## Methods
---
### clearAllMarks(mark=false) ### clearAllMarks(mark=false)
Sets the `marked` property of all map elements. Can be passed `true` to mark all map elements. Sets the `marked` property of all map elements. Can be passed `true` to mark all map elements.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearAllSelected() ### clearAllSelected()
Clears all selected map elements. Clears all selected map elements.
---
### clearMarkeLinedefs(mark=false) ### clearMarkeLinedefs(mark=false)
Sets the `marked` property of all `Linedef`s. Can be passed `true` to mark all `Linedef`s. Sets the `marked` property of all `Linedef`s. Can be passed `true` to mark all `Linedef`s.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkeSectors(mark = false) ### clearMarkeSectors(mark = false)
Sets the `marked` property of all `Sector`s. Can be passed `true` to mark all `Sector`s. Sets the `marked` property of all `Sector`s. Can be passed `true` to mark all `Sector`s.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkeSidedefs(mark = false) ### clearMarkeSidedefs(mark = false)
Sets the `marked` property of all `Sidedef`s. Can be passed `true` to mark all `Sidedef`s. Sets the `marked` property of all `Sidedef`s. Can be passed `true` to mark all `Sidedef`s.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkedThings(mark=false) ### clearMarkedThings(mark=false)
Sets the `marked` property of all `Thing`s. Can be passed `true` to mark all `Thing`s. Sets the `marked` property of all `Thing`s. Can be passed `true` to mark all `Thing`s.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearMarkedVertices(mark=false) ### clearMarkedVertices(mark=false)
Sets the `marked` property of all vertices. Can be passed `true` to mark all vertices. Sets the `marked` property of all vertices. Can be passed `true` to mark all vertices.
#### Parameters #### Parameters
* mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true` * mark: `false` to set the `marked` property to `false` (default), `true` to set the `marked` property to `true`
---
### clearSelectedSectors() ### clearSelectedSectors()
Clears all selected `Sector`s. Clears all selected `Sector`s.
---
### clearSelectedThings() ### clearSelectedThings()
Clears all selected `Thing`s. Clears all selected `Thing`s.
---
### clearSelectedVertices() ### clearSelectedVertices()
Clears all selected vertices. Clears all selected vertices.
---
### createThing(pos, type=0) ### createThing(pos, type=0)
Creates a new `Thing` at the given position. The position can be a `Vector2D`, `Vector3D`, or an `Array` of two numbers or three numbers (note that the z position only works for game configurations that support vertical pos. A thing type can be supplied optionally. Creates a new `Thing` at the given position. The position can be a `Vector2D`, `Vector3D`, or an `Array` of two numbers or three numbers (note that the z position only works for game configurations that support vertical pos. A thing type can be supplied optionally.
@ -58,6 +90,8 @@ var t4 = Map.createThing([ 32, 64 ], 3001); // Create an Imp
* type: Thing type (optional) * type: Thing type (optional)
#### Return value #### Return value
The new `Thing` The new `Thing`
---
### createVertex(pos) ### createVertex(pos)
Creates a new `Vertex` at the given position. The position can be a `Vector2D` or an `Array` of two numbers. Creates a new `Vertex` at the given position. The position can be a `Vector2D` or an `Array` of two numbers.
@ -69,6 +103,8 @@ var v2 = Map.createVertex([ 32, 64 ]);
* pos: Position where the `Vertex` should be created at * pos: Position where the `Vertex` should be created at
#### Return value #### Return value
The created `Vertex` The created `Vertex`
---
### drawLines(data) ### drawLines(data)
Draws lines. Data has to be an `Array` of `Array` of numbers, `Vector2D`s, `Vector3D`s, or objects with x and y properties. Note that the first and last element have to be at the same positions to make a complete drawing. Draws lines. Data has to be an `Array` of `Array` of numbers, `Vector2D`s, `Vector3D`s, or objects with x and y properties. Note that the first and last element have to be at the same positions to make a complete drawing.
@ -93,166 +129,251 @@ Map.drawLines([
* data: `Array` of positions * data: `Array` of positions
#### Return value #### Return value
`true` if drawing was successful, `false` if it wasn't `true` if drawing was successful, `false` if it wasn't
---
### getHighlightedLinedef() ### getHighlightedLinedef()
Get the currently highlighted `Linedef`. Get the currently highlighted `Linedef`.
#### Return value #### Return value
The currently highlighted `Linedef` or `null` if no `Linedef` is highlighted The currently highlighted `Linedef` or `null` if no `Linedef` is highlighted
---
### getHighlightedSector() ### getHighlightedSector()
Get the currently highlighted `Sector`. Get the currently highlighted `Sector`.
#### Return value #### Return value
The currently highlighted `Sector` or `null` if no `Sector` is highlighted The currently highlighted `Sector` or `null` if no `Sector` is highlighted
---
### getHighlightedThing() ### getHighlightedThing()
Get the currently highlighted `Thing`. Get the currently highlighted `Thing`.
#### Return value #### Return value
The currently highlighted `Thing` or `null` if no `Thing` is highlighted The currently highlighted `Thing` or `null` if no `Thing` is highlighted
---
### getHighlightedVertex() ### getHighlightedVertex()
Get the currently highlighted `Vertex`. Get the currently highlighted `Vertex`.
#### Return value #### Return value
The currently highlighted `Vertex` or `null` if no `Vertex` is highlighted The currently highlighted `Vertex` or `null` if no `Vertex` is highlighted
---
### getLinedefs() ### getLinedefs()
Returns an `Array` of all `Linedef`s in the map. Returns an `Array` of all `Linedef`s in the map.
#### Return value #### Return value
`Array` of `Linedef`s `Array` of `Linedef`s
---
### getMarkedLinedefs(mark = true) ### getMarkedLinedefs(mark = true)
Gets all marked (default) or unmarked `Linedef`s. Gets all marked (default) or unmarked `Linedef`s.
#### Parameters #### Parameters
* mark: `true` to get all marked `Linedef`s (default), `false` to get all unmarked `Linedef`s * mark: `true` to get all marked `Linedef`s (default), `false` to get all unmarked `Linedef`s
#### Return value #### Return value
*missing* *missing*
---
### getMarkedSectors(mark = true) ### getMarkedSectors(mark = true)
Gets all marked (default) or unmarked `Sector`s. Gets all marked (default) or unmarked `Sector`s.
#### Parameters #### Parameters
* mark: `true` to get all marked `Sector`s (default), `false` to get all unmarked `Sector`s * mark: `true` to get all marked `Sector`s (default), `false` to get all unmarked `Sector`s
#### Return value #### Return value
*missing* *missing*
---
### getMarkedSidedefs(mark = true) ### getMarkedSidedefs(mark = true)
Gets all marked (default) or unmarked `Sidedef`s. Gets all marked (default) or unmarked `Sidedef`s.
#### Parameters #### Parameters
* mark: `true` to get all marked `Sidedef`s (default), `false` to get all unmarked `Sidedef`s * mark: `true` to get all marked `Sidedef`s (default), `false` to get all unmarked `Sidedef`s
#### Return value #### Return value
*missing* *missing*
---
### getMarkedThings(mark = true) ### getMarkedThings(mark = true)
Gets all marked (default) or unmarked `Thing`s. Gets all marked (default) or unmarked `Thing`s.
#### Parameters #### Parameters
* mark: `true` to get all marked `Thing`s (default), `false` to get all unmarked `Thing`s * mark: `true` to get all marked `Thing`s (default), `false` to get all unmarked `Thing`s
#### Return value #### Return value
*missing* *missing*
---
### getMarkedVertices(mark=true) ### getMarkedVertices(mark=true)
Gets all marked (default) or unmarked vertices. Gets all marked (default) or unmarked vertices.
#### Parameters #### Parameters
* mark: `true` to get all marked vertices (default), `false` to get all unmarked vertices * mark: `true` to get all marked vertices (default), `false` to get all unmarked vertices
#### Return value #### Return value
*missing* *missing*
---
### getMultipleNewTags(count) ### getMultipleNewTags(count)
Gets multiple new tags. Gets multiple new tags.
#### Parameters #### Parameters
* count: Number of tags to get * count: Number of tags to get
#### Return value #### Return value
`Array` of the new tags `Array` of the new tags
---
### getNewTag(usedtags = null) ### getNewTag(usedtags = null)
Gets a new tag. Gets a new tag.
#### Parameters #### Parameters
* usedtags: `Array` of tags to skip * usedtags: `Array` of tags to skip
#### Return value #### Return value
The new tag The new tag
---
### getSectors() ### getSectors()
Returns an `Array` of all `Sector`s in the map. Returns an `Array` of all `Sector`s in the map.
#### Return value #### Return value
`Array` of `Sector`s `Array` of `Sector`s
---
### getSelectedLinedefs(selected = true) ### getSelectedLinedefs(selected = true)
Gets all selected (default) or unselected `Linedef`s. Gets all selected (default) or unselected `Linedef`s.
#### Parameters #### Parameters
* selected: `true` to get all selected `Linedef`s, `false` to get all unselected ones * selected: `true` to get all selected `Linedef`s, `false` to get all unselected ones
#### Return value #### Return value
`Array` of `Linedef`s `Array` of `Linedef`s
---
### getSelectedOrHighlightedLinedefs() ### getSelectedOrHighlightedLinedefs()
Gets the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, a currently highlighted `Linedef`. Gets the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, a currently highlighted `Linedef`.
#### Return value #### Return value
`Array` of `Linedef`s `Array` of `Linedef`s
---
### getSelectedOrHighlightedSectors() ### getSelectedOrHighlightedSectors()
Gets the currently selected `Sector`s *or*, if no `Sector`s are selected, a currently highlighted `Sector`. Gets the currently selected `Sector`s *or*, if no `Sector`s are selected, a currently highlighted `Sector`.
#### Return value #### Return value
`Array` of `Sector`s `Array` of `Sector`s
---
### getSelectedOrHighlightedThings() ### getSelectedOrHighlightedThings()
Gets the currently selected `Thing`s *or*, if no `Thing`s are selected, a currently highlighted `Thing`. Gets the currently selected `Thing`s *or*, if no `Thing`s are selected, a currently highlighted `Thing`.
#### Return value #### Return value
`Array` of `Thing`s `Array` of `Thing`s
---
### getSelectedOrHighlightedVertices() ### getSelectedOrHighlightedVertices()
Gets the currently selected `Vertex`s *or*, if no `Vertex`s are selected, a currently highlighted `Vertex`. Gets the currently selected `Vertex`s *or*, if no `Vertex`s are selected, a currently highlighted `Vertex`.
#### Return value #### Return value
`Array` of `Vertex` `Array` of `Vertex`
---
### getSelectedSectors(selected = true) ### getSelectedSectors(selected = true)
Gets all selected (default) or unselected `Sector`s. Gets all selected (default) or unselected `Sector`s.
#### Parameters #### Parameters
* selected: `true` to get all selected `Sector`s, `false` to get all unselected ones * selected: `true` to get all selected `Sector`s, `false` to get all unselected ones
#### Return value #### Return value
`Array` of `Sector`s `Array` of `Sector`s
---
### getSelectedThings(selected = true) ### getSelectedThings(selected = true)
Gets all selected (default) or unselected `Thing`s. Gets all selected (default) or unselected `Thing`s.
#### Parameters #### Parameters
* selected: `true` to get all selected `Thing`s, `false` to get all unselected ones * selected: `true` to get all selected `Thing`s, `false` to get all unselected ones
#### Return value #### Return value
`Array` of `Thing`s `Array` of `Thing`s
---
### getSelectedVertices(selected=true) ### getSelectedVertices(selected=true)
Gets all selected (default) or unselected vertices. Gets all selected (default) or unselected vertices.
#### Parameters #### Parameters
* selected: `true` to get all selected vertices, `false` to get all unselected ones * selected: `true` to get all selected vertices, `false` to get all unselected ones
#### Return value #### Return value
`Array` of `Vertex` `Array` of `Vertex`
---
### getSidedefs() ### getSidedefs()
Returns an `Array` of all `Sidedef`s in the map. Returns an `Array` of all `Sidedef`s in the map.
#### Return value #### Return value
`Array` of `Sidedef`s `Array` of `Sidedef`s
---
### getSidedefsFromSelectedLinedefs(selected = true) ### getSidedefsFromSelectedLinedefs(selected = true)
Gets all `Sidedef`s from the selected `Linedef`s. Gets all `Sidedef`s from the selected `Linedef`s.
In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
#### Parameters #### Parameters
* selected: `true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s * selected: `true` to get all `Sidedef`s of all selected `Linedef`s, `false` to get all `Sidedef`s of all unselected `Linedef`s
#### Return value #### Return value
*missing* `Array` of `Sidedef`
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### getSidedefsFromSelectedOrHighlightedLinedefs()
Gets the `Sidedef`s of the currently selected `Linedef`s *or*, if no `Linede`f`s are selected, the `Sidedef`s of the currently highlighted `Linedef`.
In classic modes this will return both sidedefs of 2-sided lines, in visual mode it will only return the actually selected `Sidedef`.
#### Return value
`Array` of `Sidedef`s
---
### getThings() ### getThings()
Returns an `Array` of all `Thing`s in the map. Returns an `Array` of all `Thing`s in the map.
#### Return value #### Return value
`Array` of `Thing`s `Array` of `Thing`s
---
### getVertices() ### getVertices()
Returns an `Array` of all `Vertex` in the map. Returns an `Array` of all `Vertex` in the map.
#### Return value #### Return value
`Array` of `Vertex` `Array` of `Vertex`
---
### invertAllMarks() ### invertAllMarks()
Inverts all marks of all map elements. Inverts all marks of all map elements.
---
### invertMarkedLinedefs() ### invertMarkedLinedefs()
Inverts the `marked` property of all `Linedef`s. Inverts the `marked` property of all `Linedef`s.
---
### invertMarkedSectors() ### invertMarkedSectors()
Inverts the `marked` property of all `Sector`s. Inverts the `marked` property of all `Sector`s.
---
### invertMarkedSidedefs() ### invertMarkedSidedefs()
Inverts the `marked` property of all `Sidedef`s. Inverts the `marked` property of all `Sidedef`s.
---
### invertMarkedThings() ### invertMarkedThings()
Inverts the `marked` property of all `Thing`s. Inverts the `marked` property of all `Thing`s.
---
### invertMarkedVertices() ### invertMarkedVertices()
Inverts the `marked` property of all vertices. Inverts the `marked` property of all vertices.
---
### joinSectors(sectors) ### joinSectors(sectors)
Joins `Sector`s, keeping lines shared by the `Sector`s. All `Sector`s will be joined with the first `Sector` in the array. Joins `Sector`s, keeping lines shared by the `Sector`s. All `Sector`s will be joined with the first `Sector` in the array.
#### Parameters #### Parameters
* sectors: `Array` of `Sector`s * sectors: `Array` of `Sector`s
---
### markSelectedLinedefs(mark = true) ### markSelectedLinedefs(mark = true)
Marks (default) or unmarks all selected `Linedef`s. Marks (default) or unmarks all selected `Linedef`s.
#### Parameters #### Parameters
* mark: `true` to mark all selected `Linedef`s (default), `false` to unmark * mark: `true` to mark all selected `Linedef`s (default), `false` to unmark
---
### markSelectedSectors(mark = true) ### markSelectedSectors(mark = true)
Marks (default) or unmarks all selected `Sector`s. Marks (default) or unmarks all selected `Sector`s.
#### Parameters #### Parameters
* mark: `true` to mark all selected `Sector`s (default), `false` to unmark * mark: `true` to mark all selected `Sector`s (default), `false` to unmark
---
### markSelectedThings(mark = true) ### markSelectedThings(mark = true)
Marks (default) or unmarks all selected `Thing`s. Marks (default) or unmarks all selected `Thing`s.
#### Parameters #### Parameters
* mark: `true` to mark all selected `Thing`s (default), `false` to unmark * mark: `true` to mark all selected `Thing`s (default), `false` to unmark
---
### markSelectedVertices(mark=true) ### markSelectedVertices(mark=true)
Marks (default) or unmarks all selected vertices. Marks (default) or unmarks all selected vertices.
#### Parameters #### Parameters
* mark: `true` to mark all selected vertices (default), `false` to unmark * mark: `true` to mark all selected vertices (default), `false` to unmark
---
### mergeSectors(sectors) ### mergeSectors(sectors)
Merges `Sector`s, deleting lines shared by the `Sector`s. All `Sector`s will be merged into the first `Sector` in the array. Merges `Sector`s, deleting lines shared by the `Sector`s. All `Sector`s will be merged into the first `Sector` in the array.
#### Parameters #### Parameters
* sectors: `Array` of `Sector`s * sectors: `Array` of `Sector`s
---
### nearestLinedef(pos, maxrange = double.NaN) ### nearestLinedef(pos, maxrange = double.NaN)
Gets the `Linedef` that's nearest to the specified position. Gets the `Linedef` that's nearest to the specified position.
#### Parameters #### Parameters
@ -260,6 +381,8 @@ Gets the `Linedef` that's nearest to the specified position.
* maxrange: Maximum range (optional) * maxrange: Maximum range (optional)
#### Return value #### Return value
Nearest `Linedef` Nearest `Linedef`
---
### nearestSidedef(pos) ### nearestSidedef(pos)
Gets the `Sidedef` that's nearest to the specified position. Gets the `Sidedef` that's nearest to the specified position.
#### Parameters #### Parameters
@ -267,6 +390,8 @@ Gets the `Sidedef` that's nearest to the specified position.
* maxrange: Maximum range (optional) * maxrange: Maximum range (optional)
#### Return value #### Return value
Nearest `Sidedef` Nearest `Sidedef`
---
### nearestThing(pos, maxrange = double.NaN) ### nearestThing(pos, maxrange = double.NaN)
Gets the `Thing` that's nearest to the specified position. Gets the `Thing` that's nearest to the specified position.
#### Parameters #### Parameters
@ -274,6 +399,8 @@ Gets the `Thing` that's nearest to the specified position.
* maxrange: Maximum range (optional) * maxrange: Maximum range (optional)
#### Return value #### Return value
Nearest `Linedef` Nearest `Linedef`
---
### nearestVertex(pos, maxrange = double.NaN) ### nearestVertex(pos, maxrange = double.NaN)
Gets the `Vertex` that's nearest to the specified position. Gets the `Vertex` that's nearest to the specified position.
#### Parameters #### Parameters
@ -281,16 +408,22 @@ Gets the `Vertex` that's nearest to the specified position.
* maxrange: Maximum range (optional) * maxrange: Maximum range (optional)
#### Return value #### Return value
Nearest `Vertex` Nearest `Vertex`
---
### snapAllToAccuracy(usepreciseposition = true) ### snapAllToAccuracy(usepreciseposition = true)
Snaps all vertices and things to the map format accuracy. Call this to ensure the vertices and things are at valid coordinates. Snaps all vertices and things to the map format accuracy. Call this to ensure the vertices and things are at valid coordinates.
#### Parameters #### Parameters
* usepreciseposition: `true` if decimal places defined by the map format should be used, `false` if no decimal places should be used * usepreciseposition: `true` if decimal places defined by the map format should be used, `false` if no decimal places should be used
---
### snappedToGrid(pos) ### snappedToGrid(pos)
Returns the given point snapped to the current grid. Returns the given point snapped to the current grid.
#### Parameters #### Parameters
* pos: Point that should be snapped to the grid * pos: Point that should be snapped to the grid
#### Return value #### Return value
Snapped position as `Vector2D` Snapped position as `Vector2D`
---
### stitchGeometry(mergemode = MergeGeometryMode.CLASSIC) ### stitchGeometry(mergemode = MergeGeometryMode.CLASSIC)
Stitches marked geometry with non-marked geometry. Stitches marked geometry with non-marked geometry.
#### Parameters #### Parameters

View file

@ -14,12 +14,18 @@ qo.query();
showMessage('You want ' + qo.options.numsides + ' sides with a length of ' + qo.options.length); showMessage('You want ' + qo.options.numsides + ' sides with a length of ' + qo.options.length);
``` ```
## Constructors ## Constructors
---
### QueryOptions() ### QueryOptions()
Initializes a new `QueryOptions` object. Initializes a new `QueryOptions` object.
## Properties ## Properties
---
### options ### options
Object containing all the added options as properties. Object containing all the added options as properties.
## Methods ## Methods
---
### addOption(name, description, type, defaultvalue) ### addOption(name, description, type, defaultvalue)
Adds a parameter to query Adds a parameter to query
#### Parameters #### Parameters
@ -27,6 +33,8 @@ Adds a parameter to query
* description: Textual description of the parameter * description: Textual description of the parameter
* type: UniversalType value of the parameter * type: UniversalType value of the parameter
* defaultvalue: Default value of the parameter * defaultvalue: Default value of the parameter
---
### addOption(name, description, type, defaultvalue, enumvalues) ### addOption(name, description, type, defaultvalue, enumvalues)
Adds a parameter to query Adds a parameter to query
#### Parameters #### Parameters
@ -34,8 +42,12 @@ Adds a parameter to query
* description: Textual description of the parameter * description: Textual description of the parameter
* type: UniversalType value of the parameter * type: UniversalType value of the parameter
* defaultvalue: Default value of the parameter * defaultvalue: Default value of the parameter
---
### clear() ### clear()
Removes all parameters Removes all parameters
---
### query() ### query()
Queries all parameters. Options a window where the user can enter values for the options added through `addOption()`. Queries all parameters. Options a window where the user can enter values for the options added through `addOption()`.
#### Return value #### Return value

View file

@ -1,14 +1,34 @@
# Sector # Sector
## Properties ## Properties
---
### brightness ### brightness
The `Sector`'s brightness. The `Sector`'s brightness.
---
### ceilingHeight ### ceilingHeight
Ceiling height of the `Sector`. Ceiling height of the `Sector`.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### ceilingHighlighted
If the `Sector`'s ceiling is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### ceilingSelected
If the `Sector`'s ceiling is selected or not. Will always return `true` in classic modes if the `Sector` is selected.
---
### ceilingSlopeOffset ### ceilingSlopeOffset
The ceiling's slope offset. The ceiling's slope offset.
---
### ceilingTexture ### ceilingTexture
Ceiling texture of the `Sector`. Ceiling texture of the `Sector`.
---
### fields ### fields
UDMF fields. It's an object with the fields as properties. UDMF fields. It's an object with the fields as properties.
@ -37,6 +57,8 @@ To remove a field you have to assign `null` to it:
```js ```js
s.fields.user_myintfield = null; s.fields.user_myintfield = null;
``` ```
---
### flags ### flags
`Sector` flags. It's an object with the flags as properties. Only available in UDMF. `Sector` flags. It's an object with the flags as properties. Only available in UDMF.
@ -45,57 +67,103 @@ s.fields.user_myintfield = null;
s.flags['noattack'] = true; // Monsters in this sector don't attack s.flags['noattack'] = true; // Monsters in this sector don't attack
s.flags.noattack = true; // Also works s.flags.noattack = true; // Also works
``` ```
---
### floorHeight ### floorHeight
Floor height of the `Sector`. Floor height of the `Sector`.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### floorHighlighted
If the `Sector`'s floor is highlighted or not. Will always return `true` in classic modes if the `Sector` is highlighted.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### floorSelected
If the `Sector`'s floor is selected or not. Will always return `true` in classic modes if the `Sector` is selected.
---
### floorSlopeOffset ### floorSlopeOffset
The floor's slope offset. The floor's slope offset.
---
### floorTexture ### floorTexture
Floor texture of the `Sector`. Floor texture of the `Sector`.
---
### index ### index
The `Sector`'s index. Read-only. The `Sector`'s index. Read-only.
---
### marked ### marked
If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry). If the `Sector` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### selected ### selected
If the `Sector` is selected or not. If the `Sector` is selected or not.
---
### special ### special
The `Sector`'s special type. The `Sector`'s special type.
---
### tag ### tag
The `Sector`'s tag. The `Sector`'s tag.
## Methods ## Methods
---
### addTag(tag) ### addTag(tag)
Adds a tag to the `Sector`. UDMF only. Supported game configurations only. Adds a tag to the `Sector`. UDMF only. Supported game configurations only.
#### Parameters #### Parameters
* tag: Tag to add * tag: Tag to add
#### Return value #### Return value
`true` when the tag was added, `false` when the tag already exists `true` when the tag was added, `false` when the tag already exists
---
### clearFlags() ### clearFlags()
Clears all flags. Clears all flags.
---
### copyPropertiesTo(s) ### copyPropertiesTo(s)
Copies the properties from this `Sector` to another. Copies the properties from this `Sector` to another.
#### Parameters #### Parameters
* s: the `Sector` to copy the properties to * s: the `Sector` to copy the properties to
---
### delete() ### delete()
Deletes the `Sector` and its `Sidedef`s. Deletes the `Sector` and its `Sidedef`s.
---
### getCeilingSlope() ### getCeilingSlope()
Gets the ceiling's slope vector. Gets the ceiling's slope vector.
#### Return value #### Return value
The ceiling's slope normal as a `Vector3D` The ceiling's slope normal as a `Vector3D`
---
### getFloorSlope() ### getFloorSlope()
Gets the floor's slope vector. Gets the floor's slope vector.
#### Return value #### Return value
The floor's slope normal as a `Vector3D` The floor's slope normal as a `Vector3D`
---
### getSidedefs() ### getSidedefs()
Returns an `Array` of all `Sidedef`s of the `Sector`. Returns an `Array` of all `Sidedef`s of the `Sector`.
#### Return value #### Return value
`Array` of the `Sector`'s `Sidedef`s `Array` of the `Sector`'s `Sidedef`s
---
### getTags() ### getTags()
Returns an `Array` of the `Sector`'s tags. UDMF only. Supported game configurations only. Returns an `Array` of the `Sector`'s tags. UDMF only. Supported game configurations only.
#### Return value #### Return value
`Array` of tags `Array` of tags
---
### getTriangles() ### getTriangles()
Gets an array of `Vector2D` arrays, representing the vertices of the triangulated sector. Note that for sectors with islands some triangles may not always have their points on existing vertices. Gets an array of `Vector2D` arrays, representing the vertices of the triangulated sector. Note that for sectors with islands some triangles may not always have their points on existing vertices.
#### Return value #### Return value
Array of `Vector2D` arrays Array of `Vector2D` arrays
---
### intersect(p) ### intersect(p)
Checks if the given point is in this `Sector` or not. The given point can be a `Vector2D` or an `Array` of two numbers. Checks if the given point is in this `Sector` or not. The given point can be a `Vector2D` or an `Array` of two numbers.
@ -110,20 +178,28 @@ if(s.intersect([ 32, 64 ]))
* p: Point to test * p: Point to test
#### Return value #### Return value
`true` if the point is in the `Sector`, `false` if it isn't `true` if the point is in the `Sector`, `false` if it isn't
---
### join(other) ### join(other)
Joins this `Sector` with another `Sector`. Lines shared between the sectors will not be removed. Joins this `Sector` with another `Sector`. Lines shared between the sectors will not be removed.
#### Parameters #### Parameters
* other: Sector to join with * other: Sector to join with
---
### removeTag(tag) ### removeTag(tag)
Removes a tag from the `Sector`. UDMF only. Supported game configurations only. Removes a tag from the `Sector`. UDMF only. Supported game configurations only.
#### Parameters #### Parameters
* tag: Tag to remove * tag: Tag to remove
#### Return value #### Return value
`true` when the tag was removed successfully, `false` when the tag did not exist `true` when the tag was removed successfully, `false` when the tag did not exist
---
### setCeilingSlope(normal) ### setCeilingSlope(normal)
Sets the ceiling's slope vector. The vector has to be normalized. Sets the ceiling's slope vector. The vector has to be normalized.
#### Parameters #### Parameters
* normal: The new slope vector as `Vector3D` * normal: The new slope vector as `Vector3D`
---
### setFloorSlope(normal) ### setFloorSlope(normal)
Sets the floor's slope vector. The vector has to be normalized. Sets the floor's slope vector. The vector has to be normalized.
#### Parameters #### Parameters

View file

@ -1,10 +1,16 @@
# Sidedef # Sidedef
## Properties ## Properties
---
### angle ### angle
The `Sidedef`'s angle in degrees. Read-only. The `Sidedef`'s angle in degrees. Read-only.
---
### angleRad ### angleRad
The `Sidedef`'s angle in radians. Read-only. The `Sidedef`'s angle in radians. Read-only.
---
### fields ### fields
UDMF fields. It's an object with the fields as properties. UDMF fields. It's an object with the fields as properties.
@ -33,6 +39,8 @@ To remove a field you have to assign `null` to it:
```js ```js
s.fields.user_myintfield = null; s.fields.user_myintfield = null;
``` ```
---
### flags ### flags
`Sidedef` flags. It's an object with the flags as properties. Only available in UDMF. `Sidedef` flags. It's an object with the flags as properties. Only available in UDMF.
@ -41,23 +49,73 @@ s.fields.user_myintfield = null;
s.flags['noattack'] = true; // Monsters in this sector don't attack s.flags['noattack'] = true; // Monsters in this sector don't attack
s.flags.noattack = true; // Also works s.flags.noattack = true; // Also works
``` ```
---
### index ### index
The `Sidedef`'s index. Read-only. The `Sidedef`'s index. Read-only.
---
### isFront ### isFront
`true` if this `Sidedef` is the front of its `Linedef`, otherwise `false`. Read-only. `true` if this `Sidedef` is the front of its `Linedef`, otherwise `false`. Read-only.
---
### line ### line
The `Linedef` the `Sidedef` belongs to. Read-only. The `Linedef` the `Sidedef` belongs to. Read-only.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### lowerHighlighted
If the `Sidedef`'s lower part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### lowerSelected
If the `Sidedef`'s lower part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### lowerTexture ### lowerTexture
The `Sidedef`'s lower texture. The `Sidedef`'s lower texture.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### middleHighlighted
If the `Sidedef`'s middle part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### middleSelected
If the `Sidedef`'s middle part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### middleTexture ### middleTexture
The `Sidedef`'s middle texture. The `Sidedef`'s middle texture.
---
### offsetX ### offsetX
The x offset of the `Sidedef`'s textures. The x offset of the `Sidedef`'s textures.
---
### offsetY ### offsetY
The y offset of the `Sidedef`'s textures. The y offset of the `Sidedef`'s textures.
---
### other ### other
The `Sidedef` on the other side of this `Sidedef`'s `Linedef`. Returns `null` if there is no other. Read-only. The `Sidedef` on the other side of this `Sidedef`'s `Linedef`. Returns `null` if there is no other. Read-only.
---
### sector ### sector
The `Sector` the `Sidedef` belongs to. Read-only. The `Sector` the `Sidedef` belongs to. Read-only.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### upperHighlighted
If the `Sidedef`'s upper part is highlighted or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
<span style="float:right;font-weight:normal;font-size:66%">Version: 3</span>
### upperSelected
If the `Sidedef`'s upper part is selected or not. Will always return `true` in classic modes if the parent `Linedef` is selected.
---
### upperTexture ### upperTexture
The `Sidedef`'s upper texture. The `Sidedef`'s upper texture.

View file

@ -1,14 +1,24 @@
# Thing # Thing
## Properties ## Properties
---
### action ### action
`Thing` action. Hexen and UDMF only. `Thing` action. Hexen and UDMF only.
---
### angle ### angle
Angle of the `Thing` in degrees, see https://doomwiki.org/wiki/Angle. Angle of the `Thing` in degrees, see https://doomwiki.org/wiki/Angle.
---
### angleRad ### angleRad
Angle of the `Thing` in radians. Angle of the `Thing` in radians.
---
### args ### args
`Array` of arguments of the `Thing`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only. `Array` of arguments of the `Thing`. Number of arguments depends on game config (usually 5). Hexen format and UDMF only.
---
### fields ### fields
UDMF fields. It's an object with the fields as properties. UDMF fields. It's an object with the fields as properties.
@ -37,6 +47,8 @@ To remove a field you have to assign `null` to it:
```js ```js
s.fields.user_myintfield = null; s.fields.user_myintfield = null;
``` ```
---
### flags ### flags
`Thing` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name. `Thing` flags. It's an object with the flags as properties. In Doom format and Hexen format they are identified by numbers, in UDMF by their name.
Doom and Hexen: Doom and Hexen:
@ -50,12 +62,20 @@ UDMF:
t.flags['ambush'] = true; // Set the ambush flag t.flags['ambush'] = true; // Set the ambush flag
t.flags.ambush = true; // Also works t.flags.ambush = true; // Also works
``` ```
---
### index ### index
Index of the `Thing`. Read-only. Index of the `Thing`. Read-only.
---
### marked ### marked
If the `Thing` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry). If the `Thing` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### pitch ### pitch
Pitch of the `Thing` in degrees. Only valid for supporting game configurations. Pitch of the `Thing` in degrees. Only valid for supporting game configurations.
---
### position ### position
Position of the `Thing`. It's an object with `x`, `y`, and `z` properties. The latter is only relevant in Hexen format and UDMF. Position of the `Thing`. It's an object with `x`, `y`, and `z` properties. The latter is only relevant in Hexen format and UDMF.
The `x`, `y`, and `z` accept numbers: The `x`, `y`, and `z` accept numbers:
@ -72,23 +92,39 @@ t.position = new Vector3D(32, 64, 128);
t.position = [ 32, 64 ]; t.position = [ 32, 64 ];
t.position = [ 32, 64, 128 ]; t.position = [ 32, 64, 128 ];
``` ```
---
### roll ### roll
Roll of the `Thing` in degrees. Only valid for supporting game configurations. Roll of the `Thing` in degrees. Only valid for supporting game configurations.
---
### selected ### selected
If the `Thing` is selected or not. If the `Thing` is selected or not.
---
### tag ### tag
`Thing` tag. UDMF only. `Thing` tag. UDMF only.
---
### type ### type
Type of the `Thing`. Type of the `Thing`.
## Methods ## Methods
---
### clearFlags() ### clearFlags()
Clears all flags. Clears all flags.
---
### copyPropertiesTo(t) ### copyPropertiesTo(t)
Copies the properties from this `Thing` to another. Copies the properties from this `Thing` to another.
#### Parameters #### Parameters
* t: The `Thing` to copy the properties to * t: The `Thing` to copy the properties to
---
### delete() ### delete()
Deletes the `Thing`. Deletes the `Thing`.
---
### distanceTo(pos) ### distanceTo(pos)
Gets the distance between this `Thing` and the given point. The point can be either a `Vector2D` or an array of numbers. Gets the distance between this `Thing` and the given point. The point can be either a `Vector2D` or an array of numbers.
@ -100,6 +136,8 @@ t.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the distance to. * pos: Point to calculate the distance to.
#### Return value #### Return value
Distance to `pos` Distance to `pos`
---
### distanceToSq(pos) ### distanceToSq(pos)
Gets the squared distance between this `Thing` and the given point. Gets the squared distance between this `Thing` and the given point.
The point can be either a `Vector2D` or an array of numbers. The point can be either a `Vector2D` or an array of numbers.
@ -112,11 +150,17 @@ t.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the squared distance to. * pos: Point to calculate the squared distance to.
#### Return value #### Return value
Distance to `pos` Distance to `pos`
---
### getSector() ### getSector()
Determines and returns the `Sector` the `Thing` is in. Determines and returns the `Sector` the `Thing` is in.
#### Return value #### Return value
The `Sector` the `Thing` is in The `Sector` the `Thing` is in
---
### snapToAccuracy() ### snapToAccuracy()
Snaps the `Thing`'s position to the map format's accuracy. Snaps the `Thing`'s position to the map format's accuracy.
---
### snapToGrid() ### snapToGrid()
Snaps the `Thing`'s position to the grid. Snaps the `Thing`'s position to the grid.

View file

@ -1,6 +1,8 @@
# Vector2D # Vector2D
## Constructors ## Constructors
---
### Vector2D(v) ### Vector2D(v)
Creates a new `Vector2D` from a point. Creates a new `Vector2D` from a point.
@ -9,6 +11,8 @@ let v = new Vector2D([ 32, 64 ]);
``` ```
#### Parameters #### Parameters
* v: The vector to create the `Vector2D` from * v: The vector to create the `Vector2D` from
---
### Vector2D(x, y) ### Vector2D(x, y)
Creates a new `Vector2D` from x and y coordinates Creates a new `Vector2D` from x and y coordinates
@ -19,6 +23,8 @@ let v = new Vector2D(32, 64);
* x: The x coordinate * x: The x coordinate
* y: The y coordinate * y: The y coordinate
## Static methods ## Static methods
---
### crossProduct(a, b) ### crossProduct(a, b)
Returns the cross product of two `Vector2D`s. Returns the cross product of two `Vector2D`s.
#### Parameters #### Parameters
@ -26,6 +32,8 @@ Returns the cross product of two `Vector2D`s.
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
Cross product of the two vectors as `Vector2D` Cross product of the two vectors as `Vector2D`
---
### dotProduct(a, b) ### dotProduct(a, b)
Returns the dot product of two `Vector2D`s. Returns the dot product of two `Vector2D`s.
#### Parameters #### Parameters
@ -33,18 +41,24 @@ Returns the dot product of two `Vector2D`s.
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
The dot product of the two vectors The dot product of the two vectors
---
### fromAngle(angle) ### fromAngle(angle)
Creates a `Vector2D` from an angle in degrees, Creates a `Vector2D` from an angle in degrees,
#### Parameters #### Parameters
* angle: Angle in degrees * angle: Angle in degrees
#### Return value #### Return value
Vector as `Vector2D` Vector as `Vector2D`
---
### fromAngleRad(angle) ### fromAngleRad(angle)
Creates a `Vector2D` from an angle in radians, Creates a `Vector2D` from an angle in radians,
#### Parameters #### Parameters
* angle: Angle in radians * angle: Angle in radians
#### Return value #### Return value
Vector as `Vector2D` Vector as `Vector2D`
---
### getAngle(a, b) ### getAngle(a, b)
Returns the angle between two `Vector2D`s in degrees. Returns the angle between two `Vector2D`s in degrees.
#### Parameters #### Parameters
@ -52,6 +66,8 @@ Returns the angle between two `Vector2D`s in degrees.
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
Angle in degrees Angle in degrees
---
### getAngleRad(a, b) ### getAngleRad(a, b)
Returns the angle between two `Vector2D`s in radians Returns the angle between two `Vector2D`s in radians
#### Parameters #### Parameters
@ -59,6 +75,8 @@ Returns the angle between two `Vector2D`s in radians
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
Angle in radians Angle in radians
---
### getDistance(a, b) ### getDistance(a, b)
Returns the distance between two `Vector2D`s. Returns the distance between two `Vector2D`s.
#### Parameters #### Parameters
@ -66,6 +84,8 @@ Returns the distance between two `Vector2D`s.
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
The distance The distance
---
### getDistanceSq(a, b) ### getDistanceSq(a, b)
Returns the square distance between two `Vector2D`s. Returns the square distance between two `Vector2D`s.
#### Parameters #### Parameters
@ -73,6 +93,8 @@ Returns the square distance between two `Vector2D`s.
* b: Second `Vector2D` * b: Second `Vector2D`
#### Return value #### Return value
The squared distance The squared distance
---
### reflect(v, m) ### reflect(v, m)
Reflects a `Vector2D` over a mirror `Vector2D`. Reflects a `Vector2D` over a mirror `Vector2D`.
#### Parameters #### Parameters
@ -80,6 +102,8 @@ Reflects a `Vector2D` over a mirror `Vector2D`.
* m: Mirror `Vector2D` * m: Mirror `Vector2D`
#### Return value #### Return value
The reflected vector as `Vector2D` The reflected vector as `Vector2D`
---
### reversed(v) ### reversed(v)
Returns a reversed `Vector2D`. Returns a reversed `Vector2D`.
#### Parameters #### Parameters
@ -87,19 +111,29 @@ Returns a reversed `Vector2D`.
#### Return value #### Return value
The reversed vector as `Vector2D` The reversed vector as `Vector2D`
## Properties ## Properties
---
### x ### x
The `x` value of the vector. The `x` value of the vector.
---
### y ### y
The `y` value of the vector. The `y` value of the vector.
## Methods ## Methods
---
### getAngle() ### getAngle()
Returns the angle of the `Vector2D` in degree. Returns the angle of the `Vector2D` in degree.
#### Return value #### Return value
The angle of the `Vector2D` in degree The angle of the `Vector2D` in degree
---
### getAngleRad() ### getAngleRad()
Returns the angle of the `Vector2D` in radians. Returns the angle of the `Vector2D` in radians.
#### Return value #### Return value
The angle of the `Vector2D` in radians The angle of the `Vector2D` in radians
---
### getInverseTransformed(invoffsetx, invoffsety, invscalex, invscaley) ### getInverseTransformed(invoffsetx, invoffsety, invscalex, invscaley)
Returns the inverse transformed vector as `Vector2D`. Returns the inverse transformed vector as `Vector2D`.
#### Parameters #### Parameters
@ -109,38 +143,54 @@ Returns the inverse transformed vector as `Vector2D`.
* invscaley: Y scale * invscaley: Y scale
#### Return value #### Return value
The inverse transformed vector as `Vector2D` The inverse transformed vector as `Vector2D`
---
### getLength() ### getLength()
Returns the length of the `Vector2D`. Returns the length of the `Vector2D`.
#### Return value #### Return value
The length of the `Vector2D` The length of the `Vector2D`
---
### getLengthSq() ### getLengthSq()
Returns the square length of the `Vector2D`. Returns the square length of the `Vector2D`.
#### Return value #### Return value
The square length of the `Vector2D` The square length of the `Vector2D`
---
### getNormal() ### getNormal()
Returns the normal of the `Vector2D`. Returns the normal of the `Vector2D`.
#### Return value #### Return value
The normal as `Vector2D` The normal as `Vector2D`
---
### getPerpendicular() ### getPerpendicular()
Returns the perpendicular to the `Vector2D`. Returns the perpendicular to the `Vector2D`.
#### Return value #### Return value
The perpendicular as `Vector2D` The perpendicular as `Vector2D`
---
### getRotated(theta) ### getRotated(theta)
Returns the rotated vector as `Vector2D`. Returns the rotated vector as `Vector2D`.
#### Parameters #### Parameters
* theta: Angle in degree to rotate by * theta: Angle in degree to rotate by
#### Return value #### Return value
The rotated `Vector2D` The rotated `Vector2D`
---
### getRotatedRad(theta) ### getRotatedRad(theta)
Returns the rotated vector as `Vector2D`. Returns the rotated vector as `Vector2D`.
#### Parameters #### Parameters
* theta: Angle in radians to rotate by * theta: Angle in radians to rotate by
#### Return value #### Return value
The rotated `Vector2D` The rotated `Vector2D`
---
### getSign() ### getSign()
Returns a `Vector2D` with the sign of all components. Returns a `Vector2D` with the sign of all components.
#### Return value #### Return value
A `Vector2D` with the sign of all components A `Vector2D` with the sign of all components
---
### getTransformed(offsetx, offsety, scalex, scaley) ### getTransformed(offsetx, offsety, scalex, scaley)
Returns the transformed vector as `Vector2D`. Returns the transformed vector as `Vector2D`.
#### Parameters #### Parameters
@ -150,6 +200,8 @@ Returns the transformed vector as `Vector2D`.
* scaley: Y scale * scaley: Y scale
#### Return value #### Return value
The transformed vector as `Vector2D` The transformed vector as `Vector2D`
---
### isFinite() ### isFinite()
Checks if the `Vector2D` is finite or not. Checks if the `Vector2D` is finite or not.
#### Return value #### Return value

View file

@ -1,6 +1,8 @@
# Vector3D # Vector3D
## Constructors ## Constructors
---
### Vector3D(v) ### Vector3D(v)
Creates a new `Vector3D` from a point. Creates a new `Vector3D` from a point.
@ -9,6 +11,8 @@ let v = new Vector3D([ 32, 64, 128 ]);
``` ```
#### Parameters #### Parameters
* v: The vector to create the `Vector3D` from * v: The vector to create the `Vector3D` from
---
### Vector3D(x, y, z) ### Vector3D(x, y, z)
Creates a new `Vector3D` from x and y coordinates Creates a new `Vector3D` from x and y coordinates
@ -20,6 +24,8 @@ let v = new Vector3D(32, 64, 128);
* y: The y coordinate * y: The y coordinate
* z: The z coordinate * z: The z coordinate
## Static methods ## Static methods
---
### crossProduct(a, b) ### crossProduct(a, b)
Returns the cross product of two `Vector3D`s. Returns the cross product of two `Vector3D`s.
#### Parameters #### Parameters
@ -27,6 +33,8 @@ Returns the cross product of two `Vector3D`s.
* b: Second `Vector3D` * b: Second `Vector3D`
#### Return value #### Return value
Cross product of the two vectors as `Vector3D` Cross product of the two vectors as `Vector3D`
---
### dotProduct(a, b) ### dotProduct(a, b)
Returns the dot product of two `Vector3D`s. Returns the dot product of two `Vector3D`s.
#### Parameters #### Parameters
@ -34,18 +42,24 @@ Returns the dot product of two `Vector3D`s.
* b: Second `Vector3D` * b: Second `Vector3D`
#### Return value #### Return value
The dot product of the two vectors The dot product of the two vectors
---
### fromAngleXY(angle) ### fromAngleXY(angle)
Creates a `Vector3D` from an angle in radians, Creates a `Vector3D` from an angle in radians,
#### Parameters #### Parameters
* angle: Angle on the x/y axes in degrees * angle: Angle on the x/y axes in degrees
#### Return value #### Return value
Vector as `Vector3D` Vector as `Vector3D`
---
### fromAngleXYRad(angle) ### fromAngleXYRad(angle)
Creates a `Vector3D` from an angle in radians Creates a `Vector3D` from an angle in radians
#### Parameters #### Parameters
* angle: Angle on the x/y axes in radians * angle: Angle on the x/y axes in radians
#### Return value #### Return value
Vector as `Vector3D` Vector as `Vector3D`
---
### fromAngleXYZ(anglexy, anglez) ### fromAngleXYZ(anglexy, anglez)
Creates a `Vector3D` from two angles in degrees Creates a `Vector3D` from two angles in degrees
#### Parameters #### Parameters
@ -53,6 +67,8 @@ Creates a `Vector3D` from two angles in degrees
* anglez: Angle on the z axis in radians * anglez: Angle on the z axis in radians
#### Return value #### Return value
Vector as `Vector3D` Vector as `Vector3D`
---
### fromAngleXYZRad(anglexy, anglez) ### fromAngleXYZRad(anglexy, anglez)
Creates a `Vector3D` from two angles in radians Creates a `Vector3D` from two angles in radians
#### Parameters #### Parameters
@ -60,6 +76,8 @@ Creates a `Vector3D` from two angles in radians
* anglez: Angle on the z axis in radians * anglez: Angle on the z axis in radians
#### Return value #### Return value
Vector as `Vector3D` Vector as `Vector3D`
---
### reflect(v, m) ### reflect(v, m)
Reflects a `Vector3D` over a mirror `Vector3D`. Reflects a `Vector3D` over a mirror `Vector3D`.
#### Parameters #### Parameters
@ -67,6 +85,8 @@ Reflects a `Vector3D` over a mirror `Vector3D`.
* m: Mirror `Vector3D` * m: Mirror `Vector3D`
#### Return value #### Return value
The reflected vector as `Vector3D` The reflected vector as `Vector3D`
---
### reversed(v) ### reversed(v)
Returns a reversed `Vector3D`. Returns a reversed `Vector3D`.
#### Parameters #### Parameters
@ -74,51 +94,77 @@ Returns a reversed `Vector3D`.
#### Return value #### Return value
The reversed vector as `Vector3D` The reversed vector as `Vector3D`
## Properties ## Properties
---
### x ### x
The `x` value of the vector. The `x` value of the vector.
---
### y ### y
The `y` value of the vector. The `y` value of the vector.
---
### z ### z
The `z` value of the vector. The `z` value of the vector.
## Methods ## Methods
---
### getAngleXY() ### getAngleXY()
Returns the angle of the `Vector3D` in degrees. Returns the angle of the `Vector3D` in degrees.
#### Return value #### Return value
The angle of the `Vector3D` in degrees The angle of the `Vector3D` in degrees
---
### getAngleXYRad() ### getAngleXYRad()
Returns the x/y angle of the `Vector3D` in radians. Returns the x/y angle of the `Vector3D` in radians.
#### Return value #### Return value
The x/y angle of the `Vector3D` in radians The x/y angle of the `Vector3D` in radians
---
### getAngleZ() ### getAngleZ()
Returns the z angle of the `Vector3D` in degrees. Returns the z angle of the `Vector3D` in degrees.
#### Return value #### Return value
The z angle of the `Vector3D` in degrees The z angle of the `Vector3D` in degrees
---
### getAngleZRad() ### getAngleZRad()
Returns the z angle of the `Vector3D` in radians. Returns the z angle of the `Vector3D` in radians.
#### Return value #### Return value
The z angle of the `Vector3D` in radians The z angle of the `Vector3D` in radians
---
### getLength() ### getLength()
Returns the length of the `Vector3D`. Returns the length of the `Vector3D`.
#### Return value #### Return value
The length of the `Vector3D` The length of the `Vector3D`
---
### getLengthSq() ### getLengthSq()
Returns the square length of the `Vector3D`. Returns the square length of the `Vector3D`.
#### Return value #### Return value
The square length of the `Vector3D` The square length of the `Vector3D`
---
### getNormal() ### getNormal()
Returns the normal of the `Vector3D`. Returns the normal of the `Vector3D`.
#### Return value #### Return value
The normal as `Vector3D` The normal as `Vector3D`
---
### getScaled(scale) ### getScaled(scale)
Return the scaled `Vector3D`. Return the scaled `Vector3D`.
#### Parameters #### Parameters
* scale: Scale, where 1.0 is unscaled * scale: Scale, where 1.0 is unscaled
#### Return value #### Return value
The scaled `Vector3D` The scaled `Vector3D`
---
### isFinite() ### isFinite()
Checks if the `Vector3D` is finite or not. Checks if the `Vector3D` is finite or not.
#### Return value #### Return value
`true` if `Vector3D` is finite, otherwise `false` `true` if `Vector3D` is finite, otherwise `false`
---
### isNormalized() ### isNormalized()
Checks if the `Vector3D` is normalized or not. Checks if the `Vector3D` is normalized or not.
#### Return value #### Return value

View file

@ -1,8 +1,12 @@
# Vertex # Vertex
## Properties ## Properties
---
### ceilingZ ### ceilingZ
The ceiling z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations. The ceiling z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations.
---
### fields ### fields
UDMF fields. It's an object with the fields as properties. UDMF fields. It's an object with the fields as properties.
@ -31,12 +35,20 @@ To remove a field you have to assign `null` to it:
```js ```js
s.fields.user_myintfield = null; s.fields.user_myintfield = null;
``` ```
---
### floorZ ### floorZ
The floor z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations. The floor z position of the `Vertex`. Only available in UDMF. Only available for supported game configurations.
---
### index ### index
The vertex index. Read-only. The vertex index. Read-only.
---
### marked ### marked
If the `Vertex` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry). If the `Vertex` is marked or not. It is used to mark map elements that were created or changed (for example after drawing new geometry).
---
### position ### position
Position of the `Vertex`. It's an object with `x` and `y` properties. Position of the `Vertex`. It's an object with `x` and `y` properties.
The `x` and `y` accept numbers: The `x` and `y` accept numbers:
@ -51,15 +63,23 @@ It's also possible to set all fields immediately by assigning either a `Vector2D
v.position = new Vector2D(32, 64); v.position = new Vector2D(32, 64);
v.position = [ 32, 64 ]; v.position = [ 32, 64 ];
``` ```
---
### selected ### selected
If the `Vertex` is selected or not. If the `Vertex` is selected or not.
## Methods ## Methods
---
### copyPropertiesTo(v) ### copyPropertiesTo(v)
Copies the properties from this `Vertex` to another. Copies the properties from this `Vertex` to another.
#### Parameters #### Parameters
* v: the vertex to copy the properties to * v: the vertex to copy the properties to
---
### delete() ### delete()
Deletes the `Vertex`. Note that this can result in unclosed sectors. Deletes the `Vertex`. Note that this can result in unclosed sectors.
---
### distanceTo(pos) ### distanceTo(pos)
Gets the distance between this `Vertex` and the given point. Gets the distance between this `Vertex` and the given point.
The point can be either a `Vector2D` or an array of numbers. The point can be either a `Vector2D` or an array of numbers.
@ -72,6 +92,8 @@ v.distanceTo([ 32, 64 ]);
* pos: Point to calculate the distance to. * pos: Point to calculate the distance to.
#### Return value #### Return value
Distance to `pos` Distance to `pos`
---
### distanceToSq(pos) ### distanceToSq(pos)
Gets the squared distance between this `Vertex` and the given point. Gets the squared distance between this `Vertex` and the given point.
The point can be either a `Vector2D` or an array of numbers. The point can be either a `Vector2D` or an array of numbers.
@ -84,21 +106,31 @@ v.distanceToSq([ 32, 64 ]);
* pos: Point to calculate the squared distance to. * pos: Point to calculate the squared distance to.
#### Return value #### Return value
Squared distance to `pos` Squared distance to `pos`
---
### getLinedefs() ### getLinedefs()
Gets all `Linedefs` that are connected to this `Vertex`. Gets all `Linedefs` that are connected to this `Vertex`.
#### Return value #### Return value
Array of linedefs Array of linedefs
---
### join(other) ### join(other)
Joins this `Vertex` with another `Vertex`, deleting this `Vertex` and keeping the other. Joins this `Vertex` with another `Vertex`, deleting this `Vertex` and keeping the other.
#### Parameters #### Parameters
* other: `Vertex` to join with * other: `Vertex` to join with
---
### nearestLinedef(pos) ### nearestLinedef(pos)
Returns the `Linedef` that is connected to this `Vertex` that is closest to the given point. Returns the `Linedef` that is connected to this `Vertex` that is closest to the given point.
#### Parameters #### Parameters
* pos: Point to get the nearest `Linedef` connected to this `Vertex` from * pos: Point to get the nearest `Linedef` connected to this `Vertex` from
#### Return value #### Return value
*missing* *missing*
---
### snapToAccuracy() ### snapToAccuracy()
Snaps the `Vertex`'s position to the map format's accuracy. Snaps the `Vertex`'s position to the map format's accuracy.
---
### snapToGrid() ### snapToGrid()
Snaps the `Vertex`'s position to the grid. Snaps the `Vertex`'s position to the grid.

View file

@ -0,0 +1,18 @@
# Changes
This site lists all changes between different API version of UDBScript
## Version 3
- Exported the classes `Linedef`, `Sector`, `Sidedef`, `Thing`, and `Vertex`, so that they can be used with `instanceof`
- `Map` class
- the `getSidedefsFromSelectedLinedefs()` method now correctly only returns the `Sidedef`s of selected `Linedef`s in visual mode (and not also the highlighted one)
- added a new `getSidedefsFromSelectedOrHighlightedLinedefs()` method as the equivalent to the other `getSelectedOrHighlighted*()` methods
- `Sector` class
- added new `floorSelected`, `ceilingSelected`, `floorHighlighted`, and `ceilingHighlighted` properties. Those are mostly useful in visual mode, since they always return true when the `Sector` is selected or highlighted in the classic modes. The properties are read-only
- `Sidedef` class
- added new `upperSelected`, `middleSelected`, `lowerSelected`, `upperHighlighted`, `middleHighlighted`, and `lowerHighlighted` properties. Those are mostly useful in visual mode, since they always return true when the parent `Linedef` is selected or highlighted in the classic modes. The properties are read-only
## Version 2
- `Pen` built-in library
- the methods of the `Pen` class now return the instance of the Pen class to allow method chaining

View file

@ -247,11 +247,15 @@ let v2 = new Vector2D(2, 3) * 3; // Results in new Vector(6, 9)
### Working with map elements ### Working with map elements
Map elements (things, sectors, linedefs, sidedefs, vertices) can be accessed through the global `Map` object. This object has methods that return an array of map elements, for example `Map.getSectors()` returns an array of `Sector` objects, which are are all sectors in the map. There are also methods to get all selected (for example `Map.getSelectedSectors()`) and marked (for example `Map.getMarkedSectors()`) map elements. These map elements can then be modified, see the documentation for the particular map element type in the API section. Map elements (things, sectors, linedefs, sidedefs, vertices) can be accessed through the global `Map` object. This object has methods that return an array of map elements, for example `Map.getSectors()` returns an array of `Sector` objects, which are are all sectors in the map. There are also methods to get all selected (for example `Map.getSelectedSectors()`) and marked (for example `Map.getMarkedSectors()`), or the currently highlighted (for example `Map.getHighlightedSector()`) map elements. There are also methods to get either the currently selected map elements, *or* the currently highlighted map elements (for example `Map.getSelectedOrHighlightedSectors()`). These map elements can then be modified, see the documentation for the particular map element type in the API section.
!!! note !!! note
"Marking" a map element is a way to denote that something happened to this map element. For example when using the `Map.drawLines()` method all new geometry will be marked. "Marking" a map element is a way to denote that something happened to this map element. For example when using the `Map.drawLines()` method all new geometry will be marked.
!!! info
UDB differentiates between "selecting" and "highlighting" map elements. "Selecting" means clicking on the map element, "highlighting" means just hovering the mouse on (or near) a map element. All the `Map.getSelectedOrHighlighted...()` methods behave like UDB usually works, i.e. if at least one map element is selected, the selected map elements will be returned (and the highlighted map element will be ignored), if no map elements are selected the highlighted map element will be returned.
In most circumstances it is recommended to use the `Map.getSelectedOrHighlighted...()` to stay close to UDB's built-in actions.
### Creating new geometry ### Creating new geometry
New map geometry can be created with the `drawLines()` method of the `Map` object. It accepts an array of coordinates in map space. The coordinates can either by instances of `Vector2D`, `Vector3D`, or an array of numbers. New map geometry can be created with the `drawLines()` method of the `Map` object. It accepts an array of coordinates in map space. The coordinates can either by instances of `Vector2D`, `Vector3D`, or an array of numbers.

View file

@ -3,6 +3,7 @@
## UDB script ## UDB script
- [Getting started](gettingstarted.md) - [Getting started](gettingstarted.md)
- [Changes](changes.md)
## API ## API

View file

@ -1,12 +1,13 @@
site_name: UDB Script site_name: UDBScript
theme: readthedocs theme: readthedocs
markdown_extensions: markdown_extensions:
- admonition - admonition
- footnotes - footnotes
nav: nav:
- 'UDB Script': - 'UDBScript':
- Index: 'index.md' - Index: 'index.md'
- 'Getting started': 'gettingstarted.md' - 'Getting started': 'gettingstarted.md'
- 'Changes': 'changes.md'
- 'API': - 'API':
- Angle2D: 'Angle2D.md' - Angle2D: 'Angle2D.md'
- Data: 'Data.md' - Data: 'Data.md'