Created
December 17, 2016 22:08
-
-
Save thejmazz/16be004548098f2107204796cb072f39 to your computer and use it in GitHub Desktop.
WHS Points Component
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
class Shell extends WHS.Component { | |
static instructions = { | |
position: [ 'x', 'y', 'z' ] | |
} | |
constructor(params = {}) { | |
super(params, WHS.Component.defaults, Shell.instructions) | |
const { radius, detail } = params.geometry | |
this.native = new THREE.Points( | |
new THREE.IcosahedronBufferGeometry(radius, detail), | |
new THREE.ShaderMaterial({ | |
uniforms: { | |
time: { value: 0.0, step: 0.1 }, | |
cameraConstant: { value: getCameraConstant(world.$camera) } | |
}, | |
vertexShader: esfaraShellVS, | |
fragmentShader: esfaraShellFS | |
}) | |
) | |
this.native.position.set(params.position.x, params.position.y, params.position.z) | |
this.loop = new WHS.Loop(() => { | |
const { time } = this.native.material.uniforms | |
time.value += time.step | |
}) | |
} | |
} | |
const shell = new Shell({ | |
geometry: { | |
radius: 1.2, | |
detail: 5 | |
}, | |
position: [0, 0, -4] | |
}) | |
shell.addTo(world) | |
shell.loop.start(world) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment