feat: added Basic Rotation / Motion for vanilla in task4
This commit is contained in:
parent
bc0db8864c
commit
98849cc0a0
18
Week-1/Task-4/vanilla/index.html
Normal file
18
Week-1/Task-4/vanilla/index.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>My first three.js app</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="module" src="/main.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
25
Week-1/Task-4/vanilla/main.js
Normal file
25
Week-1/Task-4/vanilla/main.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import * as THREE from 'three';
|
||||||
|
|
||||||
|
const scene = new THREE.Scene();
|
||||||
|
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||||
|
|
||||||
|
const renderer = new THREE.WebGLRenderer();
|
||||||
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||||
|
renderer.setAnimationLoop(animate);
|
||||||
|
document.body.appendChild(renderer.domElement);
|
||||||
|
|
||||||
|
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
||||||
|
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
|
||||||
|
const cube = new THREE.Mesh(geometry, material);
|
||||||
|
scene.add(cube);
|
||||||
|
|
||||||
|
camera.position.z = 5;
|
||||||
|
|
||||||
|
function animate(time) {
|
||||||
|
|
||||||
|
cube.rotation.x = time / 2000;
|
||||||
|
cube.rotation.y = time / 1000;
|
||||||
|
|
||||||
|
renderer.render(scene, camera);
|
||||||
|
|
||||||
|
}
|
||||||
@ -4,9 +4,15 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"packageManager": "yarn@1.22.22",
|
"packageManager": "yarn@1.22.22",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "echo 'Add your Three.js dev script here'",
|
"dev": "vite",
|
||||||
"build": "echo 'Add your Three.js build script here'",
|
"build": "vite build",
|
||||||
"lint": "echo 'Add your lint script here'",
|
"lint": "echo 'Add your lint script here'",
|
||||||
"clean": "rm -rf dist build"
|
"clean": "rm -rf dist build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"three": "^0.183.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"vite": "^8.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user