Documentation for JS plugins for BDEngine

This section is currently being written and will be updated frequently.

Important: only the API from window.editorAPI is considered stable and officially supported.

The window.editor object is available for exploration and experimentation, but its structure may change without notice and compatibility between versions is not guaranteed.

Access to the Editor

Desc
window.editor (Internal Unstable Object)

The entire editor instance is available globally as window.editor.

This object is useful for research, debugging and advanced experiments, but it is not considered a stable public API. Internal property names and structures may change between versions without notice.

Use window.editorAPI whenever it can solve your task.

window.editorAPI (Official Plugin API)

window.editorAPI is the official stable entry point for plugins.

The current public methods are:

  • createWindow(...)
  • createModalWindow(...)
  • mergeContent(...)
  • add(...)
  • addObject(...)
  • addButtonDockMenu(...)
  • addButtonTool(...)
  • delete(...)
  • deleteSelected()
  • removeObject(...)
  • find(...)
  • getSelectedObjects()
  • getMeshes()
  • update(...)
  • registerTranslations(...)
Other Global Objects

In addition to window.editor and window.editorAPI, plugins can also use several global objects prepared by the editor:

  • window.THREE - the Three.js namespace used by the editor.
  • window.THREE.GLTFExporter - GLTF exporter attached to THREE.
  • window.Selectable - the base class for selectable editor objects.
  • window.gT(key, fallback) - translation helper for interface strings.

Example:

(() => {
    class ExampleSelectable extends Selectable {
        constructor(editor) {
            super(editor);

            const geometry = new THREE.BoxGeometry(1, 1, 1);
            const material = new THREE.MeshBasicMaterial({color: 0xff9900});
            const mesh = new THREE.Mesh(geometry, material);

            this.add(mesh);
            this.name = 'ExampleSelectable';
        }
    }
})();
Selectable Basics

Selectable is the base class for editor objects that can be selected and transformed.

Useful methods and properties:

  • setPosition({x, y, z}) / getPosition()
  • setRotation({x, y, z}) / getRotation()
  • setQuaternionRotation(quaternion)
  • setScale({x, y, z}) / getScale()
  • selected

Notes:

  • setRotation(...) works in degrees.
  • For built-in editor object types, use editorAPI.add(...).
  • For custom plugin objects based on Selectable, use editorAPI.addObject(...).
Sign up to create and share content. Sign up
Dashboard
Chats
Sign In
Browse