From de8e9915aaf6f939d581d3a68dfc562f67563d19 Mon Sep 17 00:00:00 2001 From: m0ksem Date: Fri, 15 Mar 2019 21:57:38 +0200 Subject: [PATCH] Updated docs. --- docs/Camera.html | 4 +- docs/Camera.js.html | 4 +- docs/Controls.html | 4 +- docs/Controls.js.html | 38 +- docs/Cube.html | 408 ++++++++++++++- docs/Debugger.html | 4 +- docs/Debugger.js.html | 28 +- docs/Engine.html | 152 +----- docs/Engine.js.html | 94 ++-- docs/Object.html | 52 +- docs/Picture.html | 842 +++++++++++++++++++++++++++++++ docs/Polygon.html | 377 ++++++++++++-- docs/Rect.html | 356 +++++++++++-- docs/Texture.html | 4 +- docs/Texture.js.html | 4 +- docs/UI.html | 770 ++++++++++++++++++++++++++++ docs/Utils.js.html | 4 +- docs/global.html | 4 +- docs/index.html | 4 +- docs/math_Math.js.html | 4 +- docs/math_Matrixes.js.html | 32 +- docs/math_Vectors.js.html | 4 +- docs/module-Math.html | 4 +- docs/module-Matrixes.Matrix.html | 178 ++++++- docs/module-Matrixes.html | 22 +- docs/module-Vectors.html | 4 +- docs/objects_Cube.js.html | 62 ++- docs/objects_Object.js.html | 23 +- docs/objects_Polygon.js.html | 54 +- docs/objects_Rect.js.html | 37 +- docs/ui_UI.js.html | 123 +++++ docs/ui_elements_Picture.js.html | 111 ++++ 32 files changed, 3386 insertions(+), 425 deletions(-) create mode 100644 docs/Picture.html create mode 100644 docs/UI.html create mode 100644 docs/ui_UI.js.html create mode 100644 docs/ui_elements_Picture.js.html diff --git a/docs/Camera.html b/docs/Camera.html index 6741f52..7d5db30 100644 --- a/docs/Camera.html +++ b/docs/Camera.html @@ -1855,13 +1855,13 @@
Parameters:

diff --git a/docs/Camera.js.html b/docs/Camera.js.html index 04b6305..295af84 100644 --- a/docs/Camera.js.html +++ b/docs/Camera.js.html @@ -244,13 +244,13 @@

Source: Camera.js


diff --git a/docs/Controls.html b/docs/Controls.html index 0d02cbf..cc05d1e 100644 --- a/docs/Controls.html +++ b/docs/Controls.html @@ -2245,13 +2245,13 @@
Parameters:

diff --git a/docs/Controls.js.html b/docs/Controls.js.html index a4f3631..204c9ee 100644 --- a/docs/Controls.js.html +++ b/docs/Controls.js.html @@ -178,13 +178,13 @@

Source: Controls.js

