Pixelsmart
Pixelsmart

Reputation: 15

Three.js - renderer.setSize(width,height) - How is Offset Horizontal and Offset Vertical Specified

I am writing JavaScript with Three.js to use WebGL.

My code calls:

renderer.setSize( 100, 100 );

The window is much larger than that size.

The rendered scene is placed in the top left corner of the window.

I would like it centered.

How can I center the rendered scene?

Upvotes: 0

Views: 832

Answers (1)

Darshit Hedpara
Darshit Hedpara

Reputation: 670

Try this

renderer.setSize( window.innerWidth, window.innerHeight ); 

Happy Coding :)

Upvotes: 0

Related Questions