sf-b57 / main.js
Juno360219's picture
Add 3 files
d6d4c41
raw
history blame contribute delete
955 Bytes
document.querySelector('input[type="submit"]').addEventListener('click', function (e) {
e.preventDefault();
const text = document.querySelector('#text-input').value;
generateImage(text);
});
function generateImage(text) {
// create a new Three.js scene
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer({
canvas: document.querySelector('#output'),
});
renderer.setSize(window.innerWidth, window.innerHeight);
// add a cube to the scene
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
// position the camera
camera.position.z = 5;
// animate the scene
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
}