Hi! I am trying to use three.js using corvid on Wix. But I have not been able to get it to work. I installed the three.js npm package and then tried to test a code snippet from the documentation on my website.
Documentation: www.npmjs . com/package/three
And created a blank page to test out the code:
import * as THREE from './js/three.module.js';
$w.onReady(function () {
let camera, scene, renderer;
let geometry, material, mesh;
init();
function init() {
camera = new THREE.PerspectiveCamera( 70, 1, 0.01, 10 );
camera.position.z = 1;
scene = new THREE.Scene();
geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( 900, 900 );
renderer.setAnimationLoop( animation );
document.body.appendChild( renderer.domElement );
}
function animation( time ) {
mesh.rotation.x = time / 2000;
mesh.rotation.y = time / 1000;
renderer.render( scene, camera );
}
});
However, it does not work because it says it does not recognize document in document.body.appendChild(render.domElement).
I think this is because the code has to go into the body of the HTML website but I am not sure how to specify that with Corvid.
Any help is appreciated. Thank you!