Wt  4.11.1
Public Member Functions | List of all members
Wt::WGLWidget::JavaScriptMatrix4x4 Class Reference

A client-side JavaScript matrix. More...

#include <WGLWidget.h>

Public Member Functions

 JavaScriptMatrix4x4 ()
 Creates a temporarily invalid JavaScriptMatrix4x4. More...
 
bool initialized () const
 Returns whether this JavaScriptMatrix4x4 has been initialized.
 
bool hasContext () const
 Returns whether this JavaScriptMatrix4x4 has been assigned to a WGLWidget.
 
std::string jsRef () const
 Returns the JavaScript reference to this JavaScriptMatrix4x4. More...
 
WMatrix4x4 value () const
 Returns the current server-side value. More...
 

Detailed Description

A client-side JavaScript matrix.

A JavaScriptMatrix has methods that make it possible to do client-side calculations on matrices.

Using a JavaScriptMatrix4x4, GL parameters can be modified without communication with the server. The value of the JavaScriptMatrix4x4 is updated server-side whenever an event is sent to the server.

Important: only the jsRef() of the return value from a call to WGLWidget::createJavaScriptMatrix() is a variable name that can be used in custom JavaScript to modify a matrix from external scripts. The jsRef() of return values of operations refer to unnamed temporary objects - rvalues in C++-lingo.

The JavaScriptMatrix4x4 is represented in JavaScript as an array of 16 elements. This array represents the values of the matrix in column-major order. It is either a Float32Array or a plain JavaScript array.

Constructor & Destructor Documentation

◆ JavaScriptMatrix4x4()

Wt::WGLWidget::JavaScriptMatrix4x4::JavaScriptMatrix4x4 ( )

Creates a temporarily invalid JavaScriptMatrix4x4.

Should be added to a WGLWidget with WGLWidget::addJavaScriptMatrix4, and initialized with WGLWidget::initJavaScriptMatrix4.

Member Function Documentation

◆ jsRef()

std::string Wt::WGLWidget::JavaScriptMatrix4x4::jsRef ( ) const

Returns the JavaScript reference to this JavaScriptMatrix4x4.

In order to get a valid JavaScript reference, this matrix should have been added to a WGLWidget.

◆ value()

WMatrix4x4 Wt::WGLWidget::JavaScriptMatrix4x4::value ( ) const

Returns the current server-side value.

Client-side changes to the JavaScriptMatrix4x4 are automatically synchronized.