-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87ee44a
commit e769c7c
Showing
8 changed files
with
190 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import * as THREE from 'three' | ||
import { gsap } from 'gsap' | ||
|
||
import Experience from './Experience.js' | ||
|
||
export default class LoupedeckButtons | ||
{ | ||
constructor() | ||
{ | ||
this.experience = new Experience() | ||
this.resources = this.experience.resources | ||
this.debug = this.experience.debug | ||
this.scene = this.experience.scene | ||
this.time = this.experience.time | ||
|
||
// Debug | ||
if(this.debug) | ||
{ | ||
this.debugFolder = this.debug.addFolder({ | ||
title: 'loupedeckButtons', | ||
expanded: true | ||
}) | ||
} | ||
|
||
this.setModel() | ||
this.setAnimation() | ||
} | ||
|
||
setModel() | ||
{ | ||
this.model = {} | ||
|
||
this.model.items = [] | ||
|
||
// Children | ||
const children = [...this.resources.items.loupedeckButtonsModel.scene.children] | ||
children.sort((_a, _b) => | ||
{ | ||
if(_a.name < _b.name) | ||
return -1 | ||
|
||
if(_a.name > _b.name) | ||
return 1 | ||
|
||
return 0 | ||
}) | ||
|
||
let i = 0 | ||
for(const _child of children) | ||
{ | ||
const item = {} | ||
|
||
item.index = i | ||
|
||
item.material = new THREE.MeshBasicMaterial({ | ||
color: 0xffffff, | ||
transparent: true | ||
}) | ||
|
||
item.mesh = _child | ||
item.mesh.material = item.material | ||
this.scene.add(item.mesh) | ||
|
||
this.model.items.push(item) | ||
|
||
// // Debug | ||
// if(this.debug) | ||
// { | ||
// this.debugFolder | ||
// .addInput( | ||
// item, | ||
// 'color', | ||
// { view: 'color' } | ||
// ) | ||
// .on('change', () => | ||
// { | ||
// item.material.color.set(item.color) | ||
// }) | ||
// } | ||
|
||
i++ | ||
} | ||
} | ||
|
||
setAnimation() | ||
{ | ||
this.animation = {} | ||
|
||
this.animation.colors = ['#af55cf', '#dbd85d', '#e86b24', '#b81b54'] | ||
|
||
for(const _colorIndex in this.animation.colors) | ||
{ | ||
// Debug | ||
if(this.debug) | ||
{ | ||
this.debugFolder | ||
.addInput( | ||
this.animation.colors, | ||
_colorIndex, | ||
{ view: 'color' } | ||
) | ||
// .on('change', () => | ||
// { | ||
// item.material.color.set(item.color) | ||
// }) | ||
} | ||
} | ||
|
||
this.animation.play = () => | ||
{ | ||
const buttons = [] | ||
const outButtons = [] | ||
|
||
for(const _button of this.model.items) | ||
{ | ||
if(Math.random() < 0.5) | ||
{ | ||
buttons.push(_button) | ||
} | ||
else | ||
{ | ||
outButtons.push(_button) | ||
} | ||
} | ||
|
||
for(const _button of outButtons) | ||
{ | ||
_button.material.opacity = 0 | ||
} | ||
|
||
let i = 0 | ||
for(const _button of buttons) | ||
{ | ||
_button.material.color.set(this.animation.colors[Math.floor(Math.random() * this.animation.colors.length)]) | ||
gsap.to( | ||
_button.material, | ||
{ | ||
delay: i * 0.05, | ||
duration: 0.2, | ||
opacity: 1, | ||
onComplete: () => | ||
{ | ||
gsap.to( | ||
_button.material, | ||
{ | ||
delay: 3, | ||
duration: 0.5, | ||
opacity: 0 | ||
} | ||
) | ||
} | ||
} | ||
) | ||
|
||
i++ | ||
} | ||
} | ||
|
||
this.animation.play() | ||
window.setInterval(this.animation.play, 5000) | ||
} | ||
|
||
update() | ||
{ | ||
// for(const _item of this.model.items) | ||
// { | ||
// _item.material.opacity = Math.sin(this.time.elapsed * 0.002 - _item.index * 0.5) * 0.5 + 0.5 | ||
// } | ||
} | ||
} |
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
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
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
Binary file not shown.
Binary file not shown.
e769c7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: