Accessing color of light from gltf model

First, sorry for my English.

My problem is:
I’ve made a model with Spotlight in blender, exported in gltf, and attached my_model.find(“/lightsource”) to render, so light visible in scene.

upd: by “attached” i mean render.setLight(my_model.find(“/lightsource”))

Now i want to make a function that will “flick” this light. I’m thinking about func with sequence that will make the light.color(0,0,0,0) and back to initial color,
but my_model.find(“/lightsource”).getColor() tells me that this nodepath have no setted color, although i see the actual color and attenuation with print(my_model.find(“/lightsource”).ls())

So, how i can get light.color and light.attenuation from this NodePath
It’s easier to leave a spot’s for lightsource’s in blender and create>attach the light’s to a model by:



Greetings, and welcome to the forum! I hope that you find your time here to be positive! :slight_smile:

To answer your question:

If I’m not much mistaken, the properties of lights are stored not in their NodePaths, but in their internal nodes.

(These nodes inherit not only from the standard “PandaNode” base-class, but rather from “LightLensNode”, which in turn inherits from the “Camera” class–itself a sub-class of PandaNode–and from the “Light” class. The “AmbientLight” class being a partial exception to this.)

From this node you should be able to call methods like “getAttentuation” and “getColor” to get the light-specific attributes of your light.

Something like this:

myLightNode = myLightNodePath.node()
print ("Colour:", myLightNode.getColor())
print ("Attenuation:", myLightNode.getAttenuation())

Oh my… You just saved my brain, because i totally forgot about that. What a shame. Thank You! :face_with_head_bandage:

1 Like