-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (31 loc) · 1.09 KB
/
main.js
File metadata and controls
56 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import './style.css'
import * as THREE from 'three'
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader'
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
const light = new THREE.PointLight()
light.position.set(0.8, 1.4, 1.0)
scene.add(light)
const ambientLight = new THREE.AmbientLight()
scene.add(ambientLight)
const renderer = new THREE.WebGLRenderer({
canvas: document.querySelector('#bg')
})
renderer.setPixelRatio(window.devicePixelRatio)
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
camera.position.setZ(300)
const loader = new FBXLoader()
loader.load('./skull-rock/source/SketchfabExport.fbx', function (object) {
scene.add(object)
function animate () {
requestAnimationFrame(animate)
function rotate(event) {
event.preventDefault()
object.rotation.y += 0.0005
}
document.querySelector('#bg').addEventListener('wheel', rotate)
renderer.render(scene, camera)
}
animate()
})