Interface PartInstanceMatrixResultInterface

The PartInstanceMatrixResultInterface interface is the result of a matrix retrieval query from an PartInstanceMatrixGetterInterface.

/** 
* Sample to illustrate the use of an PartInstanceMatrixGetterInterface to retrieve multiple matrices.
*/
import {
DataSessionInterface, PartInstanceMatrixGetterInterfaceSignal,
InfiniteEvent, PartInstanceMatrixResultInterface, PartInstanceMatrixGetterInterface
} from 'generated_files/documentation/appinfiniteapi';

// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the part instance ids to fetch
let lPartInstanceIds: Array<number>;

// to retrieve the matrices
const lPartInstanceMatrixGetter : PartInstanceMatrixGetterInterface = lDataSession.createPartInstanceMatrixGetter();

// what to do when matrix data has been downloaded ?
let onMatricesReady : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// what to do when the download of the matrices is ready ?
lPartInstanceMatrixGetter.addEventListener(PartInstanceMatrixGetterInterfaceSignal.MatrixFetchReady, onMatricesReady);

// what to do when matrix data has been downloaded ?
onMatricesReady = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// matrices are ready
const lMatricesContent : Array<PartInstanceMatrixResultInterface> | undefined = lPartInstanceMatrixGetter.getMatricesResult();
if ((!lMatricesContent) || (lMatricesContent.length === 0))
{
console.log('error while fetching matrices content');
return;
}
// now matrix content is there, just need to display them
// use only the first part instance
const lCurMatrixResult : PartInstanceMatrixResultInterface = lMatricesContent[0];
console.log('Matrices info : instance:', lCurMatrixResult.getInstanceId(), 'local matrix:', lCurMatrixResult.getLocalMatrix(), 'world matrix:', lCurMatrixResult.getWorldMatrix(), ')');
};

lPartInstanceMatrixGetter.fetchMatrices(lPartInstanceIds);

Or with async calls :
/** 
* Sample to illustrate the asynchronous use of an PartInstanceMatrixGetterInterface to retrieve multiple matrices.
*/
import {
DataSessionInterface, PartInstanceMatrixGetterInterface, AsyncResultReason, AsyncPartInstanceMatrixResult,
PartInstanceMatrixResultInterface
} from 'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected
let lDataSession : DataSessionInterface;
// the part instance ids to fetch
let lPartInstanceIds: Array<number>;

// to retrieve the matrices
const lPartInstanceMatrixGetter : PartInstanceMatrixGetterInterface = lDataSession.createPartInstanceMatrixGetter();

const fetchMatrices = async () : Promise<void> =>
{
const lMatrixRes : AsyncPartInstanceMatrixResult = await lPartInstanceMatrixGetter.asyncFetchMatrices(lPartInstanceIds);
if (!lMatrixRes.value || !lMatrixRes.value.length)
{
// display some fancy error message
return;
}
console.assert(lMatrixRes.reason === AsyncResultReason.ARR_Success);
// now matrix content is there, just need to display them
// use only the first view
const lCurMatrixResult : PartInstanceMatrixResultInterface = lMatrixRes.value[0];
console.log('Matrices info : instance:', lCurMatrixResult.getInstanceId(), 'local matrix:', lCurMatrixResult.getLocalMatrix(), 'world matrix:', lCurMatrixResult.getWorldMatrix(), ')');
};

fetchMatrices();

Please make sure the destination browser supports promises before using async calls.
Data Retrievers

interface PartInstanceMatrixResultInterface {
    getInstanceId(): number;
    getLocalMatrix(): Matrix4;
    getWorldMatrix(): Matrix4;
}

Methods

  • Gets the part instance id of the given part instance.

    Returns number

    The part instance id of the given part instance.

  • Gets the local matrix (i.e. relative to its parent) of the given part instance.

    DO NOT modify the resulting Matrix4 in place, this results in undefined behavior.

    Returns Matrix4

    const
    The local matrix of the given part instance.
  • Gets the world matrix of the given part instance.

    DO NOT modify the resulting Matrix4 in place, this results in undefined behavior.

    Returns Matrix4

    const
    The world matrix of the given part instance.