0

I'm desperate. been trying for so long to simply rotate an object on key press event. I can't just figure it, can anyone please show how to do it?

this is my model https://www.dropbox.com/s/8yefhx3yc11zbik/b.obj?dl=0

i need to keep rotating it on x axis, as long as keyboard button "B" is pressed down, so that that the shadow from the spotlight or direct light would be changing. anyone?

i need to do that with the whole alphabet (i've got all the models) what's the best way to do it?

  • It's hard to figure out what your problem is. You already have scene and you could render all objects? Did you know how to rotate all objects together? So is the problem the rotation or to know which object you have to rotate? – Benedikt Mar 22 '15 at 08:35
  • Hey, thanks for trying to help. I have the object loaded, but i don't know how to make it rotate with a key press, here's my jsfiddle, which is basically a mash-up of copied code: http://jsfiddle.net/cuq5uz32/ and once this would be done, the next step would be to assign different keyboard buttons to different models, and i don't know how to do that either – Jurgis Lietunovas Mar 22 '15 at 08:53

1 Answers1

0

You have different problems in your code.

1) You use the variable "letter" to rotate the object. This variable is only defined in the function onLoad. So you need to get a gloabal variable and asign the letter to it.

2) Try to rotate the hole scene first. "lesson6.scene.rotation.y += 1;" With that you could test how to use the button controls. In your code it will rotate only once per click. I think you need to use "setInterval" and "window.clearInterval" http://www.w3schools.com/js/js_timing.asp

Benedikt
  • 767
  • 6
  • 13