Wingnut Posted December 24, 2014 Share Posted December 24, 2014 Yep, and remember the light.setDirectionToTarget(anyMesh.position)... for spotlights and directional lights. It's handy, for testing, initial setting, and in animation loops. See http://www.html5gamedevs.com/topic/11288-strange-shadows/#entry65523 posted moments ago. orientation = direction, in case anyone is curious (Gryff was speaking correctly). Generally, one does not rotate spot lights and directional lights. Instead, one sets their .direction. (At least that's how I understand it.) Have I plugged my function enough, yet? light.setDirectionToTarget() is the only code that I have ever contributed to BJS. I'm so proud. hehe Almost 4 lines of code! Quote Link to comment Share on other sites More sharing options...
altreality Posted December 24, 2014 Author Share Posted December 24, 2014 Ah yes right, forgot totally about the orientation. So I need to get the direction of my car and then point the spotlight in that direction. So say I want to align the spotlight to always point towards the x axis of a box mesh(lets say the x-axis is the forward direction), then how do I get its current transform in space and use that to set the light direction ? Strangely, the direction of the light is in fact changing here: http://playground.babylonjs.com/#2AKHZK#5 Quote Link to comment Share on other sites More sharing options...
altreality Posted December 24, 2014 Author Share Posted December 24, 2014 ok, everything is working perfectly now. I think setting the position of the light to 0,0,0 has attached it properly. I was probably making a mistake with the position of the spotlight. Quote Link to comment Share on other sites More sharing options...
altreality Posted December 24, 2014 Author Share Posted December 24, 2014 Here is the raycast vehicle from Cannon in Babylon. Maybe I can ask DeltaK to pull it in and upgrade cannon to the latest version http://synth2014.github.io/Age-of-Steam/babylon/RaycastTest.html Wingnut 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted December 24, 2014 Share Posted December 24, 2014 altreality: Glad you have things figured out Here is a demo I made a few months back - originally it used a point light - but I've changed it to use a spotlight. Both the camera and the spotlight are parented to an animated cube that follows a path. Consider this a racing car Animated Light Nadolig Llawen, gryff altreality 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 27, 2014 Share Posted December 27, 2014 Ok so I think everything is ok right? No need for fix? Quote Link to comment Share on other sites More sharing options...
altreality Posted December 28, 2014 Author Share Posted December 28, 2014 Yeah all good here. By the way have you considered upgrading to the latest cannon.js ? There are some changes to creation of compound bodies but thats all, as far as I know. Quote Link to comment Share on other sites More sharing options...
altreality Posted December 28, 2014 Author Share Posted December 28, 2014 Ummm...is there a change in the way a light is created, this playground sample was working a few days ago : http://playground.babylonjs.com/#2AKHZK#5 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 28, 2014 Share Posted December 28, 2014 Sorry I did a mistake:) Should be ok (please clear cache) Quote Link to comment Share on other sites More sharing options...
altreality Posted December 29, 2014 Author Share Posted December 29, 2014 All good again !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.