// source --> http://yann-sainty.com/wp-content/themes/ronneby/assets/js/general.js?ver=4.9.11 // jQuery(window).load(function() { window.onload = init; console.ward = function() {}; // what warnings? function init() { var root = new THREERoot({ createCameraControls: !true, antialias: (window.devicePixelRatio === 1), fov: 80 }); root.renderer.setClearColor(0x000000, 0); root.renderer.setPixelRatio(window.devicePixelRatio || 1); root.camera.position.set(0, 0, 60); var width = 125; var height = 60; var slide = new Slide(width, height, 'out'); var l1 = new THREE.ImageLoader(); // l1.setCrossOrigin('Anonymous'); l1.load('http://yann-sainty.com/wp-content/themes/ronneby/assets/images/moutain_black.jpg', function(img) { slide.setImage(img); }) root.scene.add(slide); var slide2 = new Slide(width, height, 'in'); var l2 = new THREE.ImageLoader(); // l2.setCrossOrigin('Anonymous'); l2.load('http://yann-sainty.com/wp-content/themes/ronneby/assets/images/moutain.jpg', function(img) { slide2.setImage(img); }) root.scene.add(slide2); var tl = new TimelineMax({repeat:-1, repeatDelay:1.0, yoyo: true}); tl.add(slide.transition(), 0); tl.add(slide2.transition(), 0); createTweenScrubber(tl); window.addEventListener('keyup', function(e) { if (e.keyCode === 80) { tl.paused(!tl.paused()); } }); } //////////////////// // CLASSES //////////////////// function Slide(width, height, animationPhase) { // jQuery('#cerf').addClass('animated'); var plane = new THREE.PlaneGeometry(width, height, width * 2, height * 2); THREE.BAS.Utils.separateFaces(plane); var geometry = new SlideGeometry(plane); geometry.bufferUVs(); var aAnimation = geometry.createAttribute('aAnimation', 2); var aStartPosition = geometry.createAttribute('aStartPosition', 3); var aControl0 = geometry.createAttribute('aControl0', 3); var aControl1 = geometry.createAttribute('aControl1', 3); var aEndPosition = geometry.createAttribute('aEndPosition', 3); var i, i2, i3, i4, v; var minDuration = 0.8; var maxDuration = 1.2; var maxDelayX = 0.9; var maxDelayY = 0.125; var stretch = 0.11; this.totalDuration = maxDuration + maxDelayX + maxDelayY + stretch; var startPosition = new THREE.Vector3(); var control0 = new THREE.Vector3(); var control1 = new THREE.Vector3(); var endPosition = new THREE.Vector3(); var tempPoint = new THREE.Vector3(); function getControlPoint0(centroid) { var signY = Math.sign(centroid.y); tempPoint.x = THREE.Math.randFloat(0.1, 0.3) * 50; tempPoint.y = signY * THREE.Math.randFloat(0.1, 0.3) * 70; tempPoint.z = THREE.Math.randFloatSpread(20); return tempPoint; } function getControlPoint1(centroid) { var signY = Math.sign(centroid.y); tempPoint.x = THREE.Math.randFloat(0.3, 0.6) * 50; tempPoint.y = -signY * THREE.Math.randFloat(0.3, 0.6) * 70; tempPoint.z = THREE.Math.randFloatSpread(20); return tempPoint; } for (i = 0, i2 = 0, i3 = 0, i4 = 0; i < geometry.faceCount; i++, i2 += 6, i3 += 9, i4 += 12) { var face = plane.faces[i]; var centroid = THREE.BAS.Utils.computeCentroid(plane, face); // animation var duration = THREE.Math.randFloat(minDuration, maxDuration); var delayX = THREE.Math.mapLinear(centroid.x, -width * 0.5, width * 0.5, 0.0, maxDelayX); var delayY; if (animationPhase === 'in') { delayY = THREE.Math.mapLinear(Math.abs(centroid.y), 0, height * 0.5, 0.0, maxDelayY) } else { delayY = THREE.Math.mapLinear(Math.abs(centroid.y), 0, height * 0.5, maxDelayY, 0.0) } for (v = 0; v < 6; v += 2) { aAnimation.array[i2 + v] = delayX + delayY + (Math.random() * stretch * duration); aAnimation.array[i2 + v + 1] = duration; } // positions endPosition.copy(centroid); startPosition.copy(centroid); if (animationPhase === 'in') { control0.copy(centroid).sub(getControlPoint0(centroid)); control1.copy(centroid).sub(getControlPoint1(centroid)); } else { // out control0.copy(centroid).add(getControlPoint0(centroid)); control1.copy(centroid).add(getControlPoint1(centroid)); } for (v = 0; v < 9; v += 3) { aStartPosition.array[i3 + v] = startPosition.x; aStartPosition.array[i3 + v + 1] = startPosition.y; aStartPosition.array[i3 + v + 2] = startPosition.z; aControl0.array[i3 + v] = control0.x; aControl0.array[i3 + v + 1] = control0.y; aControl0.array[i3 + v + 2] = control0.z; aControl1.array[i3 + v] = control1.x; aControl1.array[i3 + v + 1] = control1.y; aControl1.array[i3 + v + 2] = control1.z; aEndPosition.array[i3 + v] = endPosition.x; aEndPosition.array[i3 + v + 1] = endPosition.y; aEndPosition.array[i3 + v + 2] = endPosition.z; } } var material = new THREE.BAS.BasicAnimationMaterial( { shading: THREE.FlatShading, side: THREE.DoubleSide, uniforms: { uTime: {type: 'f', value: 0} }, shaderFunctions: [ THREE.BAS.ShaderChunk['cubic_bezier'], //THREE.BAS.ShaderChunk[(animationPhase === 'in' ? 'ease_out_cubic' : 'ease_in_cubic')], THREE.BAS.ShaderChunk['ease_in_out_cubic'], THREE.BAS.ShaderChunk['quaternion_rotation'] ], shaderParameters: [ 'uniform float uTime;', 'attribute vec2 aAnimation;', 'attribute vec3 aStartPosition;', 'attribute vec3 aControl0;', 'attribute vec3 aControl1;', 'attribute vec3 aEndPosition;', ], shaderVertexInit: [ 'float tDelay = aAnimation.x;', 'float tDuration = aAnimation.y;', 'float tTime = clamp(uTime - tDelay, 0.0, tDuration);', 'float tProgress = ease(tTime, 0.0, 1.0, tDuration);' //'float tProgress = tTime / tDuration;' ], shaderTransformPosition: [ (animationPhase === 'in' ? 'transformed *= tProgress;' : 'transformed *= 1.0 - tProgress;'), 'transformed += cubicBezier(aStartPosition, aControl0, aControl1, aEndPosition, tProgress);' ] }, { map: new THREE.Texture(), } ); THREE.Mesh.call(this, geometry, material); this.frustumCulled = false; } Slide.prototype = Object.create(THREE.Mesh.prototype); Slide.prototype.constructor = Slide; Object.defineProperty(Slide.prototype, 'time', { get: function () { return this.material.uniforms['uTime'].value; }, set: function (v) { this.material.uniforms['uTime'].value = v; } }); Slide.prototype.setImage = function(image) { this.material.uniforms.map.value.image = image; this.material.uniforms.map.value.needsUpdate = true; }; Slide.prototype.transition = function() { return TweenMax.fromTo(this, 3.0, {time:0.0}, {time:this.totalDuration, ease:Power0.easeInOut}); }; function SlideGeometry(model) { THREE.BAS.ModelBufferGeometry.call(this, model); } SlideGeometry.prototype = Object.create(THREE.BAS.ModelBufferGeometry.prototype); SlideGeometry.prototype.constructor = SlideGeometry; SlideGeometry.prototype.bufferPositions = function () { var positionBuffer = this.createAttribute('position', 3).array; for (var i = 0; i < this.faceCount; i++) { var face = this.modelGeometry.faces[i]; var centroid = THREE.BAS.Utils.computeCentroid(this.modelGeometry, face); var a = this.modelGeometry.vertices[face.a]; var b = this.modelGeometry.vertices[face.b]; var c = this.modelGeometry.vertices[face.c]; positionBuffer[face.a * 3] = a.x - centroid.x; positionBuffer[face.a * 3 + 1] = a.y - centroid.y; positionBuffer[face.a * 3 + 2] = a.z - centroid.z; positionBuffer[face.b * 3] = b.x - centroid.x; positionBuffer[face.b * 3 + 1] = b.y - centroid.y; positionBuffer[face.b * 3 + 2] = b.z - centroid.z; positionBuffer[face.c * 3] = c.x - centroid.x; positionBuffer[face.c * 3 + 1] = c.y - centroid.y; positionBuffer[face.c * 3 + 2] = c.z - centroid.z; } }; function THREERoot(params) { params = utils.extend({ fov: 60, zNear: 10, zFar: 100000, createCameraControls: true }, params); this.renderer = new THREE.WebGLRenderer({ antialias: params.antialias, alpha: true }); this.renderer.setPixelRatio(Math.min(2, window.devicePixelRatio || 1)); document.getElementById('three-container').appendChild(this.renderer.domElement); this.camera = new THREE.PerspectiveCamera( params.fov, window.innerWidth / window.innerHeight, params.zNear, params.zfar ); this.scene = new THREE.Scene(); if (params.createCameraControls) { this.controls = new THREE.OrbitControls(this.camera, this.renderer.domElement); } this.resize = this.resize.bind(this); this.tick = this.tick.bind(this); this.resize(); this.tick(); window.addEventListener('resize', this.resize, false); } THREERoot.prototype = { tick: function () { this.update(); this.render(); requestAnimationFrame(this.tick); }, update: function () { this.controls && this.controls.update(); }, render: function () { this.renderer.render(this.scene, this.camera); }, resize: function () { this.camera.aspect = window.innerWidth / window.innerHeight; this.camera.updateProjectionMatrix(); this.renderer.setSize(window.innerWidth, window.innerHeight); } }; //////////////////// // UTILS //////////////////// var utils = { extend: function (dst, src) { for (var key in src) { dst[key] = src[key]; } return dst; }, randSign: function () { return Math.random() > 0.5 ? 1 : -1; }, ease: function (ease, t, b, c, d) { return b + ease.getRatio(t / d) * c; }, fibSpherePoint: (function () { var vec = {x: 0, y: 0, z: 0}; var G = Math.PI * (3 - Math.sqrt(5)); return function (i, n, radius) { var step = 2.0 / n; var r, phi; vec.y = i * step - 1 + (step * 0.5); r = Math.sqrt(1 - vec.y * vec.y); phi = i * G; vec.x = Math.cos(phi) * r; vec.z = Math.sin(phi) * r; radius = radius || 1; vec.x *= radius; vec.y *= radius; vec.z *= radius; return vec; } })(), spherePoint: (function () { return function (u, v) { u === undefined && (u = Math.random()); v === undefined && (v = Math.random()); var theta = 2 * Math.PI * u; var phi = Math.acos(2 * v - 1); var vec = {}; vec.x = (Math.sin(phi) * Math.cos(theta)); vec.y = (Math.sin(phi) * Math.sin(theta)); vec.z = (Math.cos(phi)); return vec; } })() }; function createTweenScrubber(tween, seekSpeed) { seekSpeed = seekSpeed || 0.001; function stop() { TweenMax.to(tween, 1, {timeScale:0}); } function resume() { TweenMax.to(tween, 1, {timeScale:1}); } function seek(dx) { var progress = tween.progress(); var p = THREE.Math.clamp((progress + (dx * seekSpeed)), 0, 1); tween.progress(p); } var _cx = 0; // desktop var mouseDown = false; document.getElementById('three-container').style.cursor = 'pointer'; window.addEventListener('mousedown', function(e) { mouseDown = true; document.getElementById('three-container').style.cursor = 'ew-resize'; _cx = e.clientX; stop(); }); window.addEventListener('mouseup', function(e) { mouseDown = false; document.getElementById('three-container').style.cursor = 'pointer'; resume(); }); window.addEventListener('mousemove', function(e) { if (mouseDown === true) { var cx = e.clientX; var dx = cx - _cx; _cx = cx; seek(dx); } }); // mobile window.addEventListener('touchstart', function(e) { _cx = e.touches[0].clientX; stop(); e.preventDefault(); }); window.addEventListener('touchend', function(e) { resume(); e.preventDefault(); }); window.addEventListener('touchmove', function(e) { var cx = e.touches[0].clientX; var dx = cx - _cx; _cx = cx; seek(dx); e.preventDefault(); }); } // }); // source --> http://yann-sainty.com/wp-content/themes/ronneby/assets/js/jquery.queryloader2.min.js?ver=2 !function(e){function t(e){this.parent=e,this.container,this.loadbar,this.percentageContainer}function n(e){this.toPreload=[],this.parent=e,this.container}function i(e){this.element,this.parent=e}function r(i,r){this.element=i,this.$element=e(i),this.options=r,this.foundUrls=[],this.destroyed=!1,this.imageCounter=0,this.imageDone=0,this.alreadyLoaded=!1,this.preloadContainer=new n(this),this.overlayLoader=new t(this),this.defaultOptions={onComplete:function(){},onLoadComplete:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",barHeight:1,percentage:!1,deepSearch:!0,completeAnimation:"fade",minimumTime:500},this.init()}!function(e){"use strict";function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define(o):"object"==typeof exports?module.exports=o:e.eventie=o}(this),function(){"use strict";function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if(e instanceof RegExp){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;tn;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),d&&(this.jqDeferred=new d.Deferred);var r=this;setTimeout(function(){r.check()})}function a(e){this.img=e}function h(e){this.src=e,f[e]=this}var d=e.jQuery,p=e.console,c="undefined"!=typeof p,u=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new a(e);this.images.push(t)},s.prototype.check=function(){function e(e){return t.options.debug&&c,t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return void this.complete();for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},d&&(d.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(d(this))}),a.prototype=new t,a.prototype.check=function(){var e=f[this.img.src]||new h(this.img.src);if(e.isConfirmed)return void this.confirm(e.isLoaded,"cached was confirmed");if(this.img.complete&&void 0!==this.img.naturalWidth)return void this.confirm(0!==this.img.naturalWidth,"naturalWidth");var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},a.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var f={};return h.prototype=new t,h.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},h.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},h.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},h.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},h.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},h.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s}),t.prototype.createOverlay=function(){var t="absolute";if("body"==this.parent.element.tagName.toLowerCase())t="fixed";else{var n=this.parent.$element.css("position");("fixed"!=n||"absolute"!=n)&&this.parent.$element.css("position","relative")}this.container=e("
").appendTo(this.parent.$element),this.parent._qLbar_wrap.length>0?(this.parent._qLbar_wrap.appendTo(this.container),this.parent.options.percentage=this.parent._qLbar_wrap.hasClass("dfd-percentage-enabled")?!0:!1,this.loadbar=this.parent._qLbar_wrap.find("#qLbar")):e("#qLoverlay_logo").length>0&&(this.logo=e('
').appendTo(this.container)),1==this.parent.options.percentage&&(this.percentageContainer=e("
").text("0%").appendTo(this.container)),this.parent.preloadContainer.toPreload.length&&1!=this.parent.alreadyLoaded||this.parent.destroyContainers()},t.prototype.updatePercentage=function(e){this.loadbar&&this.loadbar.stop().animate({width:e+"%",minWidth:e+"%"},2e3),1==this.parent.options.percentage&&this.percentageContainer.text(Math.ceil(e)+"%")},n.prototype.create=function(){e("#"+this.parent.options.overlayId).remove(),this.container=e("
").appendTo("body").css({display:"none",overflow:"hidden"}),this.processQueue()},n.prototype.processQueue=function(){for(var e=0;this.toPreload.length>e;e++)this.parent.destroyed||this.preloadImage(this.toPreload[e])},n.prototype.addImage=function(e){this.toPreload.push(e)},n.prototype.preloadImage=function(e){var t=new i;t.addToPreloader(this,e),t.bindLoadEvent()},i.prototype.addToPreloader=function(t,n){this.element=e("").attr("src",n),this.element.appendTo(t.container),this.parent=t.parent},i.prototype.bindLoadEvent=function(){this.parent.imageCounter++,this.element[0].ref=this,new imagesLoaded(this.element,function(e){e.elements[0].ref.completeLoading()})},i.prototype.completeLoading=function(){this.parent.imageDone++;var e=this.parent.imageDone/this.parent.imageCounter*100;this.parent.overlayLoader.updatePercentage(e),(this.parent.imageDone==this.parent.imageCounter||e>=100)&&this.parent.endLoader()},r.prototype.init=function(){this._qLbar_wrap=e("#qLbar_wrap").detach(),this.options=e.extend({},this.defaultOptions,this.options);this.findImageInElement(this.element);if(1==this.options.deepSearch)for(var t=this.$element.find("*:not(script)"),n=0;n0&&!e.match(/^(data:)/i)?!0:!1},r.prototype.urlIsNew=function(e){return-1==this.foundUrls.indexOf(e)?!0:!1},r.prototype.destroyContainers=function(){this.destroyed=!0,this.preloadContainer.container.remove(),this.overlayLoader.container.remove()},r.prototype.endLoader=function(){this.destroyed=!0,this.onLoadComplete()},r.prototype.onLoadComplete=function(){if(this.options.onLoadComplete(),"grow"==this.options.completeAnimation){var t=this.options.minimumTime;this.overlayLoader.loadbar[0].parent=this,this.overlayLoader.loadbar.stop().animate({width:"100%"},t,function(){e(this).animate({top:"0%",width:"100%",height:"100%"},500,function(){this.parent.overlayLoader.container[0].parent=this.parent,this.parent.overlayLoader.container.fadeOut(500,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})})})}else{var t=this.options.minimumTime;this.overlayLoader.container[0].parent=this,this.overlayLoader.container.fadeOut(t,function(){this.parent.destroyContainers(),this.parent.options.onComplete()})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,n=Number(arguments[1])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=t);t>n;n++)if(n in this&&this[n]===e)return n;return-1}),e.fn.queryLoader2=function(e){return this.each(function(){new r(this,e)})};{var o={barHeight:1e3,barColor:"#000",percentage:!1,completeAnimation:"fade",minimumTime:2e3};/(iPad|iPhone|iPod)/g.test(navigator.userAgent)}e(document).ready(function(){e("body").queryLoader2(o)})}(jQuery);