Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                	<link rel="stylesheet" type="text/css" href="https://ui-unicorn.co.uk/hostinger-exp/css/base.css" />


<body class="loading demo-1">
	<div class="loading-screen" data-section-theme="light">
		<div class="loading-animation">
			<div class="loading-bar"></div>
		</div>
	</div>

   
  
	


<div class="hotspot__positioner--01 hotspot1">
  <div class="hotspot__container">
    <div class="hotspot hotspot--01"></div>
    <div class="hotspot hotspot--02"></div>
    <div class="hotspot hotspot--03"></div>
  
  </div>
</div>

<div class="hotspot__positioner--02 hotspot2">
  <div class="hotspot__container">
    <div class="hotspot hotspot--01"></div>
    <div class="hotspot hotspot--02"></div>
    <div class="hotspot hotspot--03"></div>
      
  </div>
</div>

<div class="hotspot__positioner--03 hotspot3">
  <div class="hotspot__container">
    <div class="hotspot hotspot--01"></div>
    <div class="hotspot hotspot--02"></div>
    <div class="hotspot hotspot--03"></div>
       
  </div>
</div>




	<script src="https://ui-unicorn.co.uk/hostinger-exp/js/jquery-3.4.1.min.js"></script>



              
            
!

CSS

              
                
              
            
!

JS

              
                import * as THREE from 'https://ui-unicorn.co.uk/hostinger-exp/js/three.module.js';
import TWEEN from 'https://ui-unicorn.co.uk/hostinger-exp/js/tween.esm.js';

import {
    RGBELoader
}
from 'https://ui-unicorn.co.uk/hostinger-exp/js/RGBELoader.js';
import {
    OrbitControls
}
from 'https://ui-unicorn.co.uk/hostinger-exp/js/OrbitControls.js';
import {
    GLTFLoader
}
from 'https://ui-unicorn.co.uk/hostinger-exp/js/GLTFLoader.js';
import {
    RoughnessMipmapper
}
from 'https://ui-unicorn.co.uk/hostinger-exp/js/RoughnessMipmapper.js';

import {
    CSS2DRenderer,
    CSS2DObject
} from 'https://threejs.org/examples/jsm/renderers/CSS2DRenderer.js';
var container, controls;
var camera, scene, renderergl, mixer, clock, labelRenderer;
var raycaster, mouse;
var model;
var cube, cube2, MoveThisHead;

init();
animate();

function init() {
    container = document.createElement('div');
    container.className = "experience-div";
    $('body').prepend(container);
    camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
    camera.position.set(-10, 90, 8.7);
    scene = new THREE.Scene();
    clock = new THREE.Clock();
    raycaster = new THREE.Raycaster();
    mouse = new THREE.Vector2();
    new RGBELoader().setDataType(THREE.UnsignedByteType).load('https://ui-unicorn.co.uk/hostinger-exp/royal_esplanade_1k.hdr', function(texture) {
        var envMap = pmremGenerator.fromEquirectangular(texture).texture;
        scene.environment = envMap;

        texture.dispose();
        pmremGenerator.dispose();
        var roughnessMipmapper = new RoughnessMipmapper(renderergl);
        var loader = new GLTFLoader();
        loader.load('https://ui-unicorn.co.uk/hostinger-exp/untitled.gltf', function(gltf) {
            model = gltf.scene;
            gltf.scene.traverse(function(child) {
                if (child.isMesh) {
                    roughnessMipmapper.generateMipmaps(child.material);
                }
            });
            gltf.scene.scale.set(.010, .010, .010);
            gltf.scene.position.set(0, -0.4, 0);
            gltf.scene.rotation.set(0, -2.9, 0);
            scene.add(model);
            roughnessMipmapper.dispose();
            mixer = new THREE.AnimationMixer(gltf.scene);
            gltf.animations.forEach((clip) => {
                mixer.clipAction(clip).play();
            });
        });
    });
    renderergl = new THREE.WebGLRenderer({
        antialias: true
    });



    renderergl.setPixelRatio(window.devicePixelRatio);
    renderergl.setSize(window.innerWidth, window.innerHeight);
    renderergl.toneMapping = THREE.ACESFilmicToneMapping;
    renderergl.toneMappingExposure = 0.8;
    renderergl.outputEncoding = THREE.sRGBEncoding;
    container.appendChild(renderergl.domElement);
    $('.experience-div canvas').attr('id', 'canvas');
    var pmremGenerator = new THREE.PMREMGenerator(renderergl);
    pmremGenerator.compileEquirectangularShader();


    var hotspot1 = document.querySelector(".hotspot__positioner--01");
    var hotspotLabel1 = new CSS2DObject(hotspot1);
    hotspotLabel1.position.set(-1, -0.6, 0);
    scene.add(hotspotLabel1);


    var hotspot2 = document.querySelector(".hotspot__positioner--02");
    var hotspotLabel2 = new CSS2DObject(hotspot2);
    hotspotLabel2.position.set(0.9, 0.9461242899111069, -0.5);
    scene.add(hotspotLabel2);




    labelRenderer = new CSS2DRenderer();
    labelRenderer.setSize(window.innerWidth, window.innerHeight);
    labelRenderer.domElement.style.position = 'absolute';
    labelRenderer.domElement.style.top = 0;
    container.appendChild(labelRenderer.domElement);



    var geometry = new THREE.BoxGeometry(1, 1, 1);
    var material = new THREE.MeshBasicMaterial({
        color: 0x00ff00,
        transparent: !0,
        opacity: 0.7
    });

    cube = new THREE.Mesh(geometry, material);
    cube.position.set(-1, -0.6, 0);
    cube.name = 'MaBox';
    scene.add(cube);



    cube2 = new THREE.Mesh(geometry, material);
    cube2.position.set(0.9, 0.9461242899111069, -0.5);
    cube2.scale.set(1.65, 1.65, 1.65);
    cube2.name = 'MaBox-2';
    scene.add(cube2);



    controls = new OrbitControls(camera, renderergl.domElement);
    controls = new OrbitControls(camera, labelRenderer.domElement);
    controls.enableKeys = false;
    controls.target.set(0, -0.5, 0);
    controls.enableZoom = false;
    controls.enableDamping = true;
    controls.maxPolarAngle = 1.8;
    controls.minPolarAngle = 1.3;
    controls.dampingFactor = 0.095;
    controls.autoRotate = false;
    controls.rotateSpeed = 0.10;
    controls.minDistance = 2;
    controls.maxDistance = 10;
    controls.update();



    window.addEventListener('resize', onWindowResize, false);

    document.addEventListener('mousemove', onDocumentMouseMove, false);




}