return !this._rebind }; - engine.canvas.setAttribute('tabindex','0'); + engine.div.setAttribute('tabindex','0'); let lastMousePosition = null - engine.canvas.addEventListener('mousemove', (event) => { + engine.div.addEventListener('mousemove', (event) => { if (!this.pointerLocked) { - let mousePos = engine.canvas.getBoundingClientRect() + let mousePos = engine.div.getBoundingClientRect() let x = event.clientX - mousePos.left let y = event.clientY - mousePos.top this.mouse.x = x @@ -208,56 +208,56 @@

Source: Controls.js

}, false); window.addEventListener('mousemove', (event) => { - let canvasPos = engine.canvas.getBoundingClientRect() + let canvasPos = engine.div.getBoundingClientRect() let x = event.clientX let y = event.clientY if (x < canvasPos.right && x > canvasPos.left && y < canvasPos.bottom && y > canvasPos.top ) { this.mouseOverCanvas = true if (!this._focusOnlyIfClick && !this.isFocused) { - engine.canvas.focus() + engine.div.focus() } } else { this.mouseOverCanvas = false if (!this._focusOnlyIfClick) { - engine.canvas.blur() + engine.div.blur() } } }) - engine.canvas.onclick = () => { + engine.div.onclick = () => { if (this._focusOnlyIfClick && !this.isFocused) { - engine.canvas.focus() + engine.div.focus() } if (this._lockPointer) { - engine.canvas.requestPointerLock(); + engine.div.requestPointerLock(); } } - engine.canvas.onmousedown = (event) => { + engine.div.onmousedown = (event) => { this.mouse.buttons[event.button] = true if (this._mouseHandlers[2 + event.button] != null) this._mouseHandlers[2 + event.button](event) return false } - engine.canvas.onmouseup = (event) => { + engine.div.onmouseup = (event) => { this.mouse.buttons[event.button] = false return false } - engine.canvas.oncontextmenu = function() { + engine.div.oncontextmenu = function() { return false; } - engine.canvas.onblur = () => { + engine.div.onblur = () => { this.isFocused = false for (let i = 0; i < this._focusHandlers.length; i++) { this._blurHandlers[i]() } } - engine.canvas.onfocus = () => { + engine.div.onfocus = () => { this.isFocused = true for (let i = 0; i < this._focusHandlers.length; i++) { this._focusHandlers[i]() @@ -265,7 +265,7 @@

Source: Controls.js

} document.addEventListener('pointerlockchange', () => { - if(document.pointerLockElement === engine.canvas){ + if(document.pointerLockElement === engine.div){ this.pointerLocked = true } else { @@ -354,7 +354,7 @@

Source: Controls.js

* @public */ onMouseMove(handler) { - this.engine.canvas.addEventListener('mousemove', handler, false); + this.engine.div.addEventListener('mousemove', handler, false); } /** @@ -363,7 +363,7 @@

Source: Controls.js

* @public */ onContextMenu (handler) { - this.engine.canvas.oncontextmenu = handler + this.engine.div.oncontextmenu = handler } /** @@ -386,13 +386,13 @@

Source: Controls.js


diff --git a/docs/Cube.html b/docs/Cube.html index 6f37f9c..31d6ded 100644 --- a/docs/Cube.html +++ b/docs/Cube.html @@ -240,7 +240,7 @@
Type:
Source:
@@ -312,7 +312,75 @@
Type:
Source:
+ + + + + + + + + + + + + + + + +

(readonly) UIElement :boolean

+ + + + + + +
Type:
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -498,7 +566,7 @@
Parameters:
Source:
@@ -584,7 +652,7 @@

remove
Source:
@@ -765,7 +833,325 @@

Parameters:
Source:
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +

scale(x, y, z)

+ + + + + + +
+ Setting scaling for cube in percent +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +Number + + + + scaling in percent
y + + +Number + + + + scaling in percent
z + + +Number + + + + scaling in percent
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +

setAsUIElement(bool)

+ + + + + + +
+ Sets whether the all polygons will be attached to the camera like UI element. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bool + + +bolean + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + +
Deprecated:
  • Yes
+ + + + + + + + + + + +
Source:
+
@@ -946,7 +1332,7 @@
Parameters:
Source:
@@ -1127,7 +1513,7 @@
Parameters:
Source:
@@ -1285,7 +1671,7 @@
Parameters:
Source:
@@ -1535,7 +1921,7 @@
Parameters:
Source:
@@ -1579,13 +1965,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Debugger.html b/docs/Debugger.html index 07e7fe6..acf6eb0 100644 --- a/docs/Debugger.html +++ b/docs/Debugger.html @@ -198,13 +198,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Debugger.js.html b/docs/Debugger.js.html index 5103e51..ac1ba68 100644 --- a/docs/Debugger.js.html +++ b/docs/Debugger.js.html @@ -43,9 +43,8 @@

Source: Debugger.js

this.element = element } - addLog(name, object, value, view, output) { - output = output || this.defaultOutput - this.logArray.push({name: name, object: object, value: value, view: view, output: output}) + addLog(view, output) { + this.logArray.push({view: view, output: output}) this.addView(view) } @@ -54,13 +53,6 @@

Source: Debugger.js

return node } - defaultOutput (log) { - if (object != null) { - return log.name + " : " + log.object[log.value] - } - return "log.name" - } - addView(view) { this.element.appendChild(view) } @@ -70,6 +62,18 @@

Source: Debugger.js

e.view.innerText = e.output(e) }) } + + logObject (object) { + let output = '{\n' + for (let property in object) { + if (property[0] != '_') { + output += property + ': ' + object[property] + ',' + } + } + output.slice(-1, 1) + output += '}\n' + return output + } } @@ -80,13 +84,13 @@

Source: Debugger.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Engine.html b/docs/Engine.html index 2edee1d..87350ba 100644 --- a/docs/Engine.html +++ b/docs/Engine.html @@ -243,7 +243,7 @@
Type:
Source:
@@ -377,7 +377,7 @@
Type:
Source:
@@ -449,7 +449,7 @@
Type:
Source:
@@ -521,7 +521,7 @@
Type:
Source:
@@ -593,7 +593,7 @@
Type:
Source:
@@ -665,7 +665,7 @@
Type:
Source:
@@ -737,127 +737,7 @@
Type:
Source:
- - - - - - - -
- - - - - - - - -

ui :Object

- - - - - - -
Type:
- - - - - - -
Properties:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
ui.objects - - -Array - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
@@ -929,7 +809,7 @@
Type:
Source:
@@ -1058,7 +938,7 @@
Parameters:
Source:
@@ -1144,7 +1024,7 @@

canvasRe
Source:
@@ -1279,7 +1159,7 @@

Parameters:
Source:
@@ -1365,7 +1245,7 @@

(async) render<
Source:
@@ -1451,7 +1331,7 @@

runSource:
@@ -1586,7 +1466,7 @@
Parameters:
Source:
@@ -1630,13 +1510,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Engine.js.html b/docs/Engine.js.html index 35ede53..8c84e1b 100644 --- a/docs/Engine.js.html +++ b/docs/Engine.js.html @@ -43,31 +43,41 @@

Source: Engine.js

* @param {HTMLElement|HTMLCanvasElement} canvas */ export class Engine { - constructor (canvas) { + constructor (div) { /** - * WebGL context of canvas * @private */ - this.webGL = Utils.getWebGL(canvas) + this.div = div + this.div.style = "position: relative;" /** * Canvas for drawing. * @readonly */ - this.canvas = canvas + this.canvas = document.createElement('canvas') + this.canvas.width = div.width + this.canvas.height = div.height + + div.appendChild(this.canvas) + + /** + * WebGL context of canvas + * @private + */ + this.webGL = Utils.getWebGL(this.canvas) /** * Width of drawing resolution * @type {Number} */ - this.width = canvas.width + this.width = div.width /** * Height of drawing resolution. * @type {Number} */ - this.height = canvas.height + this.height = div.height /** * @type {Polygon[]} @@ -83,13 +93,10 @@

Source: Engine.js

this.objects = [] /** - * @type {Object} - * @property {Array} ui.objects - * @public + * @type {UI} + * @private */ - this.ui = { - objects: [] - } + this.ui = null /** * @type {Array.<{Texture}>} @@ -262,8 +269,15 @@

Source: Engine.js

this.polygons.forEach(element => { temp = new Matrixes.Matrix() - temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) - temp.multiply(this.camera.inventedMatrix) + + // temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) + if (!element.UIElement) { + temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) + temp.multiply(this.camera.inventedMatrix) + } else { + temp.projection(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) + } + world = new Matrixes.Matrix() world.multiply(Matrixes.inverse(Matrixes.translation(element.rotationPoint[0], element.rotationPoint[1], element.rotationPoint[2]))) world.translate(element.position[0], element.position[1], element.position[2]) @@ -277,8 +291,7 @@

Source: Engine.js

} world.multiply(rot) - world.translate(element.rotationPoint[0], element.rotationPoint[1], element.rotationPoint[2]) - world.scale(1, 1, 1) + world.translate(element.rotationPoint[0], element.rotationPoint[1], element.rotationPoint[2]) temp.multiply(world.matrix) @@ -290,9 +303,12 @@

Source: Engine.js

this.objects.forEach(element => { temp = new Matrixes.Matrix() - temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) + //temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) if (!element.UIElement) { + temp.perspective(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) temp.multiply(this.camera.inventedMatrix) + } else { + temp.projection(this.camera.fieldOfViewRad, this.width, this.height, 1, 20000) } world = new Matrixes.Matrix() world.multiply(Matrixes.inverse(Matrixes.translation(element.rotationPoint[0], element.rotationPoint[1], element.rotationPoint[2]))) @@ -464,40 +480,21 @@

Source: Engine.js

this.webGL.enable(this.webGL.DEPTH_TEST) }); - this.ui.objects.forEach(o => { - o.faces.forEach(face => { - // console.log(face) - - this.webGL.enableVertexAttribArray(this.positionLocation) - this.webGL.bindBuffer(this.webGL.ARRAY_BUFFER, face.vertexesBuffer) - this.webGL.vertexAttribPointer( - this.positionLocation, 3, this.webGL.FLOAT, false, 0, 0 - ) - - this.webGL.enableVertexAttribArray(this.textureCoordinatesLocation) - this.webGL.bindBuffer(this.webGL.ARRAY_BUFFER, face.coordsBuffer) - this.webGL.vertexAttribPointer( - this.textureCoordinatesLocation, 2, this.webGL.FLOAT, false, 0, 0 - ) - - this.webGL.enableVertexAttribArray(this.normalLocation); - this.webGL.bindBuffer(this.webGL.ARRAY_BUFFER, face.normalBuffer); - this.webGL.vertexAttribPointer( - this.normalLocation, 3, this.webGL.FLOAT, false, 0, 0) - - this.webGL.uniform1i(this.textureLocation, o.texture._textureBlockLocation) - this.webGL.uniformMatrix4fv(this.matrixLocation, false, o._matrix) - this.webGL.uniformMatrix4fv(this.objectRotationLocation, false, o._world) - - this.webGL.drawArrays(this.webGL.TRIANGLES, 0, face.vertexes.length / face.vertexesCount) - }) - }); - if (this.debugger != null) { this.debugger.updateInfo() } } + /** + * Drawing UI function. + * @private + */ + _drawUI () { + if (this.ui !== null) { + this.ui._draw() + } + } + /** * Rendering function. * @public @@ -505,6 +502,7 @@

Source: Engine.js

async render () { await this._update() await this._draw() + await this._drawUI() } /** @@ -569,13 +567,13 @@

Source: Engine.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Object.html b/docs/Object.html index 72facc8..9c7d947 100644 --- a/docs/Object.html +++ b/docs/Object.html @@ -138,7 +138,7 @@
Parameters:
Source:
@@ -328,7 +328,7 @@
Properties:
Source:
@@ -400,7 +400,7 @@
Type:
Source:
@@ -570,7 +570,7 @@
Properties:
Source:
@@ -740,7 +740,7 @@
Properties:
Source:
@@ -956,7 +956,7 @@
Properties:
Source:
@@ -1126,7 +1126,7 @@
Properties:
Source:
@@ -1296,7 +1296,7 @@
Properties:
Source:
@@ -1466,7 +1466,7 @@
Properties:
Source:
@@ -1538,7 +1538,7 @@
Type:
Source:
@@ -1610,7 +1610,7 @@
Type:
Source:
@@ -1782,7 +1782,7 @@
Parameters:
Source:
@@ -1917,7 +1917,7 @@
Parameters:
Source:
@@ -2003,7 +2003,7 @@

destroySource:
@@ -2138,7 +2138,7 @@
Parameters:
Source:
@@ -2319,7 +2319,7 @@
Parameters:
Source:
@@ -2500,7 +2500,7 @@
Parameters:
Source:
@@ -2681,7 +2681,7 @@
Parameters:
Source:
@@ -2862,7 +2862,7 @@
Parameters:
Source:
@@ -3043,7 +3043,7 @@
Parameters:
Source:
@@ -3224,7 +3224,7 @@
Parameters:
Source:
@@ -3405,7 +3405,7 @@
Parameters:
Source:
@@ -3586,7 +3586,7 @@
Parameters:
Source:
@@ -3721,7 +3721,7 @@
Parameters:
Source:
@@ -3765,13 +3765,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Picture.html b/docs/Picture.html new file mode 100644 index 0000000..b45561a --- /dev/null +++ b/docs/Picture.html @@ -0,0 +1,842 @@ + + + + + JSDoc: Class: Picture + + + + + + + + + + +
+ +

Class: Picture

+ + + + + + +
+ +
+ +

Picture()

+ + +
+ +
+
+ + + + + + +

new Picture()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

(readonly) loaded :boolean

+ + + + + + +
Type:
+
    +
  • + +boolean + + +
  • +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

position :Object

+ + + + + + +
Type:
+ + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
position.x + + +Number + + + +
position.y + + +Number + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

size :Object

+ + + + + + +
Type:
+ + + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
size.width + + +Number + + + +
size.height + + +Number + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

fromImage(image)

+ + + + + + +
+ Creates Picture from Image object. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
image + + +Image + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +

load(path, width, height)

+ + + + + + +
+ Load image from path +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
path + + +String + + + +
width + + +Number + + + +
height + + +Number + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time) +
+ + + + + \ No newline at end of file diff --git a/docs/Polygon.html b/docs/Polygon.html index 3e182f8..b68212a 100644 --- a/docs/Polygon.html +++ b/docs/Polygon.html @@ -186,7 +186,7 @@

Members

-

(readonly) normals

+

normals

@@ -230,7 +230,7 @@

(readonly) nor
Source:
@@ -248,7 +248,7 @@

(readonly) nor -

(readonly) parentRotation :Array.<{x: Number, y: Number, z: Number}>

+

parentRotation

@@ -259,16 +259,6 @@

(readonly) Type:

-
    -
  • - -Array.<{x: Number, y: Number, z: Number}> - - -
  • -
- @@ -302,7 +292,7 @@
Type:
Source:
@@ -320,7 +310,7 @@
Type:
-

(readonly) position :Array.<{x: Number, y: Number, z: Number}>

+

position

@@ -331,15 +321,67 @@

(readonly) po -

Type:
-
    -
  • + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + -Array.<{x: Number, y: Number, z: Number}> +

    rotation

    + + + + +
    + Polygon rotation. +
    -
  • -
@@ -374,7 +416,7 @@
Type:
Source:
@@ -392,26 +434,78 @@
Type:
-

(readonly) rotation :Array.<{x: Number, y: Number, z: Number}>

+

rotationPoint

- Polygon rotation. + Polygon rotation point.
-
Type:
-
    -
  • + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + -Array.<{x: Number, y: Number, z: Number}> +

    (readonly) scaling

    + + + + +
    + Polygon scaling. +
    -
  • -
@@ -446,7 +540,7 @@
Type:
Source:
@@ -464,13 +558,13 @@
Type:
-

(readonly) rotationPoint :Array.<{x: Number, y: Number, z: Number}>

+

(readonly) texture :Texture

- Polygon rotation point. + Texture of polygon
@@ -479,7 +573,7 @@
Type:

+ + + + + + + + + + + + + + + + + + + + + + + + +

scale(x, y, z)

+ + + + + + +
+ Scaling polygon for x,y,z percent. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +Number + + + +
y + + +Number + + + +
z + + +Number + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
@@ -972,7 +1247,7 @@
Parameters:
Source:
@@ -1153,7 +1428,7 @@
Parameters:
Source:
@@ -1334,7 +1609,7 @@
Parameters:
Source:
@@ -1515,7 +1790,7 @@
Parameters:
Source:
@@ -1696,7 +1971,7 @@
Parameters:
Source:
@@ -1831,7 +2106,7 @@
Parameters:
Source:
@@ -1966,7 +2241,7 @@
Parameters:
Source:
@@ -2096,7 +2371,7 @@
Parameters:
Source:
@@ -2182,7 +2457,7 @@

updateSource:
@@ -2226,13 +2501,13 @@

update
- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Rect.html b/docs/Rect.html index 3616856..a724b28 100644 --- a/docs/Rect.html +++ b/docs/Rect.html @@ -190,7 +190,7 @@

Members

-

(readonly) position :Array.<{x: Number, y: Number, z: Number}>

+

(readonly) position

@@ -201,16 +201,6 @@

(readonly) po -

Type:
-
    -
  • - -Array.<{x: Number, y: Number, z: Number}> - - -
  • -
- @@ -262,7 +252,7 @@
Type:
-

(readonly) rotationPoint :Array.<{x: Number, y: Number, z: Number}>

+

(readonly) rotationPoint

@@ -273,16 +263,6 @@

(readonly) Type:

-
    -
  • - -Array.<{x: Number, y: Number, z: Number}> - - -
  • -
- @@ -394,7 +374,7 @@
Parameters:
-* +Number @@ -417,7 +397,7 @@
Parameters:
-* +Number @@ -440,7 +420,7 @@
Parameters:
-* +Number @@ -483,6 +463,187 @@
Parameters:
+ + + + + + +
Source:
+
+ + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + +

scale(x, y, z)

+ + + + + + +
+ Change scaling of all polygons in rect. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
x + + +Number + + + +
y + + +Number + + + +
z + + +Number + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -521,6 +682,141 @@
Parameters:
+ + + + +

setAsUIElement(bool)

+ + + + + + +
+ Sets whether the all polygons will be attached to the camera like UI element. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bool + + +bolean + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -626,7 +922,7 @@
Parameters:
Source:
@@ -807,7 +1103,7 @@
Parameters:
Source:
@@ -1169,7 +1465,7 @@
Parameters:
Source:
@@ -1506,13 +1802,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Texture.html b/docs/Texture.html index 7455cb9..85d90d2 100644 --- a/docs/Texture.html +++ b/docs/Texture.html @@ -841,13 +841,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/Texture.js.html b/docs/Texture.js.html index 04f1841..91656fa 100644 --- a/docs/Texture.js.html +++ b/docs/Texture.js.html @@ -111,13 +111,13 @@

Source: Texture.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/UI.html b/docs/UI.html new file mode 100644 index 0000000..5b9ca96 --- /dev/null +++ b/docs/UI.html @@ -0,0 +1,770 @@ + + + + + JSDoc: Class: UI + + + + + + + + + + +
+ +

Class: UI

+ + + + + + +
+ +
+ +

UI(e)

+ + +
+ +
+
+ + + + + + +

new UI(e)

+ + + + + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
e + + +Engine + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

context :CanvasRenderingContext2D

+ + + + +
+ 2D context for UI drawing. +
+ + + +
Type:
+
    +
  • + +CanvasRenderingContext2D + + +
  • +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

elements :Array.<Objects>

+ + + + +
+ There are objects which object needs to draw. +
+ + + +
Type:
+
    +
  • + +Array.<Objects> + + +
  • +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

addElement(element)

+ + + + + + +
+ Adds object to draw. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
element + + +Object + + + + some UI element.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +

appendDOMElement(element)

+ + + + + + +
+ Adding DOM element upper game engine canvas. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
element + + +HTMLElement + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +

removeElement(element)

+ + + + + + +
+ Removes element from drawing function. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
element + + +Object + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time) +
+ + + + + \ No newline at end of file diff --git a/docs/Utils.js.html b/docs/Utils.js.html index 1ee632f..b092d96 100644 --- a/docs/Utils.js.html +++ b/docs/Utils.js.html @@ -130,13 +130,13 @@

Source: Utils.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/global.html b/docs/global.html index 99fa69d..5a6f503 100644 --- a/docs/global.html +++ b/docs/global.html @@ -859,13 +859,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/index.html b/docs/index.html index 5142716..1969124 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,13 +50,13 @@


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/math_Math.js.html b/docs/math_Math.js.html index 7389593..7ee6bc1 100644 --- a/docs/math_Math.js.html +++ b/docs/math_Math.js.html @@ -62,13 +62,13 @@

Source: math/Math.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/math_Matrixes.js.html b/docs/math_Matrixes.js.html index a6d8b63..7ac0d7d 100644 --- a/docs/math_Matrixes.js.html +++ b/docs/math_Matrixes.js.html @@ -66,6 +66,29 @@

Source: math/Matrixes.js

] return this } + + /** + * Sets this matrxi to projection matrix without perscpective. + * @param {Number} width + * @param {Number} height + * @public + */ + projection (fieldOfViewInRadians, width, height, near, far) { + + this.matrix = [ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 1, + 0, 0, 0, 1 + ] + this.matrix = ([ + 2 / width, 0, 0, 0, + 0, -2 / height, 0, 0, + 0, 0, 2 / far, 0, + 0, 0, 0, 1, + ]) + return this + } /** * Multiplying this matrix by another. @@ -417,11 +440,6 @@

Source: math/Matrixes.js

* @public */ export function vec3Multiply (matrix, vector4) { - // c11 = a11 · b11 + a12 · b21 + a13 · b31 + a14 · b41 - // c21 = a21 · b11 + a22 · b21 + a23 · b31 + a24 · b41 - // c31 = a31 · b11 + a32 · b21 + a33 · b31 + a34 · b41 - // c41 = a41 · b11 + a42 · b21 + a43 · b31 + a44 · b41 - // console.log(matrix[0] * vector4[0] ) let c1 = matrix[0] * vector4[0] + matrix[1] * vector4[1] + matrix[2] * vector4[2] + matrix[3] * vector4[3] let c2 = matrix[4] * vector4[0] + matrix[5] * vector4[1] + matrix[6] * vector4[2] + matrix[7] * vector4[3] let c3 = matrix[8] * vector4[0] + matrix[9] * vector4[1] + matrix[10] * vector4[2] + matrix[11] * vector4[3] @@ -541,13 +559,13 @@

Source: math/Matrixes.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/math_Vectors.js.html b/docs/math_Vectors.js.html index 38155cd..730bad8 100644 --- a/docs/math_Vectors.js.html +++ b/docs/math_Vectors.js.html @@ -55,13 +55,13 @@

Source: math/Vectors.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/module-Math.html b/docs/module-Math.html index 5b9fc93..7276244 100644 --- a/docs/module-Math.html +++ b/docs/module-Math.html @@ -523,13 +523,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/module-Matrixes.Matrix.html b/docs/module-Matrixes.Matrix.html index d65925e..9456c78 100644 --- a/docs/module-Matrixes.Matrix.html +++ b/docs/module-Matrixes.Matrix.html @@ -245,7 +245,7 @@
Parameters:
Source:
@@ -380,7 +380,7 @@
Parameters:
Source:
@@ -659,6 +659,164 @@
Parameters:
+ + + + +

projection(width, height)

+ + + + + + +
+ Sets this matrxi to projection matrix without perscpective. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
width + + +Number + + + +
height + + +Number + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + @@ -764,7 +922,7 @@
Parameters:
Source:
@@ -899,7 +1057,7 @@
Parameters:
Source:
@@ -1034,7 +1192,7 @@
Parameters:
Source:
@@ -1215,7 +1373,7 @@
Parameters:
Source:
@@ -1396,7 +1554,7 @@
Parameters:
Source:
@@ -1577,7 +1735,7 @@
Parameters:
Source:
@@ -1621,13 +1779,13 @@
Parameters:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/module-Matrixes.html b/docs/module-Matrixes.html index 7dc8563..9f82211 100644 --- a/docs/module-Matrixes.html +++ b/docs/module-Matrixes.html @@ -172,7 +172,7 @@
Parameters:
Source:
@@ -352,7 +352,7 @@
Parameters:
Source:
@@ -505,7 +505,7 @@
Parameters:
Source:
@@ -658,7 +658,7 @@
Parameters:
Source:
@@ -811,7 +811,7 @@
Parameters:
Source:
@@ -1010,7 +1010,7 @@
Parameters:
Source:
@@ -1209,7 +1209,7 @@
Parameters:
Source:
@@ -1313,7 +1313,7 @@

(static) unitSource:
@@ -1485,7 +1485,7 @@
Parameters:
Source:
@@ -1551,13 +1551,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/module-Vectors.html b/docs/module-Vectors.html index aa48bd6..c4464d8 100644 --- a/docs/module-Vectors.html +++ b/docs/module-Vectors.html @@ -210,13 +210,13 @@
Returns:

- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/objects_Cube.js.html b/docs/objects_Cube.js.html index 8fd5de2..5ffdb39 100644 --- a/docs/objects_Cube.js.html +++ b/docs/objects_Cube.js.html @@ -37,6 +37,9 @@

Source: objects/Cube.js

*/ export class Cube { constructor (engine) { + + this.engine = engine + /** * Faces of cube * @private @@ -65,6 +68,12 @@

Source: objects/Cube.js

*/ this.rotation = [0, 0, 0] + /** + * @type {boolean} + * @readonly + */ + this.UIElement = false + this.faces[0].rotate(0, 0, 0) this.faces[0].setRotationPoint(-100, -100, 100) this.faces[0].setPosition(0, 0, 0) @@ -171,13 +180,23 @@

Source: objects/Cube.js

* @public */ setPosition(x, y, z) { - this.position = [x, y, z] - this.faces[0].setPosition(x, y, z) - this.faces[1].setPosition(x, y, z) - this.faces[2].setPosition(x, y, z) - this.faces[3].setPosition(x, y, z) - this.faces[4].setPosition(x, y, z) - this.faces[5].setPosition(x, y, z) + if (!this.UIElement) { + this.position = [x, y, z] + this.faces[0].setPosition(x, y, z) + this.faces[1].setPosition(x, y, z) + this.faces[2].setPosition(x, y, z) + this.faces[3].setPosition(x, y, z) + this.faces[4].setPosition(x, y, z) + this.faces[5].setPosition(x, y, z) + } else { + this.faces[0].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.faces[1].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.faces[2].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.faces[3].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.faces[4].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.faces[5].setPosition(this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z) + this.position = [this.engine.width / 2 * x / 100, this.engine.height / 2 * y / 100, z] + } } /** @@ -199,6 +218,16 @@

Source: objects/Cube.js

}) } + /** + * Setting scaling for cube in percent + * @param {Number} x scaling in percent + * @param {Number} y scaling in percent + * @param {Number} z scaling in percent + */ + scale (x, y, z) { + this.setSize(this.width * x, this.height * y, this.depth * z) + } + /** * Set rotation for x, y, z axis. * @param {*} x in degrees. @@ -241,6 +270,21 @@

Source: objects/Cube.js

removeAnimation () { clearInterval(this._animationInterval) } + + /** + * Sets whether the all polygons will be attached to the camera like UI element. + * @deprecated + * @param {bolean} bool + */ + setAsUIElement (bool) { + this.UIElement = bool + this.faces[0].setAsUIElement(bool) + this.faces[1].setAsUIElement(bool) + this.faces[2].setAsUIElement(bool) + this.faces[3].setAsUIElement(bool) + this.faces[4].setAsUIElement(bool) + this.faces[5].setAsUIElement(bool) + } } @@ -252,13 +296,13 @@

Source: objects/Cube.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/objects_Object.js.html b/docs/objects_Object.js.html index bb1da23..f384d35 100644 --- a/docs/objects_Object.js.html +++ b/docs/objects_Object.js.html @@ -27,6 +27,7 @@

Source: objects/Object.js

import * as Matrixes from "../math/Matrixes"
+import * as Math from '../math/Math'
 
  /**
  * Creates and bind to engine object. The object must be loaded from .obj file.
@@ -174,9 +175,15 @@ 

Source: objects/Object.js

* @public */ setPosition (x, y, z) { - this.position[0] = x - this.position[1] = y - this.position[2] = z + if (!this.UIElement) { + this.position[0] = x + this.position[1] = y + this.position[2] = z + } else { + this.position[0] = this.engine.width / 2 * x / 100 + this.position[1] = this.engine.height / 2 * y / 100 + this.position[2] = z + } } /** @@ -228,9 +235,9 @@

Source: objects/Object.js

* @public */ setRotation (x, y, z) { - this.rotation[0] = x - this.rotation[1] = y - this.rotation[2] = z + this.rotation[0] = Math.degToRad(x) + this.rotation[1] = Math.degToRad(y) + this.rotation[2] = Math.degToRad(z) } /** @@ -442,13 +449,13 @@

Source: objects/Object.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/objects_Polygon.js.html b/docs/objects_Polygon.js.html index c2f3a87..cce6652 100644 --- a/docs/objects_Polygon.js.html +++ b/docs/objects_Polygon.js.html @@ -55,38 +55,45 @@

Source: objects/Polygon.js

/** * Polygon position. - * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @public + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.position = [0, 0, 0] /** * Polygon rotation. - * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @public + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.rotation = [0, 0, 0] /** - * Polygon rotation point. + * Polygon scaling. * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 + */ + this.scaling = [1, 1, 1] + + /** + * Polygon rotation point. + * @public + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.rotationPoint = [0, 0, 0] /** * Polygon parent rotation. - * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @public + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.parentRotation = [0, 0, 0] /** * Polygon normals. - * @readonly - * @type {Array.<{0: Number, 1: Number, 2: Number, + * @public + * @type {Array.{0: Number, 1: Number, 2: Number, * 3: Number, 4: Number, 5: Number, - * 6: Number, 7: Number, 8: Number,}>} matrix 9 + * 6: Number, 7: Number, 8: Number,}} matrix 9 */ this.normals = [ 0, 1, 0, @@ -99,6 +106,13 @@

Source: objects/Polygon.js

* @private */ this._vertexesBuffer = null + + /** + * Sets whether the object will be attached to the camera like UI element. + * @type {boolean} + * @public + */ + this.UIElement = false } /** @@ -148,6 +162,20 @@

Source: objects/Polygon.js

this.position[2] = z } + /** + * Scaling polygon for x,y,z percent. + * + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @public + */ + scale (x, y, z) { + this.scaling[0] = x + this.scaling[1] = y + this.scaling[2] = z + } + /** * Add rotation for x, y, z axis for current rotation. * @param {Number} x @@ -225,13 +253,13 @@

Source: objects/Polygon.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/objects_Rect.js.html b/docs/objects_Rect.js.html index 10cb258..7299433 100644 --- a/docs/objects_Rect.js.html +++ b/docs/objects_Rect.js.html @@ -44,21 +44,21 @@

Source: objects/Rect.js

/** * Rect polygons. * @private - * @type {Array.<{0: Polygon, 1: Polygon}>} vector 3 + * @type {Array.{0: Polygon, 1: Polygon}} vector 3 */ this.polygons = new Array(2) /** * Rect position. * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.position = [0, 0, 0] /** * Rect rotation point. * @readonly - * @type {Array.<{x: Number, y: Number, z: Number}>} vector 3 + * @type {Array.{0: Number, 1: Number, 2: Number}} vector 3 */ this.rotationPoint = [0, 0, 0] @@ -138,11 +138,23 @@

Source: objects/Rect.js

this.polygons[1].setPosition(x, y, z) } + /** + * Change scaling of all polygons in rect. + * @param {Number} x + * @param {Number} y + * @param {Number} z + * @public + */ + scale(x, y, z) { + this.polygons[0].scale(x, y, z) + this.polygons[1].scale(x, y, z) + } + /** * Set rotation for x, y, z axis. - * @param {*} x in deg. - * @param {*} y in deg. - * @param {*} z in deg. + * @param {Number} x in deg. + * @param {Number} y in deg. + * @param {Number} z in deg. * @public */ rotate(x, y, z) { @@ -186,6 +198,15 @@

Source: objects/Rect.js

this.polygons[0].setNormals(normals) this.polygons[1].setNormals(normals) } + + /** + * Sets whether the all polygons will be attached to the camera like UI element. + * @param {bolean} bool + */ + setAsUIElement (bool) { + this.polygons[0].UIElement = bool + this.polygons[1].UIElement = bool + } }
@@ -197,13 +218,13 @@

Source: objects/Rect.js


- Documentation generated by JSDoc 3.5.5 on Sun Mar 10 2019 14:24:57 GMT+0200 (Eastern European Standard Time) + Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time)
diff --git a/docs/ui_UI.js.html b/docs/ui_UI.js.html new file mode 100644 index 0000000..a78be4b --- /dev/null +++ b/docs/ui_UI.js.html @@ -0,0 +1,123 @@ + + + + + JSDoc: Source: ui/UI.js + + + + + + + + + + +
+ +

Source: ui/UI.js

+ + + + + + +
+
+
/**
+ * @class
+ * @constructor
+ * @param {Engine} e
+ */
+export class UI {
+    constructor (engine) {
+        this.canvas = document.createElement('canvas')
+        this.canvas.width = engine.div.width
+        this.canvas.height = engine.div.height
+        this.canvas.style = 'position: absolute; height: 100%; width: 100%; z-index: 999999; left: 0; right: 0; top: 0;'
+
+        this.div = document.createElement('div')
+        this.div.style = 'position: absolute; height: 100%; width: 100%; z-index: 999999; left: 0; right: 0; top: 0;'
+
+        engine.div.appendChild(this.canvas)
+        engine.div.appendChild(this.div)
+
+        /**
+         * 2D context for UI drawing. 
+         * @type {CanvasRenderingContext2D}
+         */
+        this.context = this.canvas.getContext('2d')
+
+        /**
+         * There are objects which object needs to draw.
+         * @type {Objects[]}
+         */
+        this.elements = []
+        
+        engine.ui = this
+    }
+
+    /**
+     * Adds object to draw.
+     * @param {Object} element some UI element. 
+     */
+    addElement (element) {
+        this.elements.push(element)
+    }
+
+    /**
+     * Removes element from drawing function.
+     * @param {Object} element 
+     */
+    removeElement (element) {
+        let index = this.elements.indexOf(element)
+        this.elements.removeAt(index)
+    }
+
+    /**
+     * Adding DOM element upper game engine canvas.
+     * @param {HTMLElement} element 
+     */
+    appendDOMElement (element, properties) {
+        let style = ''
+        for (let property in properties) {
+            style += property + ':  ' + properties[property] + ';'
+        }
+        element.style = style
+        this.div.appendChild(element)
+    }
+
+    /**
+     * This function draws all elements.
+     * @private
+     */
+    _draw () {
+        this.elements.forEach(element => {
+            element.draw()
+        })
+    }
+}
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time) +
+ + + + + diff --git a/docs/ui_elements_Picture.js.html b/docs/ui_elements_Picture.js.html new file mode 100644 index 0000000..9355092 --- /dev/null +++ b/docs/ui_elements_Picture.js.html @@ -0,0 +1,111 @@ + + + + + JSDoc: Source: ui/elements/Picture.js + + + + + + + + + + +
+ +

Source: ui/elements/Picture.js

+ + + + + + +
+
+
/**
+ * @class
+ * @constructor
+ */
+export class Picture extends Image {
+    constructor () {
+        super()
+        /**
+         * @type {boolean}
+         * @readonly
+         */
+        this.loaded = false
+
+        /**
+         * @type {Object} 
+         * @property {Number} position.x
+         * @property {Number} position.y
+         */
+        this.position = {
+            x: 0,
+            y: 0
+        }
+
+        /**
+         * @type {Object}
+         * @property {Number} size.width
+         * @property {Number} size.height
+         */
+        this.size = {
+            width: 0,
+            height: 0
+        }
+    }
+
+    /**
+     * Load image from path
+     * @param {String} path 
+     * @param {Number} width 
+     * @param {Number} height 
+     */
+    load (path, width, height) {
+        this.src = path
+        if (width != null && height != null) {
+            this.width = width
+            this.height = height
+        }
+        this.addEventListener('load', () => {
+            this.loaded = true
+        })
+    }
+
+    /**
+     * Creates Picture from Image object.
+     * @param {Image} image
+     */
+    fromImage (image) {
+        this.load(image.src, image.width, image.height)
+    }
+
+
+}
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Fri Mar 15 2019 21:55:16 GMT+0200 (Eastern European Standard Time) +
+ + + + +