Interface MetadataManagerInterface

The MetadataManagerInterface is the object that links interfaces of the 3djuump infinite API together.

A connection to an infinite build relies on 3/4 interfaces linked together :

The MetadataManagerInterface is the first interface to be created, through the CreateMetadataManager.

/** 
* Sample to illustrate the same page authentication mechanism.
*/
import {
InfiniteFactory, MetadataManagerFactory, InfiniteCacheFactory, DirectorySessionFactory,
InfiniteEngineInterface, MetadataManagerInterface, InfiniteCacheInterface, DirectorySessionInterface,
InfiniteEvent, ConnectionData,
DataSessionInterfaceSignal, DirectorySessionInterfaceSignal,
} from 'generated/documentation/appinfiniteapi';

// the current page (without url parameters) should be registered as authentication url in the directory
const sDirectoryUrl : string = 'https://my_directory:443/directory';

// Create a metadata manager interface
// the MetadataManagerInterface is the central point of your application
// It handles the creation of sets of geometries, search functions etc...
const lMetadataManager: MetadataManagerInterface = MetadataManagerFactory.CreateMetadataManager();
let lInfiniteEngine: InfiniteEngineInterface | undefined = undefined;
let lCache: InfiniteCacheInterface | undefined = undefined;
// bind the session to the MetadataManagerInterface
let lDirectorySession: DirectorySessionInterface | undefined = undefined;

// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
let authenticate : () => void = undefined;

// Checks if the url has an hash in order to authenticate
let checkHash : () => void = undefined;

// Success callback on login
let onLoginSuccess : (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// Success callback when DataSession is ready
let onDMULoaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// *****************************************************************************
// ******************************* Authentication ******************************
// *****************************************************************************
// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
authenticate = () : void =>
{
// if we have a hash, do not request a new authentication
if (window.location.hash.length > 0)
{
// perhaps some GUI code there
return;
}
// connect to directory with address sDirectoryAddress, in the folder "/directory" through https. The default port is unchanged (443)
// bind the session to the MetadataManagerInterface
lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);

// redirect url is the current url without query parameters
// the directory needs a full url (with query parameters if needed), so we recommend to
// register the url without parameters, use this url as authentication, store the url parameters if present
// and then redirect to the "final url" (see checkHash)
const sRedirectUrl : string = window.location.origin + window.location.pathname;
if (window.location.href.indexOf('?') >= 0)
{
// store the url with query parameters in session storage
// we will finally redirect to this url
window.sessionStorage.setItem('redirecturl', window.location.href.split('#')[0]);
}
const sURL = lDirectorySession.getSamePageAuthenticationUrl(sRedirectUrl);
if (typeof sURL === 'string')
{
// navigate to the given url for authentication
window.location.href = sURL;
}
else
{
console.log('Error not expected !!! ' + sURL);
window.sessionStorage.removeItem('redirecturl');
}
}

// Checks if the url has an hash in order to authenticate
checkHash = () : void =>
{
const lHash : string = window.location.hash;
if (lHash.length === 0)
{
// do not bother if no hash
return;
}
// we may here put some GUI code

// here we can check if the url has query parameters
const lSessionItem : string | null = window.sessionStorage.getItem('redirecturl');
if (lSessionItem)
{
// we have a redirect url
// remove it from storage in order to avoid infinite redirections
window.sessionStorage.removeItem('redirecturl');
// navigate to this url with hash
window.location.replace(lSessionItem + lHash);
}
else
{
// remove hash with some fancy methods
if (window.history.replaceState)
{
const uri : string = window.location.toString();
const cleanUri : string = uri.substring(0, uri.indexOf('#'));
window.history.replaceState({}, document.title, cleanUri);
}
else
{
window.location.hash = '';
}

// bind the session to the MetadataManagerInterface
lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);
// do something when we are connected !!!! => onLoginSuccess
lDirectorySession.addEventListener(DirectorySessionInterfaceSignal.LoginSuccess, onLoginSuccess);
// and end authentication
lDirectorySession.setTokenFromHash(lHash);
}
}

