VitscnjLoaderPlugin
Loads .vitscnj scene files. Deserializes node trees with components and recursively loads embedded model resources (.bg2/.vwglb) via a Bg2LoaderPlugin dependency.
import VitscnjLoaderPlugin from 'bg2e-js/ts/db/VitscnjLoaderPlugin.ts';import Loader, { registerLoaderPlugin } from 'bg2e-js/ts/db/Loader.ts';
registerLoaderPlugin(new VitscnjLoaderPlugin({ bg2ioPath: "bg2io/" }));
const loader = new Loader();const root = await loader.loadNode("../resources/test-scene.vitscnj");Supported extensions: ["vitscnj"]
Supported resource types: Node
See also: index, loader-plugin
Constructor
Section titled “Constructor”constructor({ bg2ioPath, preferedDrawableFormat, materialImportCallback })| Parameter | Type | Default | Description |
|---|---|---|---|
bg2ioPath | string | null | "bg2io" | Path to the bg2io WASM files directory. |
preferedDrawableFormat | "vwglb" | "bg2" | "bg2" | Preferred drawable format for loading embedded resources like .vwglb or .bg2. Sets a global preference accessible via VitscnjLoaderPlugin.PreferredDrawableFormat(). |
materialImportCallback | (matData: any) => any | undefined | — | Same callback as in Bg2LoaderPlugin, applied to materials loaded from bg2/vwglb resources within the scene. |
NOTE: The
bg2ioPathshould point to the directory where thebg2io.jsandbg2io.wasmfiles are located in your final distribution. If you are using Vite, you can use thecopyBg2eAssetsplugin to copy these files to a specific directory in yourdistfolder, and then setbg2ioPathto that directory name (e.g.,"bg2io/"if you copy them todist/bg2io/). If you use the default value ofbg2ioPathin thecopyBg2eAssetsplugin, which isbg2io/, then you can omit thebg2ioPathparameter since it defaults to"bg2io/".
Static methods
Section titled “Static methods”VitscnjLoaderPlugin.PreferredDrawableFormat(): Returns the global preferred drawable format value ("bg2" or "vwglb").
Scene structure notes
Section titled “Scene structure notes”- The scene file contains an array of top-level node data objects
- Each node has a
name, optionalenabledandsteadyflags, nestedchildren, and serializablecomponents - The loader automatically sets its dependencies (
Bg2LoaderPlugin) which are registered before the scene plugin