问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/29189857/three-js-object-rotation-on-keypress