Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
  <title>Landing Page</title>
   <meta charset="utf-8" 
        name = "viewport"
        content = "width=device-width, initial scale-1.0"
        http-equiv= "X-UA-Compatible"
        content= "IE edge">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>

  <header id= 'logo right'> 
          <img class="logo" id = "logo" src="https://raw.githubusercontent.com/LostnAustin/NewMortgage/master/NewMortgage.png" alt = "logo"/>

    <div id= 'body1'>
  </div>
     
      <div>
      <div id="loading">
      </div>
      <div class="buttons">
  <button id="mountains">Mountains</button>
  <button id="volcano">Volcano</button>
  <button id="autoRotate">Auto Revolve</button>
           

<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
        
        </div>
              
            
!

CSS

              
                body {
  margin: 0;
  height: 100vh;
  background: #bdc3c7;
}

#loading {
  position: fixed;
  font-size: 40px;
  z-index: -1;
  left: 28%;
  top: 15%;
  color: #444;
  text-align: center;
}

main {
  z-index: 1;
}
              
            
!

JS

              
                let scene, camera, renderer, skyboxGeo, skybox, controls, myReq;
let zoomOut = false;
let autoRotate = true;
let skyboxImage = 'arid2';
        
        
  function createPathStrings(filename) {
  const basePath = `https://raw.githubusercontent.com/LostnAustin/skyboxProject/master/${filename}/`;
  const baseFilename = basePath + filename;
  const fileType = filename == 'arid2' || 'vulcan' ? '.jpg' : '.png';
 
  const sides = ['ft', 'bk', 'up', 'dn', 'rt', 'lf'];
  const pathStrings = sides.map(side => {
    return baseFilename + '_' + side + fileType;
  });

  return pathStrings;
}

function createMaterialArray(filename) {
  const skyboxImagepaths = createPathStrings(filename);
  const materialArray = skyboxImagepaths.map(image => {
    let texture = new THREE.TextureLoader().load(image);

    return new THREE.MeshBasicMaterial({ map: texture, side: THREE.BackSide });
  });
  return materialArray;
}

function init() {

  scene = new THREE.Scene();
  camera = new THREE.PerspectiveCamera(
    55,
    window.innerWidth / window.innerHeight,
    45,
    30000,
  );
  camera.position.set(1200, -1550, 2000);

  renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
  renderer.setSize(window.innerWidth, window.innerHeight);
  renderer.domElement.id = 'canvas';
  document.body.appendChild(renderer.domElement);

  const materialArray = createMaterialArray(skyboxImage);

  skyboxGeo = new THREE.BoxGeometry(10000, 10000, 10000);
  skybox = new THREE.Mesh(skyboxGeo, materialArray);

  scene.add(skybox);


  controls = new THREE.OrbitControls(camera, renderer.domElement);
  controls.enabled = true;
  controls.minDistance = 700;
  controls.maxDistance = 5000;
  controls.autoRotate = true;
  controls.autoRotateSpeed = 0.5;

  window.addEventListener('resize', onWindowResize, false);
  animate();
}
function onWindowResize() {
  camera.aspect = window.innerWidth / window.innerHeight;

  camera.updateProjectionMatrix();
  renderer.setSize(window.innerWidth, window.innerHeight);
}

function animate() {
    controls.autoRotate = autoRotate;
  
    if(controls.maxDistance == 1500 && zoomOut) {
    
      controls.maxDistance = 20000;
      camera.position.z = 20000;
    } else if(controls.maxDistance == 20000 && !zoomOut) {
          console.log('called')
      controls.maxDistance = 1500;
      camera.position.z = 2000;
    }
    
    controls.update();
    renderer.render(scene, camera);
    myReq = window.requestAnimationFrame(animate);
   
}

init();

function switchSkyBox (skyboxName) {
  scene.remove(skybox);
  skyboxImage = skyboxName;
  const materialArray = createMaterialArray(skyboxImage);

  skybox = new THREE.Mesh(skyboxGeo, materialArray);
  scene.add(skybox);
}

function toggleAutoRotate(value) {
  autoRotate = value;
}

// function toggleZoom(value) {
//   zoomOut = value;
//   zoomBtn.textContent = value ? 'Inside Box' : "Outside Box";
//   loading.style.display = value ? 'none' : 'show';
// }



const mountainsBtn = document.getElementById('mountains');
const volcanoBtn = document.getElementById('volcano');
// const alexGreyBtn = document.getElementById('alexGrey');

const autoRotateBtn = document.getElementById('autoRotate');
const zoomBtn = document.getElementById('zoom');
const loading = document.getElementById('loading');

mountainsBtn.addEventListener('click', () => switchSkyBox('arid2'));
volcanoBtn.addEventListener('click', () => switchSkyBox('vulcan'));
// alexGreyBtn.addEventListener('click', () => switchSkyBox('alexGrey'));


autoRotateBtn.addEventListener('click', () => toggleAutoRotate(!autoRotate))
// zoomBtn.addEventListener('click', () => toggleZoom(!zoomOut))

              
            
!
999px

Console