MCPcopy Create free account
hub / github.com/SuboptimalEng/three-js-tutorials / App

Function App

12-shaders-in-vscode/src/App.jsx:10–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import fragmentShaderCode from './a_fragment.glsl';
9
10function App() {
11 useEffect(() => {
12 const test = new SceneInit('myThreeJsCanvas');
13 test.initialize();
14 test.animate();
15
16 // part 0 - add axis helper
17 // const axesHelper = new THREE.AxesHelper(16);
18 // test.scene.add(axesHelper);
19
20 // part 1 - boilerplate code
21 // const boxGeometry = new THREE.BoxGeometry(24, 4, 24, 24, 4, 24);
22 // const boxMaterial = new THREE.MeshStandardMaterial({
23 // color: 0xff0000,
24 // wireframe: true,
25 // });
26 // const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
27 // test.scene.add(boxMesh);
28
29 // define uniform data
30 const uniformData = {
31 u_time: {
32 type: 'f',
33 value: test.clock.getElapsedTime(),
34 },
35 };
36 const render = () => {
37 uniformData.u_time.value = test.clock.getElapsedTime();
38 window.requestAnimationFrame(render);
39 };
40 render();
41
42 // glsl shader
43 // const boxGeometry = new THREE.BoxGeometry(24, 4, 24, 24, 4, 24);
44 // const boxMaterial = new THREE.ShaderMaterial({
45 // wireframe: true,
46 // uniforms: uniformData,
47 // vertexShader: `
48 // varying vec3 pos;
49 // uniform float u_time;
50
51 // void main() {
52 // vec4 result;
53 // pos = position;
54
55 // result = vec4(
56 // position.x,
57 // 4.0*sin(position.z/4.0 + u_time) + position.y,
58 // position.z,
59 // 1.0
60 // );
61
62 // gl_Position = projectionMatrix * modelViewMatrix * result;
63 // }
64 // `,
65 // fragmentShader: `
66 // varying vec3 pos;
67 // uniform float u_time;

Callers

nothing calls this directly

Calls 3

initializeMethod · 0.95
animateMethod · 0.95
renderFunction · 0.70

Tested by

no test coverage detected