It consists in a center and a scale matrix that tells the way the explosion is computed.
The vector between the center of each geometry and the center of the explosion is computed, and this vector is transformed
by the scale matrix.
If one wants to explode a list of geometry in the X direction with factor scale, transform.set(scale, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);.
In order to compute an explosion in a non aligned frame R0, R1, R2, using scale * R0,
transform should be calculated the following way using 3 matrices rotationMatrix, inverseRotationMatrix, unitScaleMatrix:
transform now holds the explosion in the given specific direction.
/** * Sample to illustrate the use of a 3d export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, ExportJobInterfaceSignal, InfiniteError, InfiniteEvent, Export3DOutputFormat } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as 3d data letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined; // the file to download // In this test, we will only download one file letlFileOffset : number = -1;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = () : boolean=> { // will will try to export as fbx lExportJob = lDataSession.export3D( [{ workingSet:lWorkingSetToExport }], { type:'export3DOutputFormat', dataFormat:Export3DOutputFormat.EOF_FBX, // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobFinished, (pEvent : InfiniteEvent) : void=> { // only get the URL if no error constlError : InfiniteError | undefined = lExportJob.getLastError(); if(lError === undefined && (lFileOffset === -1)) { lFileOffset = pEvent.attachments; if(lExportJob.isExportSuccess(lFileOffset)) { // trigger the URL computing if(!lExportJob.computeDownloadURL(lFileOffset)) { console.log('Export job failed'); } } } }); // URL will be ready lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobURLReady, () : void=> { constlUrl : string | undefined = lExportJob.getDownloadURL(lFileOffset); // sanity check if(lUrl === undefined) { console.log('Export job failed'); return; } // trigger the download from the browser onDownloadReady(lUrl); }); returntrue; };
startExportProcedure();
/** * Sample to illustrate the use of a "complete" screenshot export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, ExportJobInterfaceSignal, InfiniteError, InfiniteEvent, InfiniteEngineInterface, Export2DOutputFormat, Vector2, Vector4 } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as a raster screenshot letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined; // the infinite engine in use, created previously letlInfiniteEngine: InfiniteEngineInterface;
// the file to download // In this test, we will only download one file letlFileOffset : number = -1;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = () : boolean=> { // we will try to export as png lExportJob = lDataSession.export2D( [{ workingSet:lWorkingSetToExport }], { type:'export2DOutputFormat', outputs: [ { // the name inside the screenshot procedure, as multiple viewpoint may // be set, in this case this is useless itemName:'screenshot', // the resolution of the image resolution:newVector2(1024, 768), // camera parameters viewpoint:lInfiniteEngine.getCameraManager().toJSON(), // the background color backgroundColor:newVector4(1, 1, 1, 1), // PNG to get a lossless compression dataFormat:Export2DOutputFormat.EOF_PNG } ], // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobFinished, (pEvent : InfiniteEvent) : void=> { // only get the URL if no error constlError : InfiniteError | undefined = lExportJob.getLastError(); if(lError === undefined && (lFileOffset === -1)) { lFileOffset = pEvent.attachments; if(lExportJob.isExportSuccess(lFileOffset)) { // trigger the URL computing if(!lExportJob.computeDownloadURL(lFileOffset)) { console.log('Export job failed'); } } } }); // URL will be ready lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobURLReady, () : void=> { constlUrl : string | undefined = lExportJob.getDownloadURL(lFileOffset); // sanity check if(lUrl === undefined) { console.log('Export job failed'); return; } // trigger the download from the browser onDownloadReady(lUrl); }); returntrue; };
startExportProcedure();
/** * Sample to illustrate the use of a SVG export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, ExportJobInterfaceSignal, InfiniteError, InfiniteEvent, InfiniteEngineInterface, Vector2, ExportSVGOutputFormat } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as a svg image letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined; // the infinite engine in use, created previously letlInfiniteEngine: InfiniteEngineInterface;
// the file to download // In this test, we will only download one file letlFileOffset : number = -1;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = () : boolean=> { // will will try to export as svg lExportJob = lDataSession.exportSVG( [{ workingSet:lWorkingSetToExport }], { type:'exportSVGOutputFormat', outputs: [ { // the name inside the screenshot procedure, as multiple viewpoint may // be set, in this case this is useless itemName:'svg_screenshot', // the page size in mm (A4 here) pageSize:newVector2(210, 287), // camera parameters viewpoint:lInfiniteEngine.getCameraManager().toJSON(), // SVG file format dataFormat:ExportSVGOutputFormat.EOF_SVG } ], // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobFinished, (pEvent : InfiniteEvent) : void=> { // only get the URL if no error constlError : InfiniteError | undefined = lExportJob.getLastError(); if(lError === undefined && (lFileOffset === -1)) { lFileOffset = pEvent.attachments; if(lExportJob.isExportSuccess(lFileOffset)) { // trigger the URL computing if(!lExportJob.computeDownloadURL(lFileOffset)) { console.log('Export job failed'); } } } }); // URL will be ready lExportJob.addEventListener(ExportJobInterfaceSignal.ExportJobURLReady, () : void=> { constlUrl : string | undefined = lExportJob.getDownloadURL(lFileOffset); // sanity check if(lUrl === undefined) { console.log('Export job failed'); return; } // trigger the download from the browser onDownloadReady(lUrl); }); returntrue; };
startExportProcedure();
or asynchronously :
/** * Sample to illustrate the asynchronous use of a 3d export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, AsyncResultReason, Export3DOutputFormat } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as 3d data letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = async () : Promise<boolean> => { // will will try to export as fbx lExportJob = lDataSession.export3D( [{ workingSet:lWorkingSetToExport }], { type:'export3DOutputFormat', dataFormat:Export3DOutputFormat.EOF_FBX, // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } // wait for file count to be known constlWaitForFileCount : AsyncResultReason = awaitlExportJob.asyncWaitForFileCount(); if(lWaitForFileCount !== AsyncResultReason.ARR_Success) { returnfalse; } constlNbFiles: number = lExportJob.getFileCount(); console.log('The export procedure consists in ' + lNbFiles + ' files'); if(lNbFiles < 1) { // not enough files ? // => should not happen returnfalse; } // wait for everything to be computed // we could have waited for a specific file with an asyncWaitForFinished(item) constlExportResult : AsyncResultReason = awaitlExportJob.asyncWaitForFinished(); if(lExportResult !== AsyncResultReason.ARR_Success) { returnfalse; } // file is ready // claim for a download url for file 0 console.log('retrieving file ' + lExportJob.getFilename(0)); awaitlExportJob.asyncGetDownloadURL(0); constlUrl : string | undefined = lExportJob.getDownloadURL(0); if(lUrl === undefined) { returnfalse; } // trigger a download of the file onDownloadReady(lUrl); returntrue; };
startExportProcedure();
/** * Sample to illustrate the asynchronous use of a "complete" screenshot export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, AsyncResultReason, Export2DOutputFormat, Vector2, Vector4, InfiniteEngineInterface } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as a raster screenshot letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined; // the infinite engine in use, created previously letlInfiniteEngine: InfiniteEngineInterface;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = async () : Promise<boolean> => { // we will try to export as png lExportJob = lDataSession.export2D( [{ workingSet:lWorkingSetToExport }], { type:'export2DOutputFormat', outputs: [ { // the name inside the screenshot procedure, as multiple viewpoint may // be set, in this case this is useless itemName:'screenshot', // the resolution of the image resolution:newVector2(1024, 768), // camera parameters viewpoint:lInfiniteEngine.getCameraManager().toJSON(), // the background color backgroundColor:newVector4(1, 1, 1, 1), // PNG to get a lossless compression dataFormat:Export2DOutputFormat.EOF_PNG } ], // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } // wait for file count to be known constlWaitForFileCount : AsyncResultReason = awaitlExportJob.asyncWaitForFileCount(); if(lWaitForFileCount !== AsyncResultReason.ARR_Success) { returnfalse; } constlNbFiles: number = lExportJob.getFileCount(); console.log('The export procedure consists in ' + lNbFiles + ' files'); if(lNbFiles < 1) { // not enough files ? // => should not happen returnfalse; } // wait for everything to be computed // we could have waited for a specific file with an asyncWaitForFinished(item) constlExportResult : AsyncResultReason = awaitlExportJob.asyncWaitForFinished(); if(lExportResult !== AsyncResultReason.ARR_Success) { returnfalse; } // file is ready // claim for a download url for file 0 console.log('retrieving file ' + lExportJob.getFilename(0)); awaitlExportJob.asyncGetDownloadURL(0); constlUrl : string | undefined = lExportJob.getDownloadURL(0); if(lUrl === undefined) { returnfalse; } // trigger a download of the file onDownloadReady(lUrl); returntrue; };
startExportProcedure();
/** * Sample to illustrate the asynchronous use of a SVG export procedure. */ import { DataSessionInterface, WorkingSetInterface, ExportJobInterface, AsyncResultReason, Vector2, InfiniteEngineInterface, ExportSVGOutputFormat } from'generated_files/documentation/appinfiniteapi';
// the DataSessionInterface has been created previously and is connected letlDataSession: DataSessionInterface; // the working set to export as a svg image letlWorkingSetToExport : WorkingSetInterface; // the export job to monitor letlExportJob : ExportJobInterface | undefined = undefined; // the infinite engine in use, created previously letlInfiniteEngine: InfiniteEngineInterface;
// triggers a save file from the browser constonDownloadReady = (pUrl : string) : void=> { constdownloadLink = document.createElement('a'); downloadLink.target = '_blank'; // set object URL as the anchors href downloadLink.href = pUrl; // append the anchor to document body document.body.appendChild(downloadLink); // fire a click event on the anchor downloadLink.click(); // cleanup: remove element and revoke object URL downloadLink.remove(); };
conststartExportProcedure = async () : Promise<boolean> => { // will will try to export as svg lExportJob = lDataSession.exportSVG( [{ workingSet:lWorkingSetToExport }], { type:'exportSVGOutputFormat', outputs: [ { // the name inside the screenshot procedure, as multiple viewpoint may // be set, in this case this is useless itemName:'svg_screenshot', // the page size in mm (A4 here) pageSize:newVector2(210, 287), // camera parameters viewpoint:lInfiniteEngine.getCameraManager().toJSON(), // SVG file format dataFormat:ExportSVGOutputFormat.EOF_SVG } ], // filename without extension filename:'test' } ); // sanity check if(lExportJob === undefined) { returnfalse; } // wait for file count to be known constlWaitForFileCount : AsyncResultReason = awaitlExportJob.asyncWaitForFileCount(); if(lWaitForFileCount !== AsyncResultReason.ARR_Success) { returnfalse; } constlNbFiles: number = lExportJob.getFileCount(); console.log('The export procedure consists in ' + lNbFiles + ' files'); if(lNbFiles < 1) { // not enough files ? // => should not happen returnfalse; } // wait for everything to be computed // we could have waited for a specific file with an asyncWaitForFinished(item) constlExportResult : AsyncResultReason = awaitlExportJob.asyncWaitForFinished(); if(lExportResult !== AsyncResultReason.ARR_Success) { returnfalse; } // file is ready // claim for a download url for file 0 console.log('retrieving file ' + lExportJob.getFilename(0)); awaitlExportJob.asyncGetDownloadURL(0); constlUrl : string | undefined = lExportJob.getDownloadURL(0); if(lUrl === undefined) { returnfalse; } // trigger a download of the file onDownloadReady(lUrl); returntrue; };
startExportProcedure();
Please make sure the destination browser supports promises before using async calls.
The WorkingSetExplodedViewInterface interface defines some of the data included in a export procedure called by DataSessionInterface.export2D, DataSessionInterface.export3D or DataSessionInterface.exportSVG.
It consists in a center and a scale matrix that tells the way the explosion is computed.
The vector between the center of each geometry and the center of the explosion is computed, and this vector is transformed by the scale matrix.
If one wants to explode a list of geometry in the X direction with factor
scale,transform.set(scale, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);.In order to compute an explosion in a non aligned frame R0, R1, R2, using scale * R0, transform should be calculated the following way using 3 matrices rotationMatrix, inverseRotationMatrix, unitScaleMatrix:
rotationMatrix.set(R1.x, R1.y, R1.z, 0, R2.x, R2.y, R2.z, 0, R3.x, R3.y, R3.z, 0, 0, 0, 0, 1);.inverseRotationMatrix.set(R1.x, R2.x, R3.x, 0, R1.y, R2.y, R3.y, R1.z, R2.z, 0, R3.z, 0, 0, 0, 0, 1);.unitScaleMatrix.set(scale, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);.rotationMatrix.multiplyMatrixRight(unitScaleMatrix, transform);.transform.multiplyMatrixRight(inverseRotationMatrix);.transformnow holds the explosion in the given specific direction.or asynchronously :
Please make sure the destination browser supports promises before using async calls.
See