Back to Player SDK

Working With Plugins

A Plugin allows you to upload JavaScript to our servers which can then be executed at a later point through our api. To create plugins you will need to request plugin access. Contact us at support@exocortex.com to get started. Once you are given access you can access the plugins page by selecting: User -> Plugins (https://clara.io/plugins).

Creating a plugin

Give your script a name, which will be used to reference it in the future. Within your Plugin Script you have access to the api variable which is the clara.io player. The following plugin example loads all models of type PolyMesh from the specified scene (modelScene) and clones them into the currently loaded scene (note: you will have loaded this scene beforehand). It then finds the chain material (from the current scene) and applies it to all models of type PolyMesh within the scene.

const modelScene = '70c1a958-49a8-4e44-8b14-48977c3a0156';
api.sceneIO.fetch(modelScene).then(() => {
    const models = api.scene.filter({from: { id: modelScene }, type: 'PolyMesh' });
    return api.scene.clone(models);
}).then(() => {
  const material = api.scene.find({name: 'Chain'})
    api.scene.setAll({type: 'PolyMesh', plug: 'Material', property: 'reference'}, material);
});

Loading a plugin

Please refer to the load plugin demo for loading this plugin via our api.