Skip to content

Instantly share code, notes, and snippets.

@Samsy
Created September 26, 2018 16:50
Show Gist options
  • Save Samsy/491ec29cecf8dea462565051eebf4585 to your computer and use it in GitHub Desktop.
Save Samsy/491ec29cecf8dea462565051eebf4585 to your computer and use it in GitHub Desktop.
triangle
uniform sampler2D tex;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tex, vUv );
}
import * as three from 'three'
class Triangle extends three.BufferGeometry {
constructor(){
super()
this.setIndex( [2, 1, 0] )
this.addAttribute( 'position', new three.Float32BufferAttribute(
[
-1, -1, 0,
-1, 4, 0,
4, -1, 0
]
, 3 ));
this.needsUpdate = true
}
}
let tri = new Triangle()
export default tri;
varying vec2 vUv;
void main() {
vUv = vec2(0.5)+(position.xy)*0.5;
gl_Position = vec4( position.xy, 0.0, 1.0 );;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment