Skip to content

GltfBridge

David Komer edited this page May 26, 2018 · 8 revisions

GltfBridge is the transition point between the internal library and the outside world. See the interface itself for exact typing, what follows is the reason why and where comes into play

Init/Load

The typical pipeline is loadFile -> loadAssets -> start. These are separated to allow for use-cases where we might already have some gltf data in memory, and to keep the code separated by concern.

There is a convenience method to call all 3 via gltf_load() which is not part of GltfBridge, and rather returns a new GltfBridge after everything is loaded.

loadFile()

Loads a GLTF File, but not all the associated data in that file

loadAssets()

Loads all the associated data in the loaded GLTF (i.e. result of loadFile), but does not initialize it

start()

Initializes all the loaded assets/file and creates the internal GltfData etc.

Tick

renderScene

The main workhorse for output - this renders the given GltfScene, using the bridges internal GltfData etc.

updateShaderConfigs()

Will recursively step through each primitive and update its shader config by calling both the core method and each extensions runtimeShaderConfig method. This is usually super fast so it can be called every tick but it's not always needed, therefore it's up to the caller to either skip it or call it every tick.

Note that there is a helper gltf_updatePrimitiveShaderConfig() which can be used for updating a single primitive as a standalone

Data Retrieval

getOriginalScene()

This is usually called to kick off a render cycle. Retrieves a Pure3D scene based on the original loaded data

getOriginalCameras()

Same as above but just the cameras

getAllNodes()

Typically not called (rather get nodes via scene) but can be used externally to get the original loaded nodes without differentiating by node type etc.

getData()

Convenience method to inspect the GltfData from the outside caller.

renderer

Convenience to get the renderer that was used to create the bridge.