Namespace core

xeokit Core


Foundational primitives every other SDK module depends on — result types, error taxonomy, event dispatcher, task runner, and progress reporting.


core carries the small, stable types that the rest of the SDK exchanges across module boundaries. It has no dependencies on other SDK modules and is safe to import from anywhere.


  • SDKResult — discriminated union covering every fallible operation in the SDK. if (r.ok) { use r.value } vs r.error / r.type. Never throw for caller errors; always return an SDKResult.
  • SDKErrorType — small enum of error categories (InvalidInput, InvalidOperation, NotSupported, OutOfMemory, …) so callers can branch on machine-readable error kinds instead of string-matching messages.
  • SDKInternalException — thrown for internal SDK bugs (broken invariants, impossible states). Surfaces to the host as a regular Error with a typed SDKErrorType tag.
  • EventEmitter — typed wrapper around strongly-typed-events. Every event in the SDK is exposed as an EventEmitter<Source, Payload> with subscribe() returning an unsubscribe function.
  • SDKTask / SDKTaskRunner — cooperative task queue with progress reporting; used by the Demo task panel and by long-running converter pipelines.
  • SDKProgress{phase, current, total} snapshot passed to caller progress callbacks during loading / exporting / inspecting.
  • TextureTranscoder — abstract interface for transcoding compressed-texture payloads (Basis Universal, KTX2) to GPU-native formats; implementations provided by format-specific loaders.
  • EventsLogger — opt-in observer that mirrors every subscribed event to the console; useful for debugging event flow.

npm install @xeokit/sdk

import { SDKResult, SDKErrorType } from "@xeokit/sdk/base/core";

const r = doThing();
if (r.ok) {
useValue(r.value);
} else if (r.type === SDKErrorType.NotSupported) {
showFallback();
} else {
console.error(r.error);
}

const unsub = viewer.events.onError.subscribe((source, err) => {
console.warn(`[${source.id}] ${err.error}`);
});

// ...later:
unsub();

Enumerations

SDKErrorType

Classes

EventEmitter
EventsLogger
SDKInternalException
SDKProgress
SDKTask
SDKTaskRunner

Interfaces

ModelChunksManifestParams
TextureCompressedParams
TextureTranscoder

Type Aliases

SDKResult

Variables

sdkProgress
SDKResultOK

Functions

getGlobalTaskRunner