import * as THREE from 'three/webgpu';
import {
color,
mix,
normalLocal,
positionLocal,
sin,
time,
uniform
} from 'three/tsl';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1,
100);
camera.position.z = 4;
const amplitude = uniform(0.15);
const material = new THREE.MeshStandardNodeMaterial();
// Wave the surface along its normals on the GPU; compiles to WGSL or GLSL
material.positionNode = positionLocal.add(normalLocal.mul(sin(positionLocal.y
.mul(6).add(time)).mul(amplitude)));
material.colorNode = mix(color('#1e1e2e'), color('#7c5cff'), sin(time).mul(0.5)
.add(0.5));
scene.add(new THREE.Mesh(new THREE.IcosahedronGeometry(1, 64), material));
scene.add(new THREE.HemisphereLight(0xffffff, 0x222233, 2));
const renderer = new THREE.WebGPURenderer({
antialias: true
}); // falls back to WebGL 2
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
renderer.setAnimationLoop(() => renderer.render(scene, camera));