// Success callback on login
onLoginSuccess = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// Create a 3D engine to handle the rendering of the DMU. The engine is optional if you
// just want to search data in the DMU, but required to display 3D data.
// you need to provide a div inside your html file, or create one div programmatically
lInfiniteEngine = InfiniteFactory.CreateInfiniteEngine(lMetadataManager);
// bind the engine to the given div that will be used for rendering
lInfiniteEngine.setView(<HTMLElement>document.getElementById('rendering'));
// Create a cache to avoid requesting heavy data from the server if data has been retrieved already
lCache = InfiniteCacheFactory.CreateInfiniteCache();
// Get the Connection Data to get the build lists
const lConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;

// Get the list of projects => do something as you like
const lProjectList = lConnectionData.projects;
for (const lProjectId in lProjectList)
{
// iterate but get the first project
const lBuildList = lProjectList[lProjectId].builds;
for (const lBuild in lBuildList)
{
// iterate but get the first build
// create a datasession that uses the cache with the first item
const lDataSession = (<DirectorySessionInterface>(pEvent.emitter)).createDataSession(lBuild, lCache);
if (lDataSession)
{
// be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
// and go !!! => open the data session
lDataSession.openDataSession();
}
return;
}
}
};

// Success callback when DataSession is ready
onDMULoaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// do something !!!
// create filters
// change visibility
// etc ....
}

// we may launch an authentication procedure (or from a button)
authenticate();

// check hash if we should validate the authentication
checkHash();

At any moment, these 4 interfaces can be linked to at most one infinite build, but an infinite build can be closed and another open afterwards. If you need to connect to several infinite builds at once, you will need to create multiple sets of {MetadataManagerInterface / [DirectorySessionInterface](DirectorySessionInterface.html) / [DataSessionInterface](DataSessionInterface.html) / [InfiniteEngineInterface](InfiniteEngineInterface.html)}.

Performance information (PerformanceInterface) are accessed through the MetadataManagerInterface.

The MetadataManagerInterface will be removed in the next version. The relevant api has already been moved to the DataSessionInterface.


Metadata

See

Hierarchy

