Skip to content
bg2 engine

TypeScript API Overview

The TypeScript API provides a web-oriented runtime for the engine, designed to run in browser environments on top of WebGL. It enables the development of interactive 3D applications that integrate seamlessly with modern web technologies while maintaining a consistent architecture with the native engine.

The API follows an imperative, object-oriented programming model, where applications explicitly control scene creation, resource management, and rendering flow. Developers work directly with engine constructs such as scenes, nodes, components, and rendering contexts, allowing precise control over behavior and lifecycle.

This API is intended for:

  • Interactive web-based 3D applications
  • Product visualization and configurators
  • Educational and technical visualization tools
  • Integration within existing frontend applications

Although the engine can be integrated with UI frameworks such as React, this integration is limited to coordinating UI state with the rendering layer. The core engine usage remains imperative and independent from any declarative UI paradigm.

While the API can be consumed from plain JavaScript, TypeScript is the recommended and officially supported language. The TypeScript definitions are first-class and provide strong typing across the entire API surface, improving maintainability and developer experience.

Support for plain JavaScript exists for compatibility reasons, but it is considered transitional. Future versions of the engine will deprecate the JavaScript API in favor of a TypeScript-only approach, ensuring consistency with the engine’s design and long-term evolution.

The TypeScript API shares core design principles with the native engine:

  • Scene graph with hierarchical nodes and component-based behavior
  • Explicit control over rendering updates (automatic or event-driven)
  • Resource management aligned with web delivery constraints
  • Asset formats compatible with the native pipeline

This design allows assets and workflows to be shared between web and native environments without requiring structural changes, enabling consistent cross-platform development.