Created
March 18, 2017 18:08
-
-
Save thejmazz/794aeb5000fde2f6227477b12fdc4e48 to your computer and use it in GitHub Desktop.
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
const links = [{ | |
title: 'About', | |
position: [2, 1.5, 0], | |
color: 0x00ff00 | |
}, | |
{ | |
title: 'Contact', | |
position: [2, -1.5, 0], | |
color: 0xff0000 | |
}, | |
// If this is uncommented, the sphere component for Portfolio shows in scene | |
// Else, it still shows up in children of app.$scene, but does not seem to render | |
// { | |
// title: 'Portfolio', | |
// position: [-2, 1, 0], | |
// color: 0x0000ff | |
// }, | |
{ | |
title: 'Portfolio', | |
position: [-2, 1, 0], | |
color: 0x0000ff | |
} | |
].reduce(function (links, { title, position, color }) { | |
const sphere = new Sphere({ | |
buffer: true, | |
geometry: { | |
radius: 0.1, | |
widthSegments: 16, | |
heightSegments: 16 | |
}, | |
position, | |
material: new THREE.MeshBasicMaterial({ color }) | |
}) | |
// app.add(sphere) | |
mouse.track(sphere) | |
sphere.on('click', () => console.log(`${title} clicked`)) | |
sphere.on('mouseover', () => { | |
document.body.style.cursor = 'pointer' | |
hoverDown.stop(app) | |
hoverUp.start(app) | |
}) | |
sphere.on('mouseout', () => { | |
document.body.style.cursor = 'auto' | |
hoverUp.stop(app) | |
hoverDown.start(app) | |
}) | |
return { ...links, [title]: sphere } | |
}, {}) | |
links.About.addTo(app) | |
links.Portfolio.addTo(app) | |
links.Contact.addTo(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment