There is now way to get the EngineOptions from an engine

When constructing an Engine we can specify a number of options:

For some of the options like “stencil” there is an “is” method in the engine. We can call isStencilEnabled - Engine | Babylon.js Documentation

I was able to find a get method for this option and for a few of the others. But I could not find a method for all the options.

Here is our use case and there reason why we need it.

In our buildin3d platform we call new BABYLON.Engine in one place. Different extensions provide the options for the engine. The Screenshot extension provides the option preserveDrawingBuffer which is not needed otherwise if the Screenshot extension is not enabled.

This means that there is logic for calling new BABYLON.Engine(). We would like to test this logic. In order to test this logic a new engine is created in the production code and in the spec we would like to inspect the options that were used for creation of this engine.

There is

engine._creationOptions

which I assume is private.

Is there a way we could access _creationOptions in a public way? Is there a chance for such a way to be introduced to make it possible to spec the engine creations?

Yeah, it’s private/protected: Babylon.js/thinEngine.ts at master · BabylonJS/Babylon.js (github.com)

For your specific use case, there’s a way to do that without needing to look into the Babylon Engine. You could store the options object in a variable, pass that to the engine, and then in your spec check that same object. Would that be possible in your system?

I could. It introduces some inconsistency and there is a logic that could never be speces in this way - specifically that we’ve passed the right options to the engine.

I could use the _createOptions. It would be great if ther is a consistent API for all the create options. Some of them have public get methods, some of them don’t. Even a getCreatedOptions() would be greate.