function onWindowResize() {
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderergl.setSize(window.innerWidth, window.innerHeight);
    labelRenderer.setSize(window.innerWidth, window.innerHeight);

}




function onDocumentMouseMove(event) {

    event.preventDefault();
    var mouse = new THREE.Vector2();
    mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
    mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;

    raycaster.setFromCamera(mouse, camera);

    var intersects = raycaster.intersectObjects(scene.children, true);
    $('body').css('cursor', 'default');

   // TWEEN.removeAll();
    MoveThisHead = scene.getObjectByName("balloon_Balloon_0");
    var tween = new TWEEN.Tween(MoveThisHead.scale)
        .to({
            y: 1,
            x: 1,
            z: 1
        }, 2000).easing(TWEEN.Easing.Quadratic.InOut) // relative animation

        .onComplete(function() {

        })
        .start();

    if (intersects.length > 0) { // check the array

        $('body').css('cursor', 'default');
        if (intersects[0].object.name == 'MaBox') {
            //Move Head Scale it BIGGER
           // TWEEN.removeAll();
            MoveThisHead = scene.getObjectByName("balloon_Balloon_0");
            var tween = new TWEEN.Tween(MoveThisHead.scale)
                .to({
                    y: 1.6,
                    x: 1.6,
                    z: 1.6
                }, 2000).easing(TWEEN.Easing.Quadratic.InOut) // relative animation

                .onComplete(function() {

                })
                .start();
            $('body').css('cursor', 'pointer');
            console.log('Mouse is over Arm')
        } else if (intersects[0].object.name == 'MaBox-2') {

            $('body').css('cursor', 'pointer');
            console.log('Mouse is over Head')
        } else {

            $('body').css('cursor', 'default');
            console.log('Mouse is off')
        }
    }




}




function animate() {

    TWEEN.update();
    requestAnimationFrame(animate);

    var delta = clock.getDelta();
    if (mixer) mixer.update(delta);
    labelRenderer.render(scene, camera);
    renderergl.render(scene, camera);

    controls.update();
    testa();
}

//IRRELEVANT CODE BELOW NON THREE.JS
var previousImgFileSize;
var data_urli = renderergl.domElement.toDataURL();
var headi = 'data:image/png;base64,';
var imgFileSizei = Math.round((data_urli.length));
previousImgFileSize = imgFileSizei;
console.log(previousImgFileSize);
var previousImgFileSize;
var data_urli = renderergl.domElement.toDataURL();
var imgFileSizei = Math.round((data_urli.length));
previousImgFileSize = imgFileSizei;
console.log(previousImgFileSize);
var data_url;
var imgFileSize;
var logit;

function testa() {
    data_url = renderergl.domElement.toDataURL();
    imgFileSize = Math.round((data_url.length));
}

var glLoader = setInterval(glLoaderTime, 1000);

function glLoaderTime() {
    var imgFileSizeCh = imgFileSize;
    var previmg = previousImgFileSize;
    if (imgFileSizeCh > previmg) {

        $('.loading-screen').fadeOut(2500);
        $('.experience-div').fadeIn(2500);


        clearInterval(glLoader);
    }
}

$(document).ready(function() {

    $('#enter').hide();

    $('.hotspot1').hide();
    $('.hotspot2').hide();
    $('.hotspot3').hide();




});
              
            
!
999px

Console