Created
April 5, 2021 05:58
-
-
Save lARSHADl/9260c3cc453fe07877063d30af7b154c to your computer and use it in GitHub Desktop.
3d model for website
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=UTF-8 /> | |
<link rel="stylesheet" type="text/css" href="styles.css" /> | |
</head> | |
<body> | |
<script src="./three/three.min.js"></script> | |
<script type="module" src="three/OrbitControls.js"></script> | |
<script type="module" src="three/GLTFLoader.js"></script> | |
<script type="module" > | |
import * as THREE from '../three/three.module.js'; | |
import { OrbitControls } from './three/OrbitControls.js'; | |
import { GLTFLoader } from './three/GLTFLoader.js'; | |
var scene, camera, renderer; | |
scene = new THREE.Scene(); | |
scene.background = new THREE.Color(0xff5f0f); | |
camera = new THREE.PerspectiveCamera(40,window.innerWidth/window.innerHeight,1,5000); | |
camera.rotation.y = 45/180*Math.PI; | |
camera.position.x = 800; | |
camera.position.y = 100; | |
camera.position.z = 1000; | |
//var controls = new OrbitControls( camera , renderer.domElement) | |
var controls = new THREE.OrbitControls(camera); | |
controls.addEventListener('change', renderer); | |
hlight = new THREE.AmbientLight (0x404040,100); | |
scene.add(hlight); | |
directionalLight = new THREE.DirectionalLight(0xffffff,100); | |
directionalLight.position.set(0,1,0); | |
directionalLight.castShadow = true; | |
scene.add(directionalLight); | |
var light = new THREE.PointLight(0xc4c4c4,10); | |
light.position.set(0,300,500); | |
scene.add(light); | |
var light2 = new THREE.PointLight(0xc4c4c4,10); | |
light2.position.set(500,100,0); | |
scene.add(light2); | |
var light3 = new THREE.PointLight(0xc4c4c4,10); | |
light3.position.set(0,100,-500); | |
scene.add(light3); | |
var light4 = new THREE.PointLight(0xc4c4c4,10); | |
light4.position.set(-500,300,500); | |
scene.add(light4); | |
renderer = new THREE.WebGLRenderer({antialias:true}); | |
renderer.setSize(window.innerWidth,window.innerHeight); | |
document.body.appendChild(renderer.domElement); | |
var loader = new THREE.GLTFLoader(); | |
loader.load('scene.gltf', function(gltf){ | |
var car = gltf.scene.children[0]; | |
car.scale.set(0.5,0.5,0.5); | |
scene.add(gltf.scene); | |
animate(); | |
}); | |
function animate() { | |
renderer.render(scene,camera); | |
requestAnimationFrame(animate); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment