MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / init

Function init

assets/js/PanoramCube.js:11–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9animate();
10
11function init() {
12 const container = document.getElementById("container");
13
14 renderer = new THREE.WebGLRenderer();
15 renderer.setPixelRatio(window.devicePixelRatio);
16 renderer.setSize(window.innerWidth, window.innerHeight);
17 container.appendChild(renderer.domElement);
18
19 scene = new THREE.Scene();
20
21 camera = new THREE.PerspectiveCamera(
22 90,
23 window.innerWidth / window.innerHeight,
24 0.1,
25 100
26 );
27 camera.position.z = 0.01;
28
29 controls = new OrbitControls(camera, renderer.domElement);
30 controls.enableZoom = false;
31 controls.enablePan = false;
32 controls.enableDamping = true;
33 controls.rotateSpeed = -0.25;
34
35 const textures = getTexturesFromAtlasFile(
36 "../assets/Images/temple.jpg",
37 6
38 );
39
40 const materials = [];
41
42 for (let i = 0; i < 6; i++) {
43 materials.push(new THREE.MeshBasicMaterial({ map: textures[i] }));
44 }
45
46 const skyBox = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1), materials);
47 skyBox.geometry.scale(1, 1, -1);
48 scene.add(skyBox);
49
50 window.addEventListener("resize", onWindowResize);
51}
52
53function getTexturesFromAtlasFile(atlasImgUrl, tilesNum) {
54 const textures = [];

Callers 1

PanoramCube.jsFile · 0.70

Calls 1

getTexturesFromAtlasFileFunction · 0.85

Tested by

no test coverage detected