Methods

(static) getLinesIntersection2v(start1, end1, start2, end2, isSegmentopt) → {Vec2}

Returns two segment lines intersection coordinate.

Parameters:
NameTypeAttributesDescription
start1Vec2

First line first coordinate.

end1Vec2

First line second coordinate.

start2Vec2

Second line first coordinate.

end2Vec2

Second line second coordinate.

isSegmentboolean<optional>

Lines are segments.

Returns:
  • Intersection coordinate.
Type: 
Vec2

(static) getLinesIntersectionLonLat(start1, end1, start2, end2, isSegmentopt) → {Vec2}

Returns two segment lines intersection coordinate.

Parameters:
NameTypeAttributesDefaultDescription
start1Vec2

First line first coordinate.

end1Vec2

First line second coordinate.

start2Vec2

Second line first coordinate.

end2Vec2

Second line second coordinate.

isSegmentboolean<optional>
false

Lines are segments.

Returns:
  • Intersection coordinate.
Type: 
Vec2

(static) getMatrixSubArray32(sourceArr, gridSize, i0, j0, size) → {Float32Array}

Returns 32-bit triangle coordinate array from inside of the source triangle array.

Parameters:
NameTypeDescription
sourceArrTypedArray | Array.<number>

Source array

gridSizenumber

Source array square matrix size

i0number

First row index source array matrix

j0number

First column index

sizenumber

Square matrix result size.

Returns:

Triangle coordinates array from the source array.

Type: 
Float32Array

(static) getMatrixSubArray64(sourceArr, gridSize, i0, j0, size) → {Float64Array}

Returns 64-bit triangle coordinate array from inside of the source triangle array.

Parameters:
NameTypeDescription
sourceArrTypedArray | Array.<number>

Source array

gridSizenumber

Source array square matrix size

i0number

First row index source array matrix

j0number

First column index

sizenumber

Square matrix result size.

Returns:

Triangle coordinates array from the source array.

Type: 
Float64Array

(static) xmlToJson(xml) → {Object}

Converts XML to JSON

Parameters:
NameTypeDescription
xmlObject

Xml object

Returns:
  • Json converted object.
Type: 
Object

(inner) binaryInsert(ar, el, compare_fn) → {number}

Parameters:
NameTypeDescription
arArray.<any>

The sorted array to insert.

elany

The item to insert.

compare_fnfunction

comparator The function to use to compare the item to elements in the array.

Returns:

Array index position in which item inserted in.

Type: 
number

(inner) binarySearch(ar, el, compare_fn) → {number}

Finds an item in a sorted array.

Parameters:
NameTypeDescription
arArray.<any>

The sorted array to search.

elany

The item to find in the array.

compare_fnfunction

comparator The function to use to compare the item to elements in the array.

Returns:

a negative number if 'a' is less than 'b'; 0 if 'a' is equal to 'b'; 'a' positive number of 'a' is greater than 'b'.

Type: 
number
Example
// Create a comparator function to search through an array of numbers.
function comparator(a, b) {
    return a - b;
};
var numbers = [0, 2, 4, 6, 8];
var index = og.utils.binarySearch(numbers, 6, comparator); // 3

(inner) blerp(x, y, fQ11, fQ21, fQ12, fQ22, x1opt, x2opt, y1opt, y2opt)

y2-----Q12--------------Q22--- | | | | | | | | y-------|-----P----------|---- | | | | | | | | | | | | | | | | | | | | y1-----Q11----|---------Q21--- | | | | | | x1 x x2

Parameters:
NameTypeAttributesDefaultDescription
xNumber
yNumber
fQ11Number
fQ21Number
fQ12Number
fQ22Number
x1Number<optional>
0.0
x2Number<optional>
1.0
y1Number<optional>
0.0
y2Number<optional>
1.0

(inner) concatArrays(aopt, bopt) → {TypedArray|Array.<number>}

Concatenates two the same arrays

Parameters:
NameTypeAttributesDefaultDescription
aTypedArray | Array.<number><optional>
[]

First array

bTypedArray | Array.<number><optional>
[]

Second array

Returns:
Type: 
TypedArray | Array.<number>

(inner) concatTypedArrays(a, b)

Concatenates two the same type arrays

Parameters:
NameTypeDescription
aTypedArray
bTypedArray | Array.<number>

(inner) getMatrixSubArrayBoundsExt()

Returns two float32 triangle coordinate arrays from inside of the source triangle array.

(inner) htmlColorToRgb(htmlColor) → {Vec3}

Convert html color string to the RGB number vector.

Parameters:
NameTypeDescription
htmlColorstring

HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.

Returns:
Type: 
Vec3

(inner) htmlColorToRgba(htmlColor, opacityopt) → {Vec4}

Convert html color string to the RGBA number vector.

Parameters:
NameTypeAttributesDescription
htmlColorstring

HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.

opacitynumber<optional>

Opacity for the output vector.

Returns:
Type: 
Vec4

(inner) isImageLoaded(image) → {boolean}

Gets image is loaded

Parameters:
NameTypeDescription
imageHTMLImageElement
Returns:

Returns true is the image is loaded

Type: 
boolean

(inner) isUndef(obj) → {boolean}

Returns true if the object pointer is undefined.

Parameters:
NameTypeDescription
objObject

Object pointer.

Returns:

Returns true if object is undefined.

Type: 
boolean

(async, inner) loadImage(url) → {Promise.<Image>}

Promise for load images

Parameters:
NameTypeDescription
urlstring

link to image.

Returns:

Returns promise.

Type: 
Promise.<Image>

(inner) makeArray(arr) → {Array.<number>}

Convert typed array to array

Parameters:
NameTypeDescription
arrTypedArray | Array.<number>
Returns:
Type: 
Array.<number>

(inner) makeArrayTyped(arr, ctor) → {TypedArray}

Convert simple array to typed

Parameters:
NameTypeDescription
arrArray.<number>
ctorFloat32Array
Returns:
Type: 
TypedArray

(inner) spliceArray(arr, starting, deleteCount, outopt)

Parameters:
NameTypeAttributesDescription
arrTypedArray | Array
startingNumber
deleteCountNumber
outObject<optional>

(inner) spliceTypedArray(arr, starting, deleteCount, outopt)

Parameters:
NameTypeAttributesDescription
arrTypedArray
startingNumber
deleteCountNumber
outObject<optional>

(inner) stringTemplate(template, params) → {string}

Replace template substrings between '{' and '}' tokens.

Parameters:
NameTypeDescription
templatestring

String with templates in "{" and "}"

paramsObject

Template named object with subsrtings.

Returns:
Type: 
string
Example

Example from og.terrain that replaces tile indexes in url:

var substrings = {
      "x": 12,
      "y": 15,
      "z": 8
}
og.utils.stringTemplate("http://earth3.openglobus.org/{z}/{y}/{x}.ddm", substrings);
//returns http://earth3.openglobus.org/8/15/12.ddm

(inner) throttle(func, limit, skipopt)

Callback throttling

Parameters:
NameTypeAttributesDefaultDescription
funcany
limitNumber
skipboolean<optional>
false