Add constants for frequently used types

Earlier you might have been using constructor.name === "SceneNode" instead of constructor === scenegraph.SceneNode. Sorry, I should have mentioned that as a workaround in my last post.

1 Like

Actually, just checked timeline, and I was using it successfully 8 months ago as

import { SceneNode } from 'scenegraph'

{shrug?}.

1 Like

I don’t know if you’re using the Typescript Definitions?

If so, there was an issue with SceneNode being declared as a class (as it got documented this way, I actually today see this as an issue with the docs back then) in the definitions until a few months ago (then, I changed it to now change it back with it actually getting exported :rofl:).

Therefore, no errors got shown when importing it. However, its value then has been undefined…

Not not using Typescript, though I’d love to. Just haven’t taken the plunge (since I’ll then have to figure out/find definitions for everything else I’m using).

At my next ā€œpause pointā€ I may try.

I’m using the latest.

I tested it and it seems to be working but the error might be because I’m using an older typescript definitions that @pklaschka mentioned he has updated but I have not updated. I have not updated because it was causing some other issues I don’t remember but the code is work now.

 const { SceneNode } = require("scenegraph");

 if (item instanceof SceneNode) { log("it is a scene node"); }

@peterflynn Should I use this instead:

if (node.constructor === scenegraph.SceneNode)