added rotation
This commit is contained in:
6
main.js
6
main.js
@@ -7,6 +7,7 @@ import headURL from "./models/head.obj?url";
|
||||
const scene = new THREE.Scene();
|
||||
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||
const renderer = new THREE.WebGLRenderer();
|
||||
let modelObject = new THREE.Object3D;
|
||||
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.setAnimationLoop(animate);
|
||||
@@ -24,7 +25,7 @@ objectLoader.load(
|
||||
headURL,
|
||||
function(object) {
|
||||
console.log(object);
|
||||
|
||||
modelObject = object;
|
||||
object.traverse((child) => {
|
||||
if (child instanceof THREE.Mesh) {
|
||||
// Create material for the mesh.
|
||||
@@ -34,7 +35,7 @@ objectLoader.load(
|
||||
child.material.emissive = (new THREE.Color().setHex(0x962FFE));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
scene.add(object);
|
||||
},
|
||||
function(xhr) {
|
||||
@@ -46,6 +47,7 @@ objectLoader.load(
|
||||
);
|
||||
|
||||
function animate() {
|
||||
modelObject.rotateY(-THREE.MathUtils.degToRad(2));
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user