Hi, I’ve made a few threejs prototypes before. But currently I’m handling my code in an .js file instead of straight into my html.
I included threejs in my code. But for some reason it still won’t let me use it’s functions.
What am I doing wrong?
//Make div for canvas
function AdDiv(divname)
{
//make a div that will be used for the canvas
var iDiv = document.createElement('div');
iDiv.id = 'placedCanvas';
iDiv.className = 'placedCanvas';
//document.getElementsByTagName('body')[0].appendChild(iDiv);
document.getElementById(divname).appendChild(iDiv);
console.log("canvas created");
}
//Include js files
function include(file)
{
var script = document.createElement('script');
script.src = file;
script.type = 'text/javascript';
script.defer = true;
document.getElementsByTagName('head').item(0).appendChild(script);
}
/* include any js files here */
include('https://pixelvaria.com/wp-content/themes/pixelvaria/js/three.js');
include('https://pixelvaria.com/wp-content/themes/pixelvaria/js/three.min.js');
include('https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js');
var scene = new THREE.Scene();