Methods

  • Adds a callback triggered each time the internal clock ticks.

    The internal clock is set at a fixed pace, and the callback is called at the end of the tick.

    The callback may be called only if the tick triggered a modification in the rendering (in case an InfiniteEngineInterface is linked to this instance).

    Returns a string id to use in removeCallback.

    Returns

    The id of the callback to be used in removeCallback.

    Deprecated

    Please use DisplayDone and Tick events instead.

    Parameters

    • pCallback: Function
      in
      The callback to call at the end of a clock tick.
    • pFrameHasNotChanged: boolean
      in
      If `true`, the callback will be called only if the tick induced a modification in the rendering.

    Returns string

  • Gets the conversion ratio between two units.

    Returns

    A floating number corresponding to the Unit conversion ratio.

    Deprecated

    Please use convertUnitFactor instead.

    Parameters

    • pFrom: Unit
      in
      The reference [Unit](../enums/Unit.html) where the conversion starts from.
    • pTo: Unit
      in
      The [Unit](../enums/Unit.html) to convert to.

    Returns number

  • Gets the list of available annotation types.

    Please see Annotations for more explanations about annotations.

    Modifying this array in place results in undefined behavior.

    DO NOT modify this array.

    Returns

    const
    The list of annotation types.

    Deprecated

    Please use getAnnotationTypes instead.

    Returns string[]

  • Gets the Axis Aligned Bounding Box of the currently loaded DMU.

    Returns false if no DMU is loaded (DMULoadingSuccess).

    Returns

    true if a DMU is loaded and pDmuAABBOut is updated.

    Deprecated

    Please use getDmuAABB instead.

    Parameters

    • pDmuAABBOut: AABB
      out
      AABB of the DMU.

    Returns boolean

  • Gets the axis aligned bounding box of the given geometric instance id.

    Call this function after the DMU has been loaded (DMULoadingSuccess) with a previously created AABB.

    Returns true if the given geometric instance id is valid.

    Returns

    true if pAABBOut is updated.

    Deprecated

    Please use getGeometricAABB instead.

    Parameters

    • pGeometricInstanceId: number
      in
      The geometric instance id to query.
    • pAABBOut: AABB
      out
      The resulting AABB of the geometric instance.

    Returns boolean

  • Gets the diagonal squared length of the Oriented Bounding Box (OBB) of the given geometric instance id.

    Returns -1 if pGeometricInstanceId is an invalid geometric instance id, or the diagonal squared length of the OBB if it is valid.

    Returns

    The diagonal squared length of the OBB of the geometric instance or -1 if invalid.

    Deprecated

    Please use getGeometricOBBDiagonalSquaredLength instead.

    Parameters

    • pGeometricInstanceId: number
      in
      The geometric instance id to query.

    Returns number

  • Gets the maximum diagonal squared length of all the Oriented Bounding Box (OBB) of all the geometric instances.

    Returns the maximum diagonal squared length of the current DMU, or -1 if a DMU has not been loaded (DMULoadingSuccess).

    Returns

    The maximum diagonal squared length of the current DMU, or -1 if no DMU is loaded.

    Deprecated

    Please use getGeometricOBBDiagonalSquaredMax instead.

    Returns number

  • Gets the minimum diagonal squared length of all the Oriented Bounding Box (OBB) of all the geometric instances.

    Returns the minimum diagonal squared length of the current DMU, or -1 if a DMU has not been loaded ().

    Returns

    The minimum diagonal squared length of the current DMU, or -1 if no DMU is loaded.

    Deprecated

    Please use getGeometricOBBDiagonalSquaredMin instead.

    Returns number

  • Gets the maximum geometric instance id of the DMU.

    Valid geometric instance ids range from 1 to getMaximumGeometricId() included. Please refer to Main ID Types for more information.

    Returns the maximum geometric instance id if a DMU is loaded (DMULoadingSuccess, 0 else.

    Returns

    The maximum geometric instance id, 0 if no DMU is loaded.

    Deprecated

    Please use getMaximumGeometricId instead.

    Returns number

  • Gets the maximum part instance id of the DMU.

    Valid part instance ids range from 1 to getMaximumPartInstanceId() included. Please refer to Main ID Types for more information.

    Returns the maximum part instance id if a DMU is loaded (DMULoadingSuccess, 0 else.

    Returns

    The maximum part instance id, 0 if no DMU is loaded.

    Deprecated

    Please use getMaximumPartInstanceId instead.

    Returns number

  • Gets a project document by its id.

    Available project documents are :

    • com.3djuump:scripts (idcard customization script) (deprecated).
    • com.3djuump:defaultsettings (field of view, orientation, etc).
    • com.3djuump:indexinfo (elasticsearch index information) : this information is accessible through the AttributesDictionaryInterface.

    Please refer to the integration manual to have more information about these documents.

    It is very unlikely any developer will use these versioned documents.

    Example (illustration purpose only):

    const lDocs = [
    {
    "id": "com.3djuump:defaultsettings",
    "profiles": [],
    "settings": {
    "backfaceculling": false,
    "dynamiclowdefprofiles": {
    "high": 2097152,
    "standard": 1048576
    },
    "fieldofview": {
    "degree": 25,
    "orientation": "vertical"
    },
    "frameorientation": {
    "dir": [
    -1,
    0,
    0
    ],
    "up": [
    0,
    0,
    1
    ]
    }
    },
    "subtype": "defaultsettings",
    "tasksettings": {
    "PresentationTask": {
    "aspectratio": [
    16,
    9
    ]
    }
    },
    "ts": 1591950944,
    "type": "projectdocument",
    "version": "8.0"
    },
    {
    "id": "com.3djuump:indexinfo",
    "internal": {
    "effectivity": {
    "SB": {
    "nested": [
    "effectivity"
    ],
    "type": "keyword",
    "values": [
    "SB1",
    "not_SB1"
    ]
    },
    "engine": {
    "nested": [
    "effectivity"
    ],
    "type": "keyword",
    "values": [
    "A",
    "B"
    ]
    }
    },
    "metadata": {
    "system": {
    "type": "text",
    "values": [
    "Structure",
    "Interior",
    "Exterior",
    "windows",
    "Wheel base"
    ]
    },
    "test.nested.text": {
    "nested": [
    "metadata",
    "test",
    "nested"
    ],
    "type": "text",
    "values": [
    "A",
    "B",
    "C"
    ]
    },
    "test.bool": {
    "type": "boolean"
    },
    "test.date": {
    "max": 1528114033000,
    "min": 1528114033000,
    "type": "date"
    },
    "test.date_range": {
    "type": "date_range"
    },
    "test.double_range": {
    "type": "double_range"
    },
    "test.int": {
    "max": 1,
    "min": 1,
    "type": "double"
    }
    }
    },
    "seq": 814,
    "subtype": "indexinfo",
    "type": "indexdocument",
    "version": 1
    },
    {
    "id": "com.3djuump:scripts",
    "scriptbase64": "base64 string",
    "subtype": "scripts",
    "taskscripts": {
    "AnnotationTask": "base64 string"
    },
    "ts": 1598877573,
    "type": "projectdocument",
    "version": "8.0"
    }
    ];

    These documents are json documents.

    Returns the json document as a string if the given document is available in the 3djuump infinite project.

    It is very unlikely any developer will use getProjectDocument("com.3djuump:scripts") as this script should be used for the 3djuump infinite native client.

    Returns

    The document as a string, or undefined if the document could not be found or the DMU is not loaded.

    Deprecated

    Please use getProjectDocument instead.

    Parameters

    • pDocumentId: string
      in
      The project document id to fetch.

    Returns undefined | string

  • Computes the axis aligned bounding box of the given geometric instances.

    This consists in the union of all the AABB of the geometric instances expressed by their geometric instance ids.

    Call this function once the DMU has been loaded (DMULoadingSuccess) with a previously created AABB.

    Returns true if at least one geometric instance id inside pGeometricInstanceIds is valid. Invalid geometric instance ids are silently discarded.

    Returns

    true if at least one geometric instance id inside pGeometricInstanceIds is valid and pAABBOut is therefore updated.

    Deprecated

    Please use getUnitedAABB instead.

    Parameters

    • pGeometricInstanceIds: number[] | Uint32Array
      in
      the list of geometric instance ids to query.
    • pAABBOut: AABB
      out
      the union of all the [AABB](../classes/AABB.html) o the geometric instance.

    Returns boolean

  • Gets the version of the infinite API.

    Returns

    The version of the infinite API.

    Deprecated

    Please use getVersion.

    Returns string

  • Indicates if a callback exists in the list of callbacks triggered each time the internal clock ticks.

    Returns

    true if the callback exists in the list of callbacks.

    Deprecated

    Please use hasEventListener and hasEventListener instead.

    Parameters

    • pCallbackId: string
      in
      the id obtained from [addCallback](MetadataManagerInterface.html#addCallback).

    Returns boolean

  • Tells if power saving mode is enabled.

    Power saving mode is used to save CPU usage when the browser tab is hidden by introducing some frame throttling.

    Returns

    true if the power saving mode is enabled.

    Deprecated

    Please use isPowerSavingEnabled instead.

    Returns boolean

  • Removes a callback that was triggered each time the internal clock ticked.

    The id obtained from addCallback should be used.

    Returns

    true if the callback was registered and has been removed.

    Deprecated

    Please use removeEventListener and removeEventListener instead.

    Parameters

    • pCallbackId: string
      in
      The id obtained from [addCallback](MetadataManagerInterface.html#addCallback).

    Returns boolean

  • Enables/Disables power saving mode.

    Power saving mode is used to save CPU usage when the browser tab is hidden by introducing some frame throttling. The FilterSolverInterface calculations will be slower if the tab is hidden.

    Power saving is disabled (false) by default.

    Deprecated

    Please use setPowerSavingEnabled instead.

    Parameters

    • pIsPowerSavingEnabled: boolean
      in
      Tells if the power saving mode should be enabled.

    Returns void