Skip to content

Latest commit

 

History

History
103 lines (74 loc) · 2.35 KB

README.md

File metadata and controls

103 lines (74 loc) · 2.35 KB

@soundworks/plugin-[name]

soundworks plugin template project.

Table of Contents

Installation

npm install @soundworks/plugin-[name] --save

Example

A working example can be found in the https://github.com/collective-soundworks/soundworks-examples repository.

Usage

Server installation

Registering the plugin

// index.js
import { Server } from '@soundworks/core/server';
import plugin[Name]Factory from '@soundworks/plugin-[name]/server';

const server = new Server();
server.pluginManager.register('[name]', plugin[Name]Factory, {
  // default to `.data/scripts`
  directory: 'scripts',
}, []);

Requiring the plugin

// MyExperience.js
import { AbstractExperience } from '@soundworks/core/server';

class MyExperience extends AbstractExperience {
  constructor(server, clientType) {
    super(server, clientType);
    // require plugin in the experience
    this.[name] = this.require('[name]');
  }
}

Client installation

Registering the plugin

// index.js
import { Client } from '@soundworks/core/client';
import plugin[Name]Factory from '@soundworks/plugin-[name]/client';

const client = new Client();
client.pluginManager.register('[name]', plugin[Name]Factory, {}, []);

Requiring the plugin

// MyExperience.js
import { Experience } from '@soundworks/core/client';

class MyExperience extends Experience {
  constructor(client) {
    super(client);
    // require plugin in the experience
    this.[name] = this.require('[name]');
  }
}

Additional Documentation

Credits

The code has been initiated in the framework of the WAVE and CoSiMa research projects, funded by the French National Research Agency (ANR).

License

BSD-3-Clause