-
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
d49eb8f
commit a7c081d
Showing
9 changed files
with
131 additions
and
2 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
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,100 @@ | ||
import Experience from './Experience.js' | ||
|
||
import * as THREE from 'three' | ||
|
||
export default class GoogleLeds | ||
{ | ||
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: 'googleLeds', | ||
expanded: true | ||
}) | ||
} | ||
|
||
this.setModel() | ||
} | ||
|
||
setModel() | ||
{ | ||
this.model = {} | ||
|
||
this.model.items = [] | ||
|
||
const colors = ['#196aff', '#ff0000', '#ff5d00', '#7db81b'] | ||
|
||
// Texture | ||
this.model.texture = this.resources.items.googleHomeLedMaskTexture | ||
|
||
// Children | ||
const children = [...this.resources.items.googleHomeLedsModel.scene.children] | ||
children.sort((_a, _b) => | ||
{ | ||
if(_a.name < _b.name) | ||
return -1 | ||
|
||
if(_a.name > _b.name) | ||
return 1 | ||
|
||
return 0 | ||
}) | ||
|
||
console.log(children) | ||
|
||
let i = 0 | ||
for(const _child of children) | ||
{ | ||
const item = {} | ||
|
||
item.index = i | ||
|
||
item.color = colors[item.index] | ||
|
||
item.material = new THREE.MeshBasicMaterial({ | ||
color: item.color, | ||
transparent: true, | ||
alphaMap: this.model.texture | ||
}) | ||
|
||
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++ | ||
} | ||
} | ||
|
||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
a7c081d
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: