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

Function App

06-textures/src/App.jsx:7–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import SceneInit from './lib/SceneInit';
6
7function App() {
8 useEffect(() => {
9 const test = new SceneInit('myThreeJsCanvas');
10 test.initialize();
11 test.animate();
12
13 // Part 0
14 // const boxGeometry = new THREE.BoxGeometry(4, 4, 4);
15 // const boxMaterial = new THREE.MeshNormalMaterial();
16 // const boxMesh = new THREE.Mesh(boxGeometry, boxMaterial);
17 // test.scene.add(boxMesh);
18
19 // // Part 1
20 // const spaceTexture = new THREE.TextureLoader().load('./assets/space.jpeg');
21 // spaceTexture.wrapS = THREE.RepeatWrapping;
22 // spaceTexture.wrapT = THREE.RepeatWrapping;
23 // spaceTexture.repeat.set(2, 2);
24 // test.scene.background = spaceTexture;
25
26 // // Part 2
27 const uvTexture = new THREE.TextureLoader().load('./assets/uv.png');
28 const crateTexture = new THREE.TextureLoader().load('./assets/crate.png');
29 const earthTexture = new THREE.TextureLoader().load('./assets/earth.jpeg');
30 const brickTexture = new THREE.TextureLoader().load('./assets/brick.jpeg');
31
32 // Thumbnail
33 // const tgeo = new THREE.BoxGeometry(15, 15, 15);
34 // const tmat = new THREE.MeshStandardMaterial({
35 // map: crateTexture,
36 // });
37 // const tmesh = new THREE.Mesh(tgeo, tmat);
38 // tmesh.rotation.y = Math.PI / 4;
39 // tmesh.rotation.x = Math.PI / 8;
40 // test.scene.add(tmesh);
41
42 // Part 1.5
43 const ge0 = new THREE.BoxGeometry(7, 7, 7);
44 const me0 = new THREE.MeshStandardMaterial({
45 map: uvTexture,
46 });
47 const boxMe0 = new THREE.Mesh(ge0, me0);
48 boxMe0.position.x = -9;
49 boxMe0.position.y = -5;
50 test.scene.add(boxMe0);
51
52 const ge1 = new THREE.BoxGeometry(7, 7, 7);
53 const me1 = new THREE.MeshStandardMaterial({
54 map: crateTexture,
55 });
56 const boxMe1 = new THREE.Mesh(ge1, me1);
57 boxMe1.position.x = 0;
58 boxMe1.position.y = -5;
59 test.scene.add(boxMe1);
60
61 const ge2 = new THREE.BoxGeometry(7, 7, 7);
62 const me2 = new THREE.MeshStandardMaterial({
63 // map: earthTexture,
64 map: brickTexture,

Callers

nothing calls this directly

Calls 2

initializeMethod · 0.95
animateMethod · 0.95

Tested by

no test coverage detected