UNPKG

@wonderlandengine/editor-api

Version:

Wonderland Engine's Editor API for plugins - very experimental.

55 lines (54 loc) 1.71 kB
const tools = _wl_internalBinding('tools'); /** @hidden */ export function awaitJob(jobId) { return new Promise((resolve, reject) => { tools.awaitJob(jobId, (success) => { if (success) resolve(); else reject(); }); }); } export const newSubProject = tools.newSubProject.bind(tools); export const switchProject = tools.switchProject.bind(tools); /** * Package the current project * @param destDir Destination directory into which to package, default `'<project-root>/deploy'`. * @returns Promise with that is rejected on package failure. */ export function packageProject(destDir) { const job = tools.packageProject(destDir); return awaitJob(job); } /** * Load a file into current scene * * @param path Path to file to load * @returns Promise with that is rejected on load failure. */ export function loadFile(path) { const job = tools.loadFile(path); return awaitJob(job); } /** * Load a scene file into current scene * * @param path Path to file to load * @param options.parent Parent object to parent the scene to. `null`, `undefined` and `""` indicate * scene root. * @returns Promise with that is rejected on load failure. */ export function loadScene(path, options) { const job = tools.loadScene(path, options.parent); return awaitJob(job); } /** * Open a URL with the system default browser * * @param url URL to open */ export const openBrowser = tools.openBrowser.bind(tools); export const computeMeshBounds = tools.computeMeshBounds.bind(tools); export const saveProject = tools.saveProject.bind(tools); export const getComponentTypes = tools.getComponentTypes.bind(tools);