Sorry for my awful French-English.
Hi dear admin,
In my entire life, that’s the first time I write on a forum… so sorry in advance : I might not be at the good place to ask my question. I’ll follow this topic and move it if it needs to be done.
I’ve been trying desperately to use the rendering addons with wordpress.
I’ve got no problem using three.js, GLTFLoader and OrbitControls, but when it comes to render, it’s seems to generate a world of problems.
My will is to use a bloom effect on a basic scene with a basic GLTF object (let’s say a ball). I try to adapt the UnrealBloomPass from the documentation. So I charge in the wordpress functions.php all the scripts I need, which are those ones (don’t pay attention to the “true” or “false” in_footer, that’s a problem I’l talk about later :
wp_enqueue_script( 'three', get_template_directory_uri() . '/js/three.js', array(), true ); wp_enqueue_script( 'OrbitControls', get_template_directory_uri() . '/js/OrbitControls.js', array(), false ); wp_enqueue_script( 'GLTFLoader', get_template_directory_uri() . '/js/GLTFLoader.js', array(), false ); wp_enqueue_script( 'EffectComposer', get_template_directory_uri() . '/js/EffectComposer.js', array(), true ); wp_enqueue_script( 'RenderPass', get_template_directory_uri() . '/js/RenderPass.js', array(), false ); wp_enqueue_script( 'UnrealBloomPass', get_template_directory_uri() . '/js/UnrealBloomPass.js', array(), true );
The fact is : when I do it in a basic HTML index, it works and I manage to render a scene. When I’m on the wordpress project (all JS files loaded in the same order), my js code seems not to reach three.js.
For example, if I write this in the JS containing my three scene : composer = new THREE.EffectComposer(renderer);
Even if EffectComposer is loaded, I get this message composer = Cannot read property ‘getSize’ of undefined.
Or this error : RenderPass is not a function (athough RenderPass is fully loaded.
Then comes my question :
Where to load my JS files in wordpress. It seems to have no importance when it’s about OrbitControls or GLTFLoader, but a lot of importance when it’s about the rendering .js files.
Do I put them all at the bottom of the body ?
My second question is about the “Uncaught TypeError: Cannot read property ‘getSize’ of undefined
at new THREE.EffectComposer (EffectComposer.js?ver=1:18)
at (index):196” error.
How to get rid of that ? Did I miss something so important that makes me noobest that I already am ?
If somebody has a working WP example that would allow me to learn a bit more…
Thanks a lot.
All my version are the last versions from the official three GitHub repository…
Last version of Worpress.
Very last version of myself, I think I will pass out if it does not work tomorow.