tparisi / Vizi

A Component-Based Framework for Visual Web Applications
MIT License
103 stars 30 forks source link

Vizi.SpotLight looks for "position" on object, not transform #7

Closed 190n closed 10 years ago

190n commented 10 years ago

When I try to use a Vizi.SpotLight and pass in the object parameter, it seems to be looking for the object's position on the object itself, not its transform property.

I'm using this code:

light.addComponent(new Vizi.SpotLight({object: cube}));

I get this error (in the Safari debugger): TypeError: 'undefined' is not an object (evaluating 'a.object.position.clone')

Shouldn't it look for position on the object's transform property?

tobscher commented 10 years ago

Hi @fogcityben,

Vizi.SpotLight seems to be a wrapper for THREE.SpotLight. From what I can see the object param is for the use case where you have already built a THREE.SpotLight: https://github.com/tparisi/Vizi/blob/master/engine/src/lights/spotLight.js#L14-L19

Something like the following:

var parent = new Vizi.Object();
var spotLight = new THREE.SpotLight( 0xffffff );
var light = new Vizi.SpotLight({ object: spotLight });

parent.addComponent(light);

In this case calling position on the object you pass in (or the object Vizi creates for you) is correct.

190n commented 10 years ago

Thanks a lot, @Tobscher! I'm closing the issue now.