MCPcopy Create free account
hub / github.com/cogentcore/core / TrackLight

Method TrackLight

xyz/node.go:289–303  ·  view source on GitHub ↗

TrackLight moves node to position of light of given name. For SpotLight, copies entire Pose. Does not work for Ambient light which has no position information.

(lightName string)

Source from the content-addressed store, hash-verified

287// For SpotLight, copies entire Pose. Does not work for Ambient light
288// which has no position information.
289func (nb *NodeBase) TrackLight(lightName string) error {
290 lt, ok := nb.Scene.Lights.ValueByKeyTry(lightName)
291 if !ok {
292 return fmt.Errorf("xyz Node: %v TrackLight named: %v not found", nb.Path(), lightName)
293 }
294 switch l := lt.(type) {
295 case *DirLight:
296 nb.Pose.Pos = l.Pos
297 case *PointLight:
298 nb.Pose.Pos = l.Pos
299 case *SpotLight:
300 nb.Pose.CopyFrom(&l.Pose)
301 }
302 return nil
303}

Callers

nothing calls this directly

Calls 4

PathMethod · 0.95
ValueByKeyTryMethod · 0.80
ErrorfMethod · 0.65
CopyFromMethod · 0.65

Tested by

no test coverage detected