Skip to content
Advertisement

How to zoom a three.js scene with the mouse wheel?

I have a simple three.js graphics, and I tried to use the answers in this and this question to make the created plot zoomable by the mouse wheel. By using the mouse wheel I would like to zoom in to the graphics or to zoom out.

Here is the complete code: pastebin link

However, when turning the mouse wheel nothing happens, and I do not get an error message. Maybe I am missing something?

Advertisement

Answer

DEMO

JavaScript
JavaScript
JavaScript

In your code add event listener

document.addEventListener( 'mousewheel', onDocumentMouseWheel, false );

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement