1234567891011121314151617181920212223242526272829303132333435 |
- import * as THREE from "three"
- import { IcosahedronGeometry, MeshStandardMaterial, Mesh, ShaderMaterial } from "three";
-
- export class VaringBox {
- material: ShaderMaterial;
- private vertexShader = `
- uniform float time;
- varying vec3 vPos;
- void main() {
- vPos=position;
- vPos.x += sin( time + vPos.z * 4.0 ) / 4.0;
- //vPos.y += cos( time + vPos.z * 4.0 ) / 4.0;
- gl_Position = projectionMatrix * modelViewMatrix * vec4( vPos, 1.0 );
- }
- `;
-
- private fragmentShader = `
- varying vec3 vPos;
- void main() {
- gl_FragColor = vec4( vPos*2.0, 1.0 );
- }
- `;
-
- constructor() {
- this.material = new ShaderMaterial({
- uniforms: {
- time: {
- value: 0
- }
- },
- vertexShader: this.vertexShader,
- fragmentShader: this.fragmentShader
- });
- }
- }
|