Thank you. I have been studying the example at the link you provided, but I still don’t know where to begin to attach a listener to a hypothetical “OnCameraZoom” event (I made up that event name).
Can you provide a simple JavaScript example here of how I can do this, or point me to an example of a real camera event being set using createExtractCallback()
and sceneManager.addObserver()
?
I’m working in the mindset of the well-known convention Object.addEventListener(eventName, callbackFunction)
in JavaScript, where I simply provide the event name and the function.
I see this createExtractCallback
function declared in many VTK/WASM examples, but I’m not exactly sure where I would provide my own plain JavaScript event handler function to it like you can with the Object.addEventListener()
example mentioned above. Can you point me to the documentation for the createExtractCallback
function, and how it interacts with sceneManager.addObserver()
?
Its signature takes the following three arguments. I’m not sure what extractInfo
should be:
trame
: a Trame
object
wasmManager
: a VtkWASMHandler
object
extractInfo
: ??
function createExtractCallback(trame, wasmManager, extractInfo) {
return function () {
wasmManager.clearStateCache();
for (const [name, props] of Object.entries(extractInfo)) {
const value = {};
for (const [propName, statePath] of Object.entries(props)) {
value[propName] = wasmManager.getStateValue(statePath, true);
}
trame.state.set(name, value);
}
wasmManager.clearStateCache();
};
}