Skip to content

Instantly share code, notes, and snippets.

@thejmazz
Created December 17, 2016 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejmazz/16be004548098f2107204796cb072f39 to your computer and use it in GitHub Desktop.
Save thejmazz/16be004548098f2107204796cb072f39 to your computer and use it in GitHub Desktop.
WHS Points Component
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