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 letlDataSession : DataSessionInterface; // the part instance ids to fetch letlPartInstanceIds: Array<number>;
// to retrieve the matrices constlPartInstanceMatrixGetter : PartInstanceMatrixGetterInterface = lDataSession.createPartInstanceMatrixGetter();
// what to do when matrix data has been downloaded ? letonMatricesReady : (_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 constlMatricesContent : 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 constlCurMatrixResult : PartInstanceMatrixResultInterface = lMatricesContent[0]; console.log('Matrices info : instance:', lCurMatrixResult.getInstanceId(), 'local matrix:', lCurMatrixResult.getLocalMatrix(), 'world matrix:', lCurMatrixResult.getWorldMatrix(), ')'); };
/** * 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 letlDataSession : DataSessionInterface; // the part instance ids to fetch letlPartInstanceIds: Array<number>;
// to retrieve the matrices constlPartInstanceMatrixGetter : PartInstanceMatrixGetterInterface = lDataSession.createPartInstanceMatrixGetter();
constfetchMatrices = async () : Promise<void> => { constlMatrixRes : AsyncPartInstanceMatrixResult = awaitlPartInstanceMatrixGetter.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 constlCurMatrixResult : 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.
The PartInstanceMatrixResultInterface interface is the result of a matrix retrieval query from an PartInstanceMatrixGetterInterface.
Or with async calls :
Please make sure the destination browser supports promises before using async calls.
See
PartInstanceMatrixGetterInterface