Jump to content

Setting a JS as a background image.


Geist

Recommended Posts

I feel like there is a super easy fix to this and I am just missing it. I am currently using this pen as the "background image" on my page. I'm unsure about to actually set it as the background image. Whether it is done via JS or css. Is there a simple value I am missing? Thanks (:

Link to comment
Share on other sites

The Javascript generates a <canvas> element. The best thing to do is to give the canvas a negative Z-index and use absolute positioning to stretch it to the full size of its container. I'm not exactly sure how much the THREE.js framework will get in your way, though. It might be trying to resize the canvas on its own.

Link to comment
Share on other sites

4 minutes ago, Ingolme said:

The Javascript generates a <canvas> element. The best thing to do is to give the canvas a negative Z-index and use absolute positioning to stretch it to the full size of its container. I'm not exactly sure how much the THREE.js framework will get in your way, though. It might be trying to resize the canvas on its own.

How would one put that canvas inside a div? The JS is made for background sizing so that doesn't negatively affect what I am trying to achieve. 

Link to comment
Share on other sites

Here it is:

document.body.appendChild( renderer.domElement );

This line of code puts the canvas as a direct child of the body. Just append it to a different element if you want it somewhere else.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...