mirror of
https://github.com/seigler/webgl-threejs-hello
synced 2025-07-27 17:56:17 +00:00
⚡ Added an eyeball
This commit is contained in:
parent
2eeebe06e8
commit
8ffe124402
15 changed files with 381 additions and 16 deletions
48
app/js/components/Eyeball.js
Normal file
48
app/js/components/Eyeball.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import props from 'js/core/props';
|
||||
|
||||
class Eyeball extends THREE.Object3D {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
var loader = new THREE.GLTFLoader();
|
||||
|
||||
// Load a glTF resource
|
||||
loader.load(
|
||||
// resource URL
|
||||
'blue_eyeball/scene.gltf',
|
||||
// called when the resource is loaded
|
||||
( gltf ) => {
|
||||
|
||||
this.add( gltf.scene );
|
||||
|
||||
// gltf.animations; // Array<THREE.AnimationClip>
|
||||
// gltf.scene; // THREE.Scene
|
||||
// gltf.scenes; // Array<THREE.Scene>
|
||||
// gltf.cameras; // Array<THREE.Camera>
|
||||
// gltf.asset; // Object
|
||||
|
||||
},
|
||||
// called while loading is progressing
|
||||
( xhr ) => {
|
||||
|
||||
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
|
||||
|
||||
},
|
||||
// called when loading has errors
|
||||
( error ) => {
|
||||
|
||||
console.log( { error } );
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
this.onUpdate = this.onUpdate.bind(this);
|
||||
}
|
||||
|
||||
onUpdate() {
|
||||
this.rotation.x += props.rotation;
|
||||
this.rotation.y += props.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Eyeball;
|
Loading…
Add table
Add a link
Reference in a new issue