diff --git a/lib/photo-sphere-viewer.js b/lib/photo-sphere-viewer.js deleted file mode 100644 index c9381b3..0000000 --- a/lib/photo-sphere-viewer.js +++ /dev/null @@ -1,1503 +0,0 @@ -/* -* Photo Sphere Viewer v2.2.1 -* http://jeremyheleine.com/#photo-sphere-viewer -* -* Copyright (c) 2014,2015 Jérémy Heleine -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -/** - * Viewer class - * @param args (Object) Viewer settings - * - panorama (string) Panorama URL or path (absolute or relative) - * - container (HTMLElement) Panorama container (should be a div or equivalent) - * - autoload (boolean) (optional) (true) true to automatically load the panorama, false to load it later (with the .load() method) - * - usexmpdata (boolean) (optional) (true) true if Photo Sphere Viewer must read XMP data, false if it is not necessary - * - default_position (Object) (optional) ({}) Defines the default position, the first point seen by the user (e.g. {long: Math.PI, lat: Math.PI/2}) - * - min_fov (number) (optional) (30) The minimal field of view, in degrees, between 1 and 179 - * - max_fov (number) (optional) (90) The maximal field of view, in degrees, between 1 and 179 - * - tilt_up_max (number) (optional) (Math.PI/2) The maximal tilt up angle, in radians - * - tilt_down_max (number) (optional) (Math.PI/2) The maximal tilt down angle, in radians - * - zoom_level (number) (optional) (0) The default zoom level, between 0 and 100 - * - long_offset (number) (optional) (PI/360) The longitude to travel per pixel moved by mouse/touch - * - lat_offset (number) (optional) (PI/180) The latitude to travel per pixel moved by mouse/touch - * - time_anim (integer) (optional) (2000) Delay before automatically animating the panorama in milliseconds, false to not animate - * - theta_offset (integer) (optional) (1440) (deprecated) The PI fraction to add to theta during the animation - * - anim_speed (string) (optional) (2rpm) Animation speed in radians/degrees/revolutions per second/minute - * - navbar (boolean) (optional) (false) Display the navigation bar if set to true - * - navbar_style (Object) (optional) ({}) Style of the navigation bar - * - loading_img (string) (optional) (null) Loading image URL or path (absolute or relative) - * - size (Object) (optional) (null) Final size of the panorama container (e.g. {width: 500, height: 300}) - * - onready (Function) (optional) (null) Function called once the panorama is ready and the first image is displayed - **/ - -var PhotoSphereViewer = function(args) { - /** - * Detects whether canvas is supported - * @return (boolean) true if canvas is supported, false otherwise - **/ - - var isCanvasSupported = function() { - var canvas = document.createElement('canvas'); - return !!(canvas.getContext && canvas.getContext('2d')); - } - - /** - * Detects whether WebGL is supported - * @return (boolean) true if WebGL is supported, false otherwise - **/ - - var isWebGLSupported = function() { - var canvas = document.createElement('canvas'); - return !!(window.WebGLRenderingContext && canvas.getContext('webgl')); - } - - /** - * Attaches an event handler function to an elemnt - * @param elt (HTMLElement) The element - * @param evt (string) The event name - * @param f (Function) The handler function - * @return (void) - **/ - - var addEvent = function(elt, evt, f) { - if (!!elt.addEventListener) - elt.addEventListener(evt, f, false); - else - elt.attachEvent('on' + evt, f); - } - - /** - * Ensures that a number is in a given interval - * @param x (number) The number to check - * @param min (number) First endpoint - * @param max (number) Second endpoint - * @return (number) The checked number - **/ - - var stayBetween = function(x, min, max) { - return Math.max(min, Math.min(max, x)); - } - - /** - * Calculates the distance between two points (square of the distance is enough) - * @param x1 (number) Horizontal coordinate (first point) - * @param y1 (number) Vertical coordinate (first point) - * @param x2 (number) Horizontal coordinate (second point) - * @param y2 (number) Vertical coordinate (second point) - * @return (number) Squar of the wanted distance - **/ - - var dist = function(x1, y1, x2, y2) { - var x = x2 - x1; - var y = y2 - y1; - return x*x + y*y; - } - - /** - * Returns the measure of an angle (between 0 and 2π) - * @param angle (number) The angle to reduce - * @return (number) The wanted measure - **/ - - var getAngleMeasure = function(angle) { - return angle - Math.floor(angle / (2.0 * Math.PI)) * 2.0 * Math.PI; - } - - /** - * Starts to load the panorama - * @return (void) - **/ - - this.load = function() { - // Loading indicator (text or image if given) - if (!!loading_img) { - var loading = document.createElement('img'); - loading.setAttribute('src', loading_img); - loading.setAttribute('alt', 'Loading...'); - container.appendChild(loading); - } - else - container.textContent = 'Loading...'; - - // Adds a new container - root = document.createElement('div'); - root.style.width = '100%'; - root.style.height = '100%'; - root.style.position = 'relative'; - - // Is canvas supported? - if (!isCanvasSupported()) { - container.textContent = 'Canvas is not supported, update your browser!'; - return; - } - - // Is Three.js loaded? - if (window.THREE === undefined) { - console.log('PhotoSphereViewer: Three.js is not loaded.'); - return; - } - - // Current viewer size - viewer_size = { - width: 0, - height: 0, - ratio: 0 - }; - - // XMP data? - if (readxmp) - loadXMP(); - - else - createBuffer(false); - } - - /** - * Returns the value of a given attribute in the panorama metadata - * @param data (string) The panorama metadata - * @param attr (string) The wanted attribute - * @return (string) The value of the attribute - **/ - - var getAttribute = function(data, attr) { - var a = data.indexOf('GPano:' + attr) + attr.length + 8, b = data.indexOf('"', a); - return data.substring(a, b); - } - - /** - * Loads the XMP data with AJAX - * @return (void) - **/ - - var loadXMP = function() { - var xhr = null; - - if (window.XMLHttpRequest) - xhr = new XMLHttpRequest(); - - else if (window.ActiveXObject) { - try { - xhr = new ActiveXObject('Msxml2.XMLHTTP'); - } - catch (e) { - xhr = new ActiveXObject('Microsoft.XMLHTTP'); - } - } - - else { - container.textContent = 'XHR is not supported, update your browser!'; - return; - } - - xhr.onreadystatechange = function() { - if (xhr.readyState == 4 && xhr.status == 200) { - // Metadata - var binary = xhr.responseText; - var a = binary.indexOf(''); - var data = binary.substring(a, b); - - // No data retrieved - if (a == -1 || b == -1 || data.indexOf('GPano:') == -1) { - createBuffer(false); - return; - } - - // Useful values - var pano_data = { - full_width: parseInt(getAttribute(data, 'FullPanoWidthPixels')), - full_height: parseInt(getAttribute(data, 'FullPanoHeightPixels')), - cropped_width: parseInt(getAttribute(data, 'CroppedAreaImageWidthPixels')), - cropped_height: parseInt(getAttribute(data, 'CroppedAreaImageHeightPixels')), - cropped_x: parseInt(getAttribute(data, 'CroppedAreaLeftPixels')), - cropped_y: parseInt(getAttribute(data, 'CroppedAreaTopPixels')), - }; - - createBuffer(pano_data); - } - }; - - xhr.open('GET', panorama, true); - xhr.send(null); - } - - /** - * Creates an image in the right dimensions - * @param pano_data (mixed) An object containing the panorama XMP data (false if it there is not) - * @return (void) - **/ - - var createBuffer = function(pano_data) { - var img = new Image(); - - img.onload = function() { - // No XMP data? - if (!pano_data) { - pano_data = { - full_width: img.width, - full_height: img.height, - cropped_width: img.width, - cropped_height: img.height, - cropped_x: 0, - cropped_y: 0, - }; - } - - // Size limit for mobile compatibility - var max_width = 2048; - if (isWebGLSupported()) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('webgl'); - max_width = ctx.getParameter(ctx.MAX_TEXTURE_SIZE); - } - - // Buffer width (not too big) - var new_width = Math.min(pano_data.full_width, max_width); - var r = new_width / pano_data.full_width; - - pano_data.full_width = new_width; - pano_data.cropped_width *= r; - pano_data.cropped_x *= r; - img.width = pano_data.cropped_width; - - // Buffer height (proportional to the width) - pano_data.full_height *= r; - pano_data.cropped_height *= r; - pano_data.cropped_y *= r; - img.height = pano_data.cropped_height; - - // Buffer creation - var buffer = document.createElement('canvas'); - buffer.width = pano_data.full_width; - buffer.height = pano_data.full_height; - - var ctx = buffer.getContext('2d'); - ctx.drawImage(img, pano_data.cropped_x, pano_data.cropped_y, pano_data.cropped_width, pano_data.cropped_height); - - loadTexture(buffer.toDataURL('image/jpeg')); - }; - - // CORS when the panorama is not given as a base64 string - if (!panorama.match(/^data:image\/[a-z]+;base64/)) - img.setAttribute('crossOrigin', 'anonymous'); - - img.src = panorama; - } - - /** - * Loads the sphere texture - * @param path (URL) Path to the panorama - * @return (void) - **/ - - var loadTexture = function(path) { - var texture = new THREE.Texture(); - var loader = new THREE.ImageLoader(); - - var onLoad = function(img) { - texture.needsUpdate = true; - texture.image = img; - - createScene(texture); - } - - loader.load(path, onLoad); - } - - /** - * Creates the 3D scene - * @param texture (THREE.Texture) The sphere texture - * @return (void) - **/ - - var createScene = function(texture) { - // New size? - if (new_viewer_size.width !== undefined) - container.style.width = new_viewer_size.width.css; - - if (new_viewer_size.height !== undefined) - container.style.height = new_viewer_size.height.css; - - fitToContainer(); - - // The chosen renderer depends on whether WebGL is supported or not - renderer = (isWebGLSupported()) ? new THREE.WebGLRenderer() : new THREE.CanvasRenderer(); - renderer.setSize(viewer_size.width, viewer_size.height); - - scene = new THREE.Scene(); - - camera = new THREE.PerspectiveCamera(PSV_FOV_MAX, viewer_size.ratio, 1, 300); - camera.position.set(0, 0, 0); - scene.add(camera); - - // Sphere - var geometry = new THREE.SphereGeometry(200, 32, 32); - var material = new THREE.MeshBasicMaterial({map: texture, overdraw: true}); - var mesh = new THREE.Mesh(geometry, material); - mesh.scale.x = -1; - scene.add(mesh); - - // Canvas container - canvas_container = document.createElement('div'); - canvas_container.style.position = 'absolute'; - canvas_container.style.zIndex = 0; - root.appendChild(canvas_container); - - // Navigation bar? - if (display_navbar) { - navbar.setStyle(navbar_style); - navbar.create(); - root.appendChild(navbar.getBar()); - } - - // Adding events - addEvent(window, 'resize', fitToContainer); - - addEvent(canvas_container, 'mousedown', onMouseDown); - addEvent(canvas_container, 'touchstart', onTouchStart); - addEvent(document, 'mouseup', onMouseUp); - addEvent(document, 'touchend', onMouseUp); - addEvent(document, 'mousemove', onMouseMove); - addEvent(document, 'touchmove', onTouchMove); - addEvent(canvas_container, 'mousewheel', onMouseWheel); - addEvent(canvas_container, 'DOMMouseScroll', onMouseWheel); - - addEvent(document, 'fullscreenchange', fullscreenToggled); - addEvent(document, 'mozfullscreenchange', fullscreenToggled); - addEvent(document, 'webkitfullscreenchange', fullscreenToggled); - addEvent(document, 'MSFullscreenChange', fullscreenToggled); - - // First render - container.innerHTML = ''; - container.appendChild(root); - - var canvas = renderer.domElement; - canvas.style.display = 'block'; - - canvas_container.appendChild(canvas); - render(); - - // Zoom? - if (zoom_lvl > 0) - zoom(zoom_lvl); - - // Animation? - anim(); - - // Panorama is ready - triggerAction('ready'); - } - - /** - * Renders an image - * @return (void) - **/ - - var render = function() { - var point = new THREE.Vector3(); - point.setX(Math.cos(lat) * Math.sin(long)); - point.setY(Math.sin(lat)); - point.setZ(Math.cos(lat) * Math.cos(long)); - - camera.lookAt(point); - renderer.render(scene, camera); - } - - /** - * Automatically animates the panorama - * @return (void) - **/ - - var anim = function() { - if (anim_delay !== false) - anim_timeout = setTimeout(startAutorotate, anim_delay); - } - - /** - * Automatically rotates the panorama - * @return (void) - **/ - - var autorotate = function() { - // Returns to the equator (lat = 0) - lat -= lat / 200; - - // Rotates the sphere - long += long_offset; - long -= Math.floor(long / (2.0 * Math.PI)) * 2.0 * Math.PI; - - render(); - autorotate_timeout = setTimeout(autorotate, PSV_ANIM_TIMEOUT); - } - - /** - * Starts the autorotate animation - * @return (void) - **/ - - var startAutorotate = function() { - autorotate(); - triggerAction('autorotate', true); - } - - /** - * Stops the autorotate animation - * @return (void) - **/ - - var stopAutorotate = function() { - clearTimeout(anim_timeout); - anim_timeout = null; - - clearTimeout(autorotate_timeout); - autorotate_timeout = null; - - triggerAction('autorotate', false); - } - - /** - * Launches/stops the autorotate animation - * @return (void) - **/ - - this.toggleAutorotate = function() { - clearTimeout(anim_timeout); - - if (!!autorotate_timeout) - stopAutorotate(); - - else - startAutorotate(); - } - - /** - * Resizes the canvas to make it fit the container - * @return (void) - **/ - - var fitToContainer = function() { - if (container.clientWidth != viewer_size.width || container.clientHeight != viewer_size.height) { - resize({ - width: container.clientWidth, - height: container.clientHeight - }); - } - } - - /** - * Resizes the canvas - * @param size (Object) New dimensions - * - width (integer) (optional) (previous value) The new canvas width - * - height (integer) (optional) (previous valus) The new canvas height - * @return (void) - **/ - - var resize = function(size) { - viewer_size.width = (size.width !== undefined) ? parseInt(size.width) : viewer_size.width; - viewer_size.height = (size.height !== undefined) ? parseInt(size.height) : viewer_size.height; - viewer_size.ratio = viewer_size.width / viewer_size.height; - - if (!!camera) { - camera.aspect = viewer_size.ratio; - camera.updateProjectionMatrix(); - } - - if (!!renderer) { - renderer.setSize(viewer_size.width, viewer_size.height); - render(); - } - } - - /** - * The user wants to move - * @param evt (Event) The event - * @return (void) - **/ - - var onMouseDown = function(evt) { - startMove(parseInt(evt.clientX), parseInt(evt.clientY)); - } - - /** - * The user wants to move or to zoom (mobile version) - * @param evt (Event) The event - * @return (void) - **/ - - var onTouchStart = function(evt) { - // Move - if (evt.touches.length == 1) { - var touch = evt.touches[0]; - if (touch.target.parentNode == canvas_container) - startMove(parseInt(touch.clientX), parseInt(touch.clientY)); - } - - // Zoom - else if (evt.touches.length == 2) { - onMouseUp(); - - if (evt.touches[0].target.parentNode == canvas_container && evt.touches[1].target.parentNode == canvas_container) - startTouchZoom(dist(evt.touches[0].clientX, evt.touches[0].clientY, evt.touches[1].clientX, evt.touches[1].clientY)); - } - } - - /** - * Initializes the movement - * @param x (integer) Horizontal coordinate - * @param y (integer) Vertical coordinate - * @return (void) - **/ - - var startMove = function(x, y) { - mouse_x = x; - mouse_y = y; - - stopAutorotate(); - - mousedown = true; - } - - /** - * Initializes the "pinch to zoom" action - * @param d (number) Square of the distance between the two fingers - * @return (void) - **/ - - var startTouchZoom = function(d) { - touchzoom_dist = d; - - touchzoom = true; - } - - /** - * The user wants to stop moving (or stop zooming with their finger) - * @param evt (Event) The event - * @return (void) - **/ - - var onMouseUp = function(evt) { - mousedown = false; - touchzoom = false; - } - - /** - * The user moves the image - * @param evt (Event) The event - * @return (void) - **/ - - var onMouseMove = function(evt) { - evt.preventDefault(); - move(parseInt(evt.clientX), parseInt(evt.clientY)); - } - - /** - * The user moves the image (mobile version) - * @param evt (Event) The event - * @return (void) - **/ - - var onTouchMove = function(evt) { - // Move - if (evt.touches.length == 1 && mousedown) { - var touch = evt.touches[0]; - if (touch.target.parentNode == canvas_container) { - evt.preventDefault(); - move(parseInt(touch.clientX), parseInt(touch.clientY)); - } - } - - // Zoom - else if (evt.touches.length == 2) { - if (evt.touches[0].target.parentNode == canvas_container && evt.touches[1].target.parentNode == canvas_container && touchzoom) { - evt.preventDefault(); - - // Calculate the new level of zoom - var d = dist(evt.touches[0].clientX, evt.touches[0].clientY, evt.touches[1].clientX, evt.touches[1].clientY); - var diff = d - touchzoom_dist; - - if (diff != 0) { - var direction = diff / Math.abs(diff); - zoom(zoom_lvl + direction); - - touchzoom_dist = d; - } - } - } - } - - /** - * Movement - * @param x (integer) Horizontal coordinate - * @param y (integer) Vertical coordinate - * @return (void) - **/ - - var move = function(x, y) { - if (mousedown) { - long = getAngleMeasure(long + (x - mouse_x) * PSV_LONG_OFFSET); - lat += (y - mouse_y) * PSV_LAT_OFFSET; - lat = stayBetween(lat, PSV_TILT_DOWN_MAX, PSV_TILT_UP_MAX); - - mouse_x = x; - mouse_y = y; - render(); - } - } - - /** - * The user wants to zoom - * @param evt (Event) The event - * @return (void) - **/ - - var onMouseWheel = function(evt) { - evt.preventDefault(); - evt.stopPropagation(); - - var delta = (evt.detail) ? -evt.detail : evt.wheelDelta; - - if (delta != 0) { - var direction = parseInt(delta / Math.abs(delta)); - zoom(zoom_lvl + direction); - } - } - - /** - * Zoom - * @paramlevel (integer) New zoom level - * @return (void) - **/ - - var zoom = function(level) { - zoom_lvl = stayBetween(parseInt(Math.round(level)), 0, 100); - - camera.fov = PSV_FOV_MAX + (zoom_lvl / 100) * (PSV_FOV_MIN - PSV_FOV_MAX); - camera.updateProjectionMatrix(); - render(); - - triggerAction('zoom-updated', zoom_lvl); - } - - /** - * Zoom (public) - * @param level (integer) New zoom level - * @return (void) - **/ - this.zoom = function(level) { - zoom(level); - } - - /** - * Zoom in - * @return (void) - **/ - - this.zoomIn = function() { - if (zoom_lvl < 100) - zoom(zoom_lvl + 1); - } - - /** - * Zoom out - * @return (void) - **/ - - this.zoomOut = function() { - if (zoom_lvl > 0) - zoom(zoom_lvl - 1); - } - - /** - * Detects whether fullscreen is enabled or not - * @return (boolean) true if fullscreen is enabled, false otherwise - **/ - - var isFullscreenEnabled = function() { - return (!!document.fullscreenElement || !!document.mozFullScreenElement || !!document.webkitFullscreenElement || !!document.msFullscreenElement); - } - - /** - * Fullscreen state has changed - * @return (void) - **/ - - var fullscreenToggled = function() { - // Fix the (weird and ugly) Chrome behavior - if (!!document.webkitFullscreenElement) { - real_viewer_size.width = container.style.width; - real_viewer_size.height = container.style.height; - - container.style.width = '100%'; - container.style.height = '100%'; - fitToContainer(); - } - - else if (!!container.webkitRequestFullscreen) { - container.style.width = real_viewer_size.width; - container.style.height = real_viewer_size.height; - fitToContainer(); - } - - triggerAction('fullscreen-mode', isFullscreenEnabled()); - } - - /** - * Enables/disables fullscreen - * @return (void) - **/ - this.toggleFullscreen = function() { - // Switches to fullscreen mode - if (!isFullscreenEnabled()) { - if (!!container.requestFullscreen) - container.requestFullscreen(); - - else if (!!container.mozRequestFullScreen) - container.mozRequestFullScreen(); - - else if (!!container.webkitRequestFullscreen) - container.webkitRequestFullscreen(); - - else if (!!container.msRequestFullscreen) - container.msRequestFullscreen(); - } - - // Switches to windowed mode - else { - if (!!document.exitFullscreen) - document.exitFullscreen(); - - else if (!!document.mozCancelFullScreen) - document.mozCancelFullScreen(); - - else if (!!document.webkitExitFullscreen) - document.webkitExitFullscreen(); - - else if (!!document.msExitFullscreen) - document.msExitFullscreen(); - } - } - - /** - * Sets the animation speed - * @param speed (string) The speed, in radians/degrees/revolutions per second/minute - * @return (void) - **/ - - var setAnimSpeed = function(speed) { - speed = speed.toString().trim(); - - // Speed extraction - var speed_value = parseFloat(speed.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/, '$1')); - var speed_unit = speed.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/, '$1').trim(); - - // "per minute" -> "per second" - if (speed_unit.match(/(pm|per minute)$/)) - speed_value /= 60; - - var rad_per_second = 0; - - // Which unit? - switch (speed_unit) { - // Revolutions per minute / second - case 'rpm': - case 'rev per minute': - case 'revolutions per minute': - case 'rps': - case 'rev per second': - case 'revolutions per second': - // speed * 2pi - rad_per_second = speed_value * 2 * Math.PI; - break; - - // Degrees per minute / second - case 'dpm': - case 'deg per minute': - case 'degrees per minute': - case 'dps': - case 'deg per second': - case 'degrees per second': - // Degrees to radians (rad = deg * pi / 180) - rad_per_second = speed_value * Math.PI / 180; - break; - - // Radians per minute / second - case 'rad per minute': - case 'radians per minute': - case 'rad per second': - case 'radians per second': - rad_per_second = speed_value; - break; - - // Unknown unit - default: - m_anim = false; - } - - // Longitude offset - long_offset = rad_per_second * PSV_ANIM_TIMEOUT / 1000; - } - - /** - * Sets the viewer size - * @param size (Object) An object containing the wanted width and height - * @return (void) - **/ - - var setNewViewerSize = function(size) { - // Checks all the values - for (dim in size) { - // Only width and height matter - if (dim == 'width' || dim == 'height') { - // Size extraction - var size_str = size[dim].toString().trim(); - - var size_value = parseFloat(size_str.replace(/^([0-9]+(?:\.[0-9]*)?).*$/, '$1')); - var size_unit = size_str.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/, '$1').trim(); - - // Only percentages and pixels are allowed - if (size_unit != '%') - size_unit = 'px'; - - // We're good - new_viewer_size[dim] = { - css: size_value + size_unit, - unit: size_unit - }; - } - } - } - - /** - * Adds an action - * @param name (string) Action name - * @param f (Function) The handler function - * @return (void) - **/ - - this.addAction = function(name, f) { - // New action? - if (!(name in actions)) - actions[name] = []; - - actions[name].push(f); - } - - /** - * Triggers an action - * @param name (string) Action name - * @param arg (mixed) An argument to send to the handler functions - * @return (void) - **/ - - var triggerAction = function(name, arg) { - // Does the action have any function? - if ((name in actions) && actions[name].length > 0) { - for (var i = 0, l = actions[name].length; i < l; ++i) { - if (arg !== undefined) - actions[name][i](arg); - - else - actions[name][i](); - } - } - } - - // Required parameters - if (args === undefined || args.panorama === undefined || args.container === undefined) { - console.log('PhotoSphereViewer: no value given for panorama or container'); - return; - } - - // Movement speed - var PSV_LONG_OFFSET = (args.long_offset !== undefined) ? parseFloat(args.long_offset) : Math.PI / 360.0; - var PSV_LAT_OFFSET = (args.lat_offset !== undefined) ? parseFloat(args.lat_offset) : Math.PI / 180.0; - - // Minimal and maximal fields of view in degrees - var PSV_FOV_MIN = (args.min_fov !== undefined) ? stayBetween(parseFloat(args.min_fov), 1, 179) : 30; - var PSV_FOV_MAX = (args.max_fov !== undefined) ? stayBetween(parseFloat(args.max_fov), 1, 179) : 90; - - // Maximal tilt up / down angles - var PSV_TILT_UP_MAX = (args.tilt_up_max !== undefined) ? parseFloat(args.tilt_up_max) : Math.PI / 2.0; - var PSV_TILT_DOWN_MAX = (args.tilt_down_max !== undefined) ? -parseFloat(args.tilt_down_max) : -Math.PI / 2.0; - - // Default position - var lat = 0, long = 0; - - if (args.default_position !== undefined) { - if (args.default_position.lat !== undefined) - lat = getAngleMeasure(parseFloat(args.default_position.lat)); - - if (args.default_position.long !== undefined) - long = getAngleMeasure(parseFloat(args.default_position.long)); - } - - // Default zoom level - var zoom_lvl = 0; - - if (args.zoom_level !== undefined) - zoom_lvl = stayBetween(parseInt(Math.round(args.zoom_level)), 0, 100); - - // Animation constants - var PSV_FRAMES_PER_SECOND = 60; - var PSV_ANIM_TIMEOUT = 1000 / PSV_FRAMES_PER_SECOND; - - // Delay before the animation - var anim_delay = 2000; - - if (args.time_anim !== undefined) { - if (typeof args.time_anim == 'number' && args.time_anim >= 0) - anim_delay = args.time_anim; - - else - anim_delay = false; - } - - // Deprecated: horizontal offset for the animation - var long_offset = (args.theta_offset !== undefined) ? Math.PI / parseInt(args.theta_offset) : Math.PI / 1440; - - // Horizontal animation speed - if (args.anim_speed !== undefined) - setAnimSpeed(args.anim_speed); - else - setAnimSpeed('2rpm'); - - // Navigation bar - var navbar = new PSVNavBar(this); - - // Must we display the navigation bar? - var display_navbar = (args.navbar !== undefined) ? !!args.navbar : false; - - // Style of the navigation bar - var navbar_style = (args.navbar_style !== undefined) ? args.navbar_style : {}; - - // Container - var container = args.container; - - // Size of the viewer - var viewer_size, new_viewer_size = {}, real_viewer_size = {}; - if (args.size !== undefined) - setNewViewerSize(args.size); - - // Some useful attributes - var panorama = args.panorama; - var root, canvas_container; - var renderer = null, scene = null, camera = null; - var mousedown = false, mouse_x = 0, mouse_y = 0; - var touchzoom = false, touchzoom_dist = 0; - var autorotate_timeout = null, anim_timeout = null; - - var actions = {}; - - // Must we read XMP data? - var readxmp = (args.usexmpdata !== undefined) ? !!args.usexmpdata : true; - - // Loading indicator - var loading_img = (args.loading_img !== undefined) ? args.loading_img : null; - - // Function to call once panorama is ready? - if (args.onready !== undefined) - this.addAction('ready', args.onready); - - // Go? - var autoload = (args.autoload !== undefined) ? !!args.autoload : true; - - if (autoload) - this.load(); -} - -/** - * Navigation bar class - * @param psv (PhotoSphereViewer) A PhotoSphereViewer object - **/ - -var PSVNavBar = function(psv) { - /** - * Checks if a value exists in an array - * @param searched (mixed) The searched value - * @param array (Array) The array - * @return (boolean) true if the value exists in the array, false otherwise - **/ - - var inArray = function(searched, array) { - for (var i = 0, l = array.length; i < l; ++i) { - if (array[i] == searched) - return true; - } - - return false; - } - - /** - * Checks if a property is valid - * @param property (string) The property - * @param value (mixed) The value to check - * @return (boolean) true if the value is valid, false otherwise - **/ - - var checkValue = function(property, value) { - return ( - // Color - ( - inArray(property, colors) && (typeof value == 'string') && - ( - value == 'transparent' || - !!value.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/) || - !!value.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/) || - !!value.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/) - ) - ) || - - // Number - (inArray(property, numbers) && !isNaN(parseFloat(value)) && isFinite(value) && value >= 0) - ); - } - - /** - * Sets the style - * @param new_style (object) The properties to change - * @return (void) - **/ - - this.setStyle = function(new_style) { - // Properties to change - for (property in new_style) { - // Is this property a property we'll use? - if ((property in style) && checkValue(property, new_style[property])) - style[property] = new_style[property]; - } - } - - /** - * Creates the elements - * @return (void) - **/ - - this.create = function() { - // Container - container = document.createElement('div'); - container.style.backgroundColor = style.backgroundColor; - - container.style.position = 'absolute'; - container.style.zIndex = 10; - container.style.bottom = 0; - container.style.width = '100%'; - - // Autorotate button - autorotate = new PSVNavBarButton(psv, 'autorotate', style); - container.appendChild(autorotate.getButton()); - - // Zoom buttons - zoom = new PSVNavBarButton(psv, 'zoom', style); - container.appendChild(zoom.getButton()); - - // Fullscreen button - fullscreen = new PSVNavBarButton(psv, 'fullscreen', style); - container.appendChild(fullscreen.getButton()); - } - - /** - * Returns the bar itself - * @return (HTMLElement) The bar - **/ - - this.getBar = function() { - return container; - } - - // Default style - var style = { - // Bar background - backgroundColor: 'rgba(61, 61, 61, 0.5)', - - // Buttons foreground color - buttonsColor: 'rgba(255, 255, 255, 0.7)', - - // Buttons background color - buttonsBackgroundColor: 'transparent', - - // Buttons background color when active - activeButtonsBackgroundColor: 'rgba(255, 255, 255, 0.1)', - - // Buttons height in pixels - buttonsHeight: 20, - - // Autorotate icon thickness in pixels - autorotateThickness: 1, - - // Zoom range width in pixels - zoomRangeWidth: 50, - - // Zoom range thickness in pixels - zoomRangeThickness: 1, - - // Zoom range disk diameter in pixels - zoomRangeDisk: 7, - - // Fullscreen icon ratio - fullscreenRatio: 4 / 3, - - // Fullscreen icon thickness in pixels - fullscreenThickness: 2 - }; - - // Properties types - var colors = ['backgroundColor', 'buttonsColor', 'buttonsBackgroundColor', 'activeButtonsBackgroundColor']; - var numbers = ['buttonsHeight', 'autorotateThickness', 'zoomRangeWidth', 'zoomRangeThickness', 'zoomRangeDisk', 'fullscreenRatio', 'fullscreenThickness']; - - // Some useful attributes - var container; - var arrows, autorotate, zoom, fullscreen; -} - -/** - * Navigation bar button class - * @param psv (PhotoSphereViewer) A PhotoSphereViewer object - * @param type (string) Type of button (arrows) - * @param style (Object) Style of the navigation bar - **/ - -var PSVNavBarButton = function(psv, type, style) { - /** - * Attaches an event handler function to an elemnt - * @param elt (HTMLElement) The element - * @param evt (string) The event name - * @param f (Function) The handler function - * @return (void) - **/ - - var addEvent = function(elt, evt, f) { - if (!!elt.addEventListener) - elt.addEventListener(evt, f, false); - else - elt.attachEvent('on' + evt, f); - } - - /** - * Creates the right button - * @return (void) - **/ - - var create = function() { - switch (type) { - case 'autorotate': - // Autorotate icon sizes - var autorotate_sphere_width = style.buttonsHeight - style.autorotateThickness * 2; - var autorotate_equator_height = autorotate_sphere_width / 10; - - // Autorotate button - button = document.createElement('div'); - button.style.cssFloat = 'left'; - button.style.padding = '10px'; - button.style.width = style.buttonsHeight + 'px'; - button.style.height = style.buttonsHeight + 'px'; - button.style.backgroundColor = style.buttonsBackgroundColor; - button.style.position = 'relative'; - button.style.cursor = 'pointer'; - - addEvent(button, 'click', function(){psv.toggleAutorotate();}); - - var autorotate_sphere = document.createElement('div'); - autorotate_sphere.style.width = autorotate_sphere_width + 'px'; - autorotate_sphere.style.height = autorotate_sphere_width + 'px'; - autorotate_sphere.style.borderRadius = '50%'; - autorotate_sphere.style.border = style.autorotateThickness + 'px solid ' + style.buttonsColor; - button.appendChild(autorotate_sphere); - - var autorotate_equator = document.createElement('div'); - autorotate_equator.style.width = autorotate_sphere_width + 'px'; - autorotate_equator.style.height = autorotate_equator_height + 'px'; - autorotate_equator.style.borderRadius = '50%'; - autorotate_equator.style.border = style.autorotateThickness + 'px solid ' + style.buttonsColor; - autorotate_equator.style.position = 'absolute'; - autorotate_equator.style.top = '50%'; - autorotate_equator.style.marginTop = -(autorotate_equator_height / 2 + style.autorotateThickness) + 'px'; - button.appendChild(autorotate_equator); - - // (In)active - psv.addAction('autorotate', toggleActive); - - break; - - case 'zoom': - // Zoom container - button = document.createElement('div'); - button.style.cssFloat = 'left'; - - // Zoom "-" - var zoom_minus = document.createElement('div'); - zoom_minus.style.cssFloat = 'left'; - zoom_minus.style.padding = '10px'; - zoom_minus.style.height = style.buttonsHeight + 'px'; - zoom_minus.style.backgroundColor = style.buttonsBackgroundColor; - zoom_minus.style.lineHeight = style.buttonsHeight + 'px'; - zoom_minus.style.color = style.buttonsColor; - zoom_minus.style.cursor = 'pointer'; - zoom_minus.textContent = '-'; - - addEvent(zoom_minus, 'click', function(){psv.zoomOut();}); - button.appendChild(zoom_minus); - - // Zoom range - zoom_range_bg = document.createElement('div'); - zoom_range_bg.style.cssFloat = 'left'; - zoom_range_bg.style.padding = (10 + (style.buttonsHeight - style.zoomRangeThickness) / 2) + 'px 5px'; - zoom_range_bg.style.backgroundColor = style.buttonsBackgroundColor; - zoom_range_bg.style.cursor = 'pointer'; - button.appendChild(zoom_range_bg); - - zoom_range = document.createElement('div'); - zoom_range.style.width = style.zoomRangeWidth + 'px'; - zoom_range.style.height = style.zoomRangeThickness + 'px'; - zoom_range.style.backgroundColor = style.buttonsColor; - zoom_range.style.position = 'relative'; - zoom_range_bg.appendChild(zoom_range); - - zoom_value = document.createElement('div'); - zoom_value.style.position = 'absolute'; - zoom_value.style.top = ((style.zoomRangeThickness - style.zoomRangeDisk) / 2) + 'px'; - zoom_value.style.left = -(style.zoomRangeDisk / 2) + 'px'; - zoom_value.style.width = style.zoomRangeDisk + 'px'; - zoom_value.style.height = style.zoomRangeDisk + 'px'; - zoom_value.style.borderRadius = '50%'; - zoom_value.style.backgroundColor = style.buttonsColor; - - psv.addAction('zoom-updated', moveZoomValue); - addEvent(zoom_range_bg, 'mousedown', initZoomChangeWithMouse); - addEvent(zoom_range_bg, 'touchstart', initZoomChangeByTouch); - addEvent(document, 'mousemove', changeZoomWithMouse); - addEvent(document, 'touchmove', changeZoomByTouch); - addEvent(document, 'mouseup', stopZoomChange); - addEvent(document, 'touchend', stopZoomChange); - zoom_range.appendChild(zoom_value); - - // Zoom "+" - var zoom_plus = document.createElement('div'); - zoom_plus.style.cssFloat = 'left'; - zoom_plus.style.padding = '10px'; - zoom_plus.style.height = style.buttonsHeight + 'px'; - zoom_plus.style.backgroundColor = style.buttonsBackgroundColor; - zoom_plus.style.lineHeight = style.buttonsHeight + 'px'; - zoom_plus.style.color = style.buttonsColor; - zoom_plus.style.cursor = 'pointer'; - zoom_plus.textContent = '+'; - - addEvent(zoom_plus, 'click', function(){psv.zoomIn();}); - button.appendChild(zoom_plus); - - break; - - case 'fullscreen': - // Fullscreen icon size - var fullscreen_width = style.buttonsHeight * style.fullscreenRatio; - - var fullscreen_vertical_space = style.buttonsHeight * 0.3; - var fullscreen_vertical_border = (style.buttonsHeight - fullscreen_vertical_space) / 2; - - var fullscreen_horizontal_space = fullscreen_width * 0.3; - var fullscreen_horizontal_border = (fullscreen_width - fullscreen_horizontal_space) / 2 - style.fullscreenThickness; - var fullscreen_vertical_int = style.buttonsHeight - style.fullscreenThickness * 2; - - // Fullscreen button - button = document.createElement('div'); - button.style.cssFloat = 'right'; - button.style.padding = '10px'; - button.style.width = fullscreen_width; - button.style.height = style.buttonsHeight; - button.style.backgroundColor = style.buttonsBackgroundColor; - button.style.cursor = 'pointer'; - - addEvent(button, 'click', function(){psv.toggleFullscreen();}) - - // Fullscreen icon left side - var fullscreen_left = document.createElement('div'); - fullscreen_left.style.cssFloat = 'left'; - fullscreen_left.style.width = style.fullscreenThickness + 'px'; - fullscreen_left.style.height = fullscreen_vertical_space + 'px'; - fullscreen_left.style.borderStyle = 'solid'; - fullscreen_left.style.borderColor = style.buttonsColor + ' transparent'; - fullscreen_left.style.borderWidth = fullscreen_vertical_border + 'px 0'; - button.appendChild(fullscreen_left); - - // Fullscreen icon top/bottom sides (first half) - var fullscreen_tb_1 = document.createElement('div'); - fullscreen_tb_1.style.cssFloat = 'left'; - fullscreen_tb_1.style.width = fullscreen_horizontal_border + 'px'; - fullscreen_tb_1.style.height = fullscreen_vertical_int + 'px'; - fullscreen_tb_1.style.borderStyle = 'solid'; - fullscreen_tb_1.style.borderColor = style.buttonsColor + ' transparent'; - fullscreen_tb_1.style.borderWidth = style.fullscreenThickness + 'px 0'; - button.appendChild(fullscreen_tb_1); - - // Fullscreen icon top/bottom sides (second half) - var fullscreen_tb_2 = document.createElement('div'); - fullscreen_tb_2.style.cssFloat = 'left'; - fullscreen_tb_2.style.marginLeft = fullscreen_horizontal_space + 'px'; - fullscreen_tb_2.style.width = fullscreen_horizontal_border + 'px'; - fullscreen_tb_2.style.height = fullscreen_vertical_int + 'px'; - fullscreen_tb_2.style.borderStyle = 'solid'; - fullscreen_tb_2.style.borderColor = style.buttonsColor + ' transparent'; - fullscreen_tb_2.style.borderWidth = style.fullscreenThickness + 'px 0'; - button.appendChild(fullscreen_tb_2); - - // Fullscreen icon right side - var fullscreen_right = document.createElement('div'); - fullscreen_right.style.cssFloat = 'left'; - fullscreen_right.style.width = style.fullscreenThickness + 'px'; - fullscreen_right.style.height = fullscreen_vertical_space + 'px'; - fullscreen_right.style.borderStyle = 'solid'; - fullscreen_right.style.borderColor = style.buttonsColor + ' transparent'; - fullscreen_right.style.borderWidth = fullscreen_vertical_border + 'px 0'; - button.appendChild(fullscreen_right); - - var fullscreen_clearer = document.createElement('div'); - fullscreen_clearer.style.clear = 'left'; - button.appendChild(fullscreen_clearer); - - // (In)active - psv.addAction('fullscreen-mode', toggleActive); - - break; - } - } - - /** - * Returns the button element - * @return (HTMLElement) The button - **/ - - this.getButton = function() { - return button; - } - - /** - * Changes the active state of the button - * @param active (boolean) true if the button should be active, false otherwise - * @return (void) - **/ - - var toggleActive = function(active) { - if (active) - button.style.backgroundColor = style.activeButtonsBackgroundColor; - - else - button.style.backgroundColor = style.buttonsBackgroundColor; - } - - /** - * Moves the zoom cursor - * @param level (integer) Zoom level (between 0 and 100) - * @return (void) - **/ - - var moveZoomValue = function(level) { - zoom_value.style.left = (level / 100 * style.zoomRangeWidth - style.zoomRangeDisk / 2) + 'px'; - } - - /** - * The user wants to zoom - * @param evt (Event) The event - * @return (void) - **/ - - var initZoomChangeWithMouse = function(evt) { - initZoomChange(parseInt(evt.clientX)); - } - - /** - * The user wants to zoom (mobile version) - * @param evt (Event) The event - * @return (void) - **/ - - var initZoomChangeByTouch = function(evt) { - var touch = evt.touches[0]; - if (touch.target == zoom_range_bg || touch.target == zoom_range || touch.target == zoom_value) - initZoomChange(parseInt(touch.clientX)); - } - - /** - * Initializes a zoom change - * @param x (integer) Horizontal coordinate - * @return (void) - **/ - - var initZoomChange = function(x) { - mousedown = true; - changeZoom(x); - } - - /** - * The user wants to stop zooming - * @param evt (Event) The event - * @return (void) - **/ - - var stopZoomChange = function(evt) { - mousedown = false; - } - - /** - * The user moves the zoom cursor - * @param evt (Event) The event - * @return (void) - **/ - - var changeZoomWithMouse = function(evt) { - evt.preventDefault(); - changeZoom(parseInt(evt.clientX)); - } - - /** - * The user moves the zoom cursor (mobile version) - * @param evt (Event) The event - * @return (void) - **/ - - var changeZoomByTouch = function(evt) { - var touch = evt.touches[0]; - if (touch.target == zoom_range_bg || touch.target == zoom_range || touch.target == zoom_value) { - evt.preventDefault(); - changeZoom(parseInt(touch.clientX)); - } - } - - /** - * Zoom change - * @param x (integer) Horizontal coordinate - * @return (void) - **/ - - var changeZoom = function(x) { - if (mousedown) { - var user_input = x - zoom_range.getBoundingClientRect().left; - var zoom_level = user_input / style.zoomRangeWidth * 100; - psv.zoom(zoom_level); - } - } - - // Some useful attributes - var zoom_range_bg, zoom_range, zoom_value; - var mousedown = false; - - // Create the button - var button; - create(); -} diff --git a/lib/photo-sphere-viewer.min.js b/lib/photo-sphere-viewer.min.js new file mode 100644 index 0000000..4cd19fd --- /dev/null +++ b/lib/photo-sphere-viewer.min.js @@ -0,0 +1 @@ +var PhotoSphereViewer=function(e){var t=function(){var e=document.createElement("canvas");return!(!e.getContext||!e.getContext("2d"))},o=function(){var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl"))},n=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},i=function(e,t,o){return Math.max(t,Math.min(o,e))},r=function(e,t,o,n){var i=o-e,r=n-t;return i*i+r*r},a=function(e){return e-2*Math.floor(e/(2*Math.PI))*Math.PI};this.load=function(){if(Se){var e=document.createElement("img");e.setAttribute("src",Se),e.setAttribute("alt",Re),se.appendChild(e)}else se.textContent=Re;return ce=document.createElement("div"),ce.style.width="100%",ce.style.height="100%",ce.style.position="relative",ce.style.overflow="hidden",t()?void 0===window.THREE?void console.log("PhotoSphereViewer: Three.js is not loaded."):(ae={width:0,height:0,ratio:0},void(Te?l():d(!1))):void(se.textContent="Canvas is not supported, update your browser!")};var s=function(e,t){var o=e.indexOf("GPano:"+t)+t.length+8,n=e.indexOf('"',o);return e.substring(o,n)},l=function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else{if(!window.ActiveXObject)return void(se.textContent="XHR is not supported, update your browser!");try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){e=new ActiveXObject("Microsoft.XMLHTTP")}}e.onreadystatechange=function(){if(4==e.readyState&&200==e.status){var t=e.responseText,o=t.indexOf(""),i=t.substring(o,n);if(-1==o||-1==n||-1==i.indexOf("GPano:"))return void d(!1);var r={full_width:parseInt(s(i,"FullPanoWidthPixels")),full_height:parseInt(s(i,"FullPanoHeightPixels")),cropped_width:parseInt(s(i,"CroppedAreaImageWidthPixels")),cropped_height:parseInt(s(i,"CroppedAreaImageHeightPixels")),cropped_x:parseInt(s(i,"CroppedAreaLeftPixels")),cropped_y:parseInt(s(i,"CroppedAreaTopPixels"))};d(r)}},e.open("GET",he,!0),e.send(null)},d=function(e){var t=new Image;t.onload=function(){e||(e={full_width:t.width,full_height:t.height,cropped_width:t.width,cropped_height:t.height,cropped_x:0,cropped_y:0});var n=2048;if(o()){var i=document.createElement("canvas"),r=i.getContext("webgl");n=r.getParameter(r.MAX_TEXTURE_SIZE)}var a=Math.min(e.full_width,n),s=a/e.full_width;e.full_width=a,e.cropped_width*=s,e.cropped_x*=s,t.width=e.cropped_width,e.full_height*=s,e.cropped_height*=s,e.cropped_y*=s,t.height=e.cropped_height;var l=document.createElement("canvas");l.width=e.full_width,l.height=e.full_height;var r=l.getContext("2d");r.drawImage(t,e.cropped_x,e.cropped_y,e.cropped_width,e.cropped_height),c(l.toDataURL("image/jpeg"))},he.match(/^data:image\/[a-z]+;base64/)||t.setAttribute("crossOrigin","anonymous"),t.src=he},c=function(e){var t=new THREE.Texture,o=new THREE.ImageLoader,n=function(e){t.needsUpdate=!0,t.image=e,u(t)};o.load(e,n)},u=function(e){void 0!==le.width&&(se.style.width=le.width.css),void 0!==le.height&&(se.style.height=le.height.css),b(),pe=o()?new THREE.WebGLRenderer:new THREE.CanvasRenderer,pe.setSize(ae.width,ae.height),ge=new THREE.Scene,me=new THREE.PerspectiveCamera(G,ae.ratio,1,300),me.position.set(0,0,0),ge.add(me);var t=new THREE.SphereGeometry(200,32,32),i=new THREE.MeshBasicMaterial({map:e,overdraw:!0}),r=new THREE.Mesh(t,i);r.scale.x=-1,ge.add(r),ue=document.createElement("div"),ue.style.position="absolute",ue.style.zIndex=0,ce.appendChild(ue),ne&&(oe.setStyle(ie),oe.create(),ce.appendChild(oe.getBar())),n(window,"resize",b),re&&(n(ue,"mousedown",x),n(document,"mousemove",T),n(ue,"mousemove",L),n(document,"mouseup",_),n(ue,"touchstart",C),n(document,"touchend",_),n(document,"touchmove",R),n(ue,"mousewheel",z),n(ue,"DOMMouseScroll",z)),n(document,"fullscreenchange",P),n(document,"mozfullscreenchange",P),n(document,"webkitfullscreenchange",P),n(document,"MSFullscreenChange",P),Ee.addListener(M),se.innerHTML="",se.appendChild(ce);var a=pe.domElement;a.style.display="block",ue.appendChild(a),h(),Z>0&&F(Z),m(),N("ready")},h=function(){var e=new THREE.Vector3;e.setX(Math.cos(U)*Math.sin(K)),e.setY(Math.sin(U)),e.setZ(Math.cos(U)*Math.cos(K)),me.lookAt(e),null!==ve?ve.render(ge,me):pe.render(ge,me)},p=function(){ve=new THREE.StereoEffect(pe),ve.eyeSeparation=5,ve.setSize(ae.width,ae.height),I(),O(),oe.mustBeHidden(),h(),N("stereo-effect",!0)},g=function(){ve=null,pe.setSize(ae.width,ae.height),oe.mustBeHidden(!1),h(),N("stereo-effect",!1)};this.toggleStereo=function(){null!==ve?g():p()};var m=function(){ee!==!1&&(ke=setTimeout(f,ee))},v=function(){U-=U/200,K+=te,K-=2*Math.floor(K/(2*Math.PI))*Math.PI,h(),Ce=setTimeout(v,Q)},f=function(){v(),N("autorotate",!0)},y=function(){clearTimeout(ke),ke=null,clearTimeout(Ce),Ce=null,N("autorotate",!1)};this.toggleAutorotate=function(){clearTimeout(ke),Ce?y():f()};var b=function(){(se.clientWidth!=ae.width||se.clientHeight!=ae.height)&&w({width:se.clientWidth,height:se.clientHeight})};this.fitToContainer=function(){b()};var w=function(e){ae.width=void 0!==e.width?parseInt(e.width):ae.width,ae.height=void 0!==e.height?parseInt(e.height):ae.height,ae.ratio=ae.width/ae.height,me&&(me.aspect=ae.ratio,me.updateProjectionMatrix()),pe&&(pe.setSize(ae.width,ae.height),h()),ve&&(ve.setSize(ae.width,ae.height),h())},x=function(e){k(parseInt(e.clientX),parseInt(e.clientY))},C=function(e){if(1==e.touches.length){var t=e.touches[0];t.target.parentNode==ue&&k(parseInt(t.clientX),parseInt(t.clientY))}else 2==e.touches.length&&(_(),e.touches[0].target.parentNode==ue&&e.touches[1].target.parentNode==ue&&E(r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY)));L()},k=function(e,t){ye=e,be=t,y(),fe=!0},E=function(e){xe=e,we=!0},_=function(e){fe=!1,we=!1},T=function(e){e.preventDefault(),S(parseInt(e.clientX),parseInt(e.clientY))},R=function(e){if(1==e.touches.length&&fe){var t=e.touches[0];t.target.parentNode==ue&&(e.preventDefault(),S(parseInt(t.clientX),parseInt(t.clientY)))}else if(2==e.touches.length&&e.touches[0].target.parentNode==ue&&e.touches[1].target.parentNode==ue&&we){e.preventDefault();var o=r(e.touches[0].clientX,e.touches[0].clientY,e.touches[1].clientX,e.touches[1].clientY),n=o-xe;if(0!=n){var i=n/Math.abs(n);F(Z+i),xe=o}}},S=function(e,t){fe&&(K=a(K+(e-ye)*$),U+=(t-be)*V,U=i(U,j,Y),ye=e,be=t,h())},I=function(){Ee.start(),y(),N("device-orientation",!0)},H=function(){Ee.stop(),N("device-orientation",!1)};this.toggleDeviceOrientation=function(){Ee.isEventAttached()?H():I()};var M=function(e){K=e.longitude,U=i(e.latitude,j,Y),h()},z=function(e){e.preventDefault(),e.stopPropagation();var t=e.detail?-e.detail:e.wheelDelta;if(0!=t){var o=parseInt(t/Math.abs(t));F(Z+o)}},F=function(e){Z=i(parseInt(Math.round(e)),0,100),me.fov=G+Z/100*(q-G),me.updateProjectionMatrix(),h(),N("zoom-updated",Z)};this.zoom=function(e){F(e)},this.zoomIn=function(){100>Z&&F(Z+1)},this.zoomOut=function(){Z>0&&F(Z-1)};var B=function(){return!!(document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement)},P=function(){document.webkitFullscreenElement?(de.width=se.style.width,de.height=se.style.height,se.style.width="100%",se.style.height="100%",b()):se.webkitRequestFullscreen&&(se.style.width=de.width,se.style.height=de.height,b()),N("fullscreen-mode",B())},O=function(){se.requestFullscreen?se.requestFullscreen():se.mozRequestFullScreen?se.mozRequestFullScreen():se.webkitRequestFullscreen?se.webkitRequestFullscreen():se.msRequestFullscreen&&se.msRequestFullscreen()},A=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()};this.toggleFullscreen=function(){B()?A():O()};var L=function(){ne&&oe.show()},D=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();o.match(/(pm|per minute)$/)&&(t/=60);var n=0;switch(o){case"rpm":case"rev per minute":case"revolutions per minute":case"rps":case"rev per second":case"revolutions per second":n=2*t*Math.PI;break;case"dpm":case"deg per minute":case"degrees per minute":case"dps":case"deg per second":case"degrees per second":n=t*Math.PI/180;break;case"rad per minute":case"radians per minute":case"rad per second":case"radians per second":n=t;break;default:m_anim=!1}te=n*Q/1e3},X=function(e){e=e.toString().trim();var t=parseFloat(e.replace(/^(-?[0-9]+(?:\.[0-9]*)?).*$/,"$1")),o=e.replace(/^-?[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();return"deg"==o&&(t*=Math.PI/180),a(t)},W=function(e){for(dim in e)if("width"==dim||"height"==dim){var t=e[dim].toString().trim(),o=parseFloat(t.replace(/^([0-9]+(?:\.[0-9]*)?).*$/,"$1")),n=t.replace(/^[0-9]+(?:\.[0-9]*)?(.*)$/,"$1").trim();"%"!=n&&(n="px"),le[dim]={css:o+n,unit:n}}};this.addAction=function(e,t){e in _e||(_e[e]=[]),_e[e].push(t)};var N=function(e,t){if(e in _e&&_e[e].length)for(var o=0,n=_e[e].length;n>o;++o)void 0!==t?_e[e][o](t):_e[e][o]()};if(void 0===e||void 0===e.panorama||void 0===e.container)return void console.log("PhotoSphereViewer: no value given for panorama or container");var $=void 0!==e.long_offset?parseFloat(e.long_offset):Math.PI/360,V=void 0!==e.lat_offset?parseFloat(e.lat_offset):Math.PI/180,q=void 0!==e.min_fov?i(parseFloat(e.min_fov),1,179):30,G=void 0!==e.max_fov?i(parseFloat(e.max_fov),1,179):90,Y=void 0!==e.tilt_up_max?i(X(e.tilt_up_max),0,Math.PI/2):Math.PI/2,j=void 0!==e.tilt_down_max?-i(X(e.tilt_down_max),0,Math.PI/2):-Math.PI/2,U=0,K=0;void 0!==e.default_position&&(void 0!==e.default_position.lat&&(U=i(X(e.default_position.lat),j,Y)),void 0!==e.default_position["long"]&&(K=X(e.default_position["long"])));var Z=0;void 0!==e.zoom_level&&(Z=i(parseInt(Math.round(e.zoom_level)),0,100));var J=60,Q=1e3/J,ee=2e3;void 0!==e.time_anim&&(ee="number"==typeof e.time_anim&&e.time_anim>=0?e.time_anim:!1);var te=void 0!==e.theta_offset?Math.PI/parseInt(e.theta_offset):Math.PI/1440;D(void 0!==e.anim_speed?e.anim_speed:"2rpm");var oe=new PSVNavBar(this),ne=void 0!==e.navbar?!!e.navbar:!1,ie=void 0!==e.navbar_style?e.navbar_style:{},re=void 0!==e.allow_user_interactions?!!e.allow_user_interactions:!0;re||(ne=!1);var ae,se=e.container,le={},de={};void 0!==e.size&&W(e.size);var ce,ue,he=e.panorama,pe=null,ge=null,me=null,ve=null,fe=!1,ye=0,be=0,we=!1,xe=0,Ce=null,ke=null,Ee=new Sphoords,_e={},Te=void 0!==e.usexmpdata?!!e.usexmpdata:!0,Re=void 0!==e.loading_msg?e.loading_msg.toString():"Loading…",Se=void 0!==e.loading_img?e.loading_img.toString():null;void 0!==e.onready&&this.addAction("ready",e.onready);var Ie=void 0!==e.autoload?!!e.autoload:!0;Ie&&this.load()},PSVNavBar=function(e){var t=function(e,t){for(var o=0,n=t.length;n>o;++o)if(t[o]==e)return!0;return!1},o=function(e,o){return t(e,h)&&"string"==typeof o&&("transparent"==o||!!o.match(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/)||!!o.match(/^rgb\((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])(,\s*(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}\)$/)||!!o.match(/^rgba\(((1?[0-9]{1,2}|2[0-4][0-9]|25[0-5]),\s*){3}(0(\.[0-9]*)?|1)\)$/))||t(e,p)&&!isNaN(parseFloat(o))&&isFinite(o)&&o>=0};this.setStyle=function(e){for(property in e)property in u&&o(property,e[property])&&(u[property]=e[property])},this.create=function(){r=document.createElement("div"),r.style.backgroundColor=u.backgroundColor,r.style.position="absolute",r.style.zIndex=10,r.style.bottom=0,r.style.width="100%",r.style.boxSizing="content-box",r.style.transition="bottom 0.4s ease-out",a=new PSVNavBarButton(e,"autorotate",u),r.appendChild(a.getButton()),s=new PSVNavBarButton(e,"zoom",u),r.appendChild(s.getButton()),l=new PSVNavBarButton(e,"fullscreen",u),r.appendChild(l.getButton()),Sphoords.isDeviceOrientationSupported&&(d=new PSVNavBarButton(e,"orientation",u),r.appendChild(d.getButton()),c=new PSVNavBarButton(e,"virtual-reality",u),r.appendChild(c.getButton()))},this.getBar=function(){return r};var n=function(){g&&(clearTimeout(g),!m&&v&&(g=setTimeout(i,5e3))),m&&(r.style.bottom=0,m=!1,v&&(g=setTimeout(i,5e3)))};this.show=function(){n()};var i=function(){m||(r.style.bottom=-r.offsetHeight+1+"px",m=!0)};this.hide=function(){i()},this.isHidden=function(){return m},this.mustBeHidden=function(e){v=void 0!==e?!!e:!0,v?i():n()};var r,a,s,l,d,c,u={backgroundColor:"rgba(61, 61, 61, 0.5)",buttonsColor:"rgba(255, 255, 255, 0.7)",buttonsBackgroundColor:"transparent",activeButtonsBackgroundColor:"rgba(255, 255, 255, 0.1)",buttonsHeight:20,autorotateThickness:1,zoomRangeWidth:50,zoomRangeThickness:1,zoomRangeDisk:7,fullscreenRatio:4/3,fullscreenThickness:2,gyroscopeThickness:1,virtualRealityRatio:4/3,virtualRealityBorderRadius:2},h=["backgroundColor","buttonsColor","buttonsBackgroundColor","activeButtonsBackgroundColor"],p=["buttonsHeight","autorotateThickness","zoomRangeWidth","zoomRangeThickness","zoomRangeDisk","fullscreenRatio","fullscreenThickness"],g=null,m=!1,v=!1},PSVNavBarButton=function(e,t,o){var n=function(e,t,o){e.addEventListener?e.addEventListener(t,o,!1):e.attachEvent("on"+t,o)},i=function(){switch(t){case"autorotate":var i=o.buttonsHeight-2*o.autorotateThickness,p=i/10;l=document.createElement("div"),l.style.cssFloat="left",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",n(l,"click",function(){e.toggleAutorotate()});var f=document.createElement("div");f.style.width=i+"px",f.style.height=i+"px",f.style.borderRadius="50%",f.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,l.appendChild(f);var y=document.createElement("div");y.style.width=i+"px",y.style.height=p+"px",y.style.borderRadius="50%",y.style.border=o.autorotateThickness+"px solid "+o.buttonsColor,y.style.position="absolute",y.style.top="50%",y.style.marginTop=-(p/2+o.autorotateThickness)+"px",l.appendChild(y),e.addAction("autorotate",d);break;case"zoom":l=document.createElement("div"),l.style.cssFloat="left";var b=document.createElement("div");b.style.cssFloat="left",b.style.padding="10px",b.style.height=o.buttonsHeight+"px",b.style.backgroundColor=o.buttonsBackgroundColor,b.style.lineHeight=o.buttonsHeight+"px",b.style.color=o.buttonsColor,b.style.cursor="pointer",b.textContent="-",n(b,"click",function(){e.zoomOut()}),l.appendChild(b),r=document.createElement("div"),r.style.cssFloat="left",r.style.padding=10+(o.buttonsHeight-o.zoomRangeThickness)/2+"px 5px",r.style.backgroundColor=o.buttonsBackgroundColor,r.style.cursor="pointer",l.appendChild(r),a=document.createElement("div"),a.style.width=o.zoomRangeWidth+"px",a.style.height=o.zoomRangeThickness+"px",a.style.backgroundColor=o.buttonsColor,a.style.position="relative",r.appendChild(a),s=document.createElement("div"),s.style.position="absolute",s.style.top=(o.zoomRangeThickness-o.zoomRangeDisk)/2+"px",s.style.left=-(o.zoomRangeDisk/2)+"px",s.style.width=o.zoomRangeDisk+"px",s.style.height=o.zoomRangeDisk+"px",s.style.borderRadius="50%",s.style.backgroundColor=o.buttonsColor,e.addAction("zoom-updated",c),n(r,"mousedown",u),n(r,"touchstart",h),n(document,"mousemove",m),n(document,"touchmove",v),n(document,"mouseup",g),n(document,"touchend",g),a.appendChild(s);var w=document.createElement("div");w.style.cssFloat="left",w.style.padding="10px",w.style.height=o.buttonsHeight+"px",w.style.backgroundColor=o.buttonsBackgroundColor,w.style.lineHeight=o.buttonsHeight+"px",w.style.color=o.buttonsColor,w.style.cursor="pointer",w.textContent="+",n(w,"click",function(){e.zoomIn()}),l.appendChild(w);break;case"fullscreen":var x=o.buttonsHeight*o.fullscreenRatio,C=.3*o.buttonsHeight,k=(o.buttonsHeight-C)/2,E=.3*x,_=(x-E)/2-o.fullscreenThickness,T=o.buttonsHeight-2*o.fullscreenThickness;l=document.createElement("div"),l.style.cssFloat="right",l.style.padding="10px",l.style.width=x+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",n(l,"click",function(){e.toggleFullscreen()});var R=document.createElement("div");R.style.cssFloat="left",R.style.width=o.fullscreenThickness+"px",R.style.height=C+"px",R.style.borderStyle="solid",R.style.borderColor=o.buttonsColor+" transparent",R.style.borderWidth=k+"px 0",l.appendChild(R);var S=document.createElement("div");S.style.cssFloat="left",S.style.width=_+"px",S.style.height=T+"px",S.style.borderStyle="solid",S.style.borderColor=o.buttonsColor+" transparent",S.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(S);var I=document.createElement("div");I.style.cssFloat="left",I.style.marginLeft=E+"px",I.style.width=_+"px",I.style.height=T+"px",I.style.borderStyle="solid",I.style.borderColor=o.buttonsColor+" transparent",I.style.borderWidth=o.fullscreenThickness+"px 0",l.appendChild(I);var H=document.createElement("div");H.style.cssFloat="left",H.style.width=o.fullscreenThickness+"px",H.style.height=C+"px",H.style.borderStyle="solid",H.style.borderColor=o.buttonsColor+" transparent",H.style.borderWidth=k+"px 0",l.appendChild(H);var M=document.createElement("div");M.style.clear="left",l.appendChild(M),e.addAction("fullscreen-mode",d);break;case"orientation":var z=o.buttonsHeight-2*o.gyroscopeThickness,F=z-4*o.gyroscopeThickness,B=z/10;l=document.createElement("div"),l.style.cssFloat="right",l.style.padding="10px",l.style.width=o.buttonsHeight+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.position="relative",l.style.cursor="pointer",n(l,"click",function(){e.toggleDeviceOrientation()});var P=document.createElement("div");P.style.width=z+"px",P.style.height=z+"px",P.style.borderRadius="50%",P.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,l.appendChild(P);var O=document.createElement("div");O.style.width=F+"px",O.style.height=B+"px",O.style.borderRadius="50%",O.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,O.style.position="absolute",O.style.top="50%",O.style.left="50%",O.style.marginTop=-(B/2+o.gyroscopeThickness)+"px",O.style.marginLeft=-(F/2+o.gyroscopeThickness)+"px",l.appendChild(O);var A=document.createElement("div");A.style.width=B+"px",A.style.height=F+"px",A.style.borderRadius="50%",A.style.border=o.gyroscopeThickness+"px solid "+o.buttonsColor,A.style.position="absolute",A.style.top="50%",A.style.left="50%",A.style.marginTop=-(F/2+o.gyroscopeThickness)+"px",A.style.marginLeft=-(B/2+o.gyroscopeThickness)+"px",l.appendChild(A),e.addAction("device-orientation",d);break;case"virtual-reality":var L=o.buttonsHeight*o.virtualRealityRatio,D=L/4,X=D/2;l=document.createElement("div"),l.style.cssFloat="right",l.style.position="relative",l.style.padding="10px",l.style.width=L+"px",l.style.height=o.buttonsHeight+"px",l.style.backgroundColor=o.buttonsBackgroundColor,l.style.cursor="pointer",n(l,"click",function(){e.toggleStereo()});var W=document.createElement("div");W.style.width=L+"px",W.style.height=o.buttonsHeight+"px",W.style.borderRadius=o.virtualRealityBorderRadius+"px",W.style.backgroundColor=o.buttonsColor,l.appendChild(W);var N=document.createElement("div");N.style.width=D+"px",N.style.height=D+"px",N.style.position="absolute",N.style.top=X+10+"px",N.style.left=X+10+"px",N.style.borderRadius="50%",N.style.backgroundColor=o.backgroundColor,l.appendChild(N);var $=document.createElement("div");$.style.width=D+"px",$.style.height=D+"px",$.style.position="absolute",$.style.top=X+10+"px",$.style.right=X+10+"px",$.style.borderRadius="50%",$.style.backgroundColor=o.backgroundColor,l.appendChild($);var V=document.createElement("div");V.style.width=D+"px",V.style.height=o.buttonsHeight/2+"px",V.style.position="absolute",V.style.left="50%",V.style.bottom="10px",V.style.marginLeft=-(D/2)+"px",V.style.borderTopLeftRadius="50% 60%",V.style.borderTopRightRadius="50% 60%",V.style.backgroundColor=o.backgroundColor,l.appendChild(V),e.addAction("stereo-effect",d)}};this.getButton=function(){return l};var r,a,s,l,d=function(e){e?l.style.backgroundColor=o.activeButtonsBackgroundColor:l.style.backgroundColor=o.buttonsBackgroundColor},c=function(e){s.style.left=e/100*o.zoomRangeWidth-o.zoomRangeDisk/2+"px"},u=function(e){p(parseInt(e.clientX))},h=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&p(parseInt(t.clientX))},p=function(e){y=!0,f(e)},g=function(e){y=!1},m=function(e){e.preventDefault(),f(parseInt(e.clientX))},v=function(e){var t=e.touches[0];(t.target==r||t.target==a||t.target==s)&&(e.preventDefault(),f(parseInt(t.clientX)))},f=function(t){if(y){var n=t-a.getBoundingClientRect().left,i=n/o.zoomRangeWidth*100;e.zoom(i)}},y=!1;i()},Sphoords=function(){var e=function(){var e=navigator.userAgent;return/Gecko\/[0-9.]+/.test(e)?"Gecko":/Chrome\/[0-9.]+/.test(e)?"Blink":/AppleWebKit\/[0-9.]+/.test(e)?"WebKit":/Trident\/[0-9.]+/.test(e)?"Trident":/Opera\/[0-9.]+/.test(e)?"Presto":"Gecko"},t=function(e){return e-360*Math.floor(e/360)};this.start=function(){return Sphoords.isDeviceOrientationSupported?(window.addEventListener("deviceorientation",o,!1),i=!0,!0):(console.log("Device Orientation API not supported"),!1)},this.stop=function(){i&&(window.removeEventListener("deviceorientation",o,!1),i=!1)},this.toggle=function(){i?this.stop():this.start()},this.isEventAttached=function(){return i};var o=function(e){c=Sphoords.getScreenOrientation();var o=0,i=0;switch(c){case"portrait-primary":o=e.alpha+e.gamma,i=e.beta-90;break;case"landscape-primary":if(o=e.alpha+e.beta-90,i=-e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"landscape-secondary":if(o=e.alpha-e.beta+90,i=e.gamma-90,Math.abs(e.beta)>90)switch(u){case"Blink":i+=180;break;case"Gecko":default:i=-i}break;case"portrait-secondary":o=e.alpha-e.gamma,i=180-(e.beta-90),i=270-e.beta}i=t(i),i>=180&&(i-=360),r=t(o),a=Math.max(-90,Math.min(90,i)),s=r*d,l=a*d,n()};this.getCoordinates=function(){return{longitude:s,latitude:l}},this.getCoordinatesInDegrees=function(){return{longitude:r,latitude:a}},this.getScreenOrientation=function(){return c},this.addListener=function(e){h.push(e)};var n=function(){if(h.length)for(var e=0,t=h.length;t>e;++e)h[e]({longitude:s,latitude:l})},i=!1,r=0,a=0,s=0,l=0,d=Math.PI/180,c=Sphoords.getScreenOrientation(),u=e(),h=[]};Sphoords.getScreenOrientation=function(){var e=null;return screen.orientation?e=screen.orientation:screen.mozOrientation?e=screen.mozOrientation:screen.msOrientation&&(e=screen.msOrientation),null!==e&&"object"==typeof e?e.type:e},Sphoords.isDeviceOrientationSupported=!1,function(){function e(t){null!==t&&null!==t.alpha&&(Sphoords.isDeviceOrientationSupported=!0,window.removeEventListener("deviceorientation",e))}window.DeviceOrientationEvent&&null!==Sphoords.getScreenOrientation()&&window.addEventListener("deviceorientation",e)}(); \ No newline at end of file diff --git a/lib/three.min.js b/lib/three.min.js index 95b938c..4e8529f 100644 --- a/lib/three.min.js +++ b/lib/three.min.js @@ -1,737 +1,14 @@ -// three.js / threejs.org/license -'use strict';var THREE={REVISION:"67"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}}; -(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(a,b,c){if(0===b)this.r=this.g=this.b=c;else{var d=function(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a};b=0.5>=c?c*(1+b):c+b-c*b;c=2*c-b;this.r=d(c,b,a+1/3);this.g=d(c,b,a);this.b=d(c,b,a-1/3)}return this},setStyle:function(a){if(/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.test(a))return a=/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.exec(a),this.r=Math.min(255,parseInt(a[1],10))/255,this.g=Math.min(255,parseInt(a[2],10))/255,this.b=Math.min(255,parseInt(a[3],10))/255,this;if(/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.test(a))return a=/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.exec(a),this.r= -Math.min(100,parseInt(a[1],10))/100,this.g=Math.min(100,parseInt(a[2],10))/100,this.b=Math.min(100,parseInt(a[3],10))/100,this;if(/^\#([0-9a-f]{6})$/i.test(a))return a=/^\#([0-9a-f]{6})$/i.exec(a),this.setHex(parseInt(a[1],16)),this;if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a))return a=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(a),this.setHex(parseInt(a[1]+a[1]+a[2]+a[2]+a[3]+a[3],16)),this;if(/^(\w+)$/i.test(a))return this.setHex(THREE.ColorKeywords[a]),this},copy:function(a){this.r=a.r;this.g= -a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);this.b=Math.sqrt(this.b);return this},getHex:function(){return 255*this.r<<16^255*this.g<< -8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){a=a||{h:0,s:0,l:0};var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f,f=0.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cf&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=0.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w= -(d-h)/c,this._x=(a+e)/c,this._y=0.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=0.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize(); -return this},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!== -b?(console.warn("DEPRECATED: Quaternion's .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this.onChangeCallback();return this},multiplyVector3:function(a){console.warn("DEPRECATED: Quaternion's .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."); -return a.applyQuaternion(this)},slerp:function(a,b){var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.acos(g),k=Math.sqrt(1-g*g);if(0.001>Math.abs(k))return this._w=0.5*(f+this._w),this._x=0.5*(c+this._x),this._y=0.5*(d+this._y),this._z=0.5*(e+this._z),this;g=Math.sin((1-b)*h)/k;h=Math.sin(b*h)/k;this._w=f*g+this._w*h;this._x= -c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];this._w=a[3];this.onChangeCallback();return this},toArray:function(){return[this._x,this._y,this._z,this._w]},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){},clone:function(){return new THREE.Quaternion(this._x,this._y, -this._z,this._w)}};THREE.Quaternion.slerp=function(a,b,c,d){return c.copy(a).slerp(b,d)};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; -THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a, -b){if(void 0!==b)return console.warn("DEPRECATED: Vector2's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},sub:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector2's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-= -a.y;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a):this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector2,b=new THREE.Vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y); -return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))}, -distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setLength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a){this.x=a[0];this.y=a[1];return this},toArray:function(){return[this.x,this.y]},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; -THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+ -a);}},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},sub:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), -this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x* -b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===b instanceof THREE.Euler&&console.error("ERROR: Vector3's .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.");void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromEuler(b));return this}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromAxisAngle(b,c));return this}}(), -applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y= -(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;this.normalize();return this}, -divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);this.z>a.z&&(this.z=a.z);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);this.z< -a.z?this.z=a.z:this.z>b.z&&(this.z=b.z);return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z); -return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+ -Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},cross:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector3's .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x= -d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(){var a,b;return function(c){void 0===a&&(a=new THREE.Vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a; -return function(b){void 0===a&&(a=new THREE.Vector3);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/(this.length()*a.length());return Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},setEulerFromRotationMatrix:function(a,b){console.error("REMOVED: Vector3's setEulerFromRotationMatrix has been removed in favor of Euler.setFromRotationMatrix(), please update your code.")}, -setEulerFromQuaternion:function(a,b){console.error("REMOVED: Vector3's setEulerFromQuaternion: has been removed in favor of Euler.setFromQuaternion(), please update your code.")},getPositionFromMatrix:function(a){console.warn("DEPRECATED: Vector3's .getPositionFromMatrix() has been renamed to .setFromMatrixPosition(). Please update your code.");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("DEPRECATED: Vector3's .getScaleFromMatrix() has been renamed to .setFromMatrixScale(). Please update your code."); -return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("DEPRECATED: Vector3's .getColumnFromMatrix() has been renamed to .setFromMatrixColumn(). Please update your code.");return this.setFromMatrixColumn(a,b)},setFromMatrixPosition:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setFromMatrixScale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(); -a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){var c=4*a,d=b.elements;this.x=d[c];this.y=d[c+1];this.z=d[c+2];return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a){this.x=a[0];this.y=a[1];this.z=a[2];return this},toArray:function(){return[this.x,this.y,this.z]},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; -THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x; -case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector4's .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this}, -addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},sub:function(a,b){if(void 0!==b)return console.warn("DEPRECATED: Vector4's .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this}, -applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a):(this.z=this.y=this.x=0,this.w=1);return this},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b, -this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(0.01>Math.abs(d-g)&&0.01>Math.abs(f-c)&&0.01>Math.abs(k-b)){if(0.1>Math.abs(d+g)&&0.1>Math.abs(f+c)&&0.1>Math.abs(k+b)&&0.1>Math.abs(e+h+l-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;l=(l+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>l?0.01>e?(b=0,d=c=0.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>l?0.01> -h?(b=0.707106781,c=0,d=0.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):0.01>l?(c=b=0.707106781,d=0):(d=Math.sqrt(l),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));0.001>Math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+l-1)/2);return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);this.z>a.z&&(this.z=a.z);this.w>a.w&&(this.w=a.w);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);this.zb.z&&(this.z=b.z);this.wb.w&&(this.w=b.w);return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector4,b=new THREE.Vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y= -Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z): -Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())}, -setLength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyScalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a){this.x=a[0];this.y=a[1];this.z=a[2];this.w=a[3];return this},toArray:function(){return[this.x,this.y,this.z,this.w]},clone:function(){return new THREE.Vector4(this.x,this.y,this.z, -this.w)}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ"; -THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},copy:function(a){this._x= -a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b){var c=THREE.Math.clamp,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],k=d[5],l=d[9],n=d[2],q=d[6],d=d[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(c(g,-1,1)),0.99999>Math.abs(g)?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-f,e)):(this._x=Math.atan2(q,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-c(l,-1,1)),0.99999>Math.abs(l)?(this._y=Math.atan2(g,d),this._z=Math.atan2(h,k)): -(this._y=Math.atan2(-n,e),this._z=0)):"ZXY"===b?(this._x=Math.asin(c(q,-1,1)),0.99999>Math.abs(q)?(this._y=Math.atan2(-n,d),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,e))):"ZYX"===b?(this._y=Math.asin(-c(n,-1,1)),0.99999>Math.abs(n)?(this._x=Math.atan2(q,d),this._z=Math.atan2(h,e)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(c(h,-1,1)),0.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,e)):(this._x=0,this._y=Math.atan2(g,d))):"XZY"===b?(this._z= -Math.asin(-c(f,-1,1)),0.99999>Math.abs(f)?(this._x=Math.atan2(q,k),this._y=Math.atan2(g,e)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("WARNING: Euler.setFromRotationMatrix() given unsupported order: "+b);this._order=b;this.onChangeCallback();return this},setFromQuaternion:function(a,b,c){var d=THREE.Math.clamp,e=a.x*a.x,f=a.y*a.y,g=a.z*a.z,h=a.w*a.w;b=b||this._order;"XYZ"===b?(this._x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-e-f+g),this._y=Math.asin(d(2*(a.x*a.z+a.y*a.w),-1,1)),this._z=Math.atan2(2* -(a.z*a.w-a.x*a.y),h+e-f-g)):"YXZ"===b?(this._x=Math.asin(d(2*(a.x*a.w-a.y*a.z),-1,1)),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-e-f+g),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-e+f-g)):"ZXY"===b?(this._x=Math.asin(d(2*(a.x*a.w+a.y*a.z),-1,1)),this._y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-e-f+g),this._z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-e+f-g)):"ZYX"===b?(this._x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-e-f+g),this._y=Math.asin(d(2*(a.y*a.w-a.x*a.z),-1,1)),this._z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+e-f-g)):"YZX"=== -b?(this._x=Math.atan2(2*(a.x*a.w-a.z*a.y),h-e+f-g),this._y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+e-f-g),this._z=Math.asin(d(2*(a.x*a.y+a.z*a.w),-1,1))):"XZY"===b?(this._x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-e+f-g),this._y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+e-f-g),this._z=Math.asin(d(2*(a.z*a.w-a.x*a.y),-1,1))):console.warn("WARNING: Euler.setFromQuaternion() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this); -this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(){return[this._x,this._y,this._z,this._order]},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3}; -THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(0.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a, -b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=THREE.Math.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a); -this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)},clone:function(){return(new THREE.Line3).copy(this)}};THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector2(-Infinity,-Infinity)}; -THREE.Box2.prototype={constructor:THREE.Box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){if(0this.max.x&&(this.max.x=b.x),b.ythis.max.y&&(this.max.y=b.y)}else this.makeEmpty();return this},setFromCenterAndSize:function(){var a=new THREE.Vector2;return function(b,c){var d=a.copy(c).multiplyScalar(0.5); -this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},empty:function(){return this.max.xthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x), -(a.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max); -return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new THREE.Box2).copy(this)}};THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector3(-Infinity,-Infinity,-Infinity)}; -THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},addPoint:function(a){a.xthis.max.x&&(this.max.x=a.x);a.ythis.max.y&&(this.max.y=a.y);a.zthis.max.z&&(this.max.z=a.z);return this},setFromPoints:function(a){if(0this.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a, -b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min, -this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new THREE.Vector3;return function(b){b=b||new THREE.Sphere;b.center=this.center();b.radius=0.5*this.size(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]; -return function(b){a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.makeEmpty(); -this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new THREE.Box3).copy(this)}};THREE.Matrix3=function(a,b,c,d,e,f,g,h,k){var l=this.elements=new Float32Array(9);l[0]=void 0!==a?a:1;l[3]=b||0;l[6]=c||0;l[1]=d||0;l[4]=void 0!==e?e:1;l[7]=f||0;l[2]=g||0;l[5]=h||0;l[8]=void 0!==k?k:1}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h,k){var l=this.elements;l[0]=a;l[3]=b;l[6]=c;l[1]=d;l[4]=e;l[7]=f;l[2]=g;l[5]=h;l[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},multiplyVector3:function(a){console.warn("DEPRECATED: Matrix3's .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)}, -multiplyVector3Array:function(a){console.warn("DEPRECATED: Matrix3's .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},applyToVector3Array:function(){var a=new THREE.Vector3;return function(b,c,d){void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ethis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements); -c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a, -b,c,d){a=c*Math.tan(THREE.Math.degToRad(0.5*a));var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,l=f-e;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((f+e)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},fromArray:function(a){this.elements.set(a);return this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11], -a[12],a[13],a[14],a[15]]},clone:function(){var a=this.elements;return new THREE.Matrix4(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15])}};THREE.Ray=function(a,b){this.origin=void 0!==a?a:new THREE.Vector3;this.direction=void 0!==b?b:new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},recast:function(){var a=new THREE.Vector3;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new THREE.Vector3;c.subVectors(a,this.origin); -var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceTo(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceTo(b)}}(),distanceSqToSegment:function(a,b,c,d){var e=a.clone().add(b).multiplyScalar(0.5),f=b.clone().sub(a).normalize(),g=0.5*a.distanceTo(b), -h=this.origin.clone().sub(e);a=-this.direction.dot(f);b=h.dot(this.direction);var k=-h.dot(f),l=h.lengthSq(),n=Math.abs(1-a*a),q,p;0<=n?(h=a*k-b,q=a*b-k,p=g*n,0<=h?q>=-p?q<=p?(g=1/n,h*=g,q*=g,a=h*(h+a*q+2*b)+q*(a*h+q+2*k)+l):(q=g,h=Math.max(0,-(a*q+b)),a=-h*h+q*(q+2*k)+l):(q=-g,h=Math.max(0,-(a*q+b)),a=-h*h+q*(q+2*k)+l):q<=-p?(h=Math.max(0,-(-a*g+b)),q=0a.normal.dot(this.direction)*b?!0:!1},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0==b)return 0==a.distanceToPoint(this.origin)? -0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},isIntersectionBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*= -a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0< -f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}, -clone:function(){return(new THREE.Ray).copy(this)}};THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3;this.radius=void 0!==b?b:0}; -THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<= -this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius); -return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}};THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]}; -THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],q=c[9],p=c[10],s=c[11],t=c[12],r=c[13],v=c[14],c=c[15];b[0].setComponents(f-a,l-g,s-n,c-t).normalize();b[1].setComponents(f+ -a,l+g,s+n,c+t).normalize();b[2].setComponents(f+d,l+h,s+q,c+r).normalize();b[3].setComponents(f-d,l-h,s-q,c-r).normalize();b[4].setComponents(f-e,l-k,s-p,c-v).normalize();b[5].setComponents(f+e,l+k,s+p,c+v).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes, -c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(), -containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0}; -THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d, -c);return this}}(),copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a, -b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},isIntersectionLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0a&&0f||1e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())},sign:function(a){return 0>a?-1:0this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;l=this.points[c[0]];n=this.points[c[1]];q=this.points[c[2]];p=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,n.x,q.x,p.x,g,h,k);d.y=b(l.y,n.y,q.y,p.y,g,h,k);d.z=b(l.z,n.z,q.z,p.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a=b.x+b.y}}(); -THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return 0.5*a.cross(b).length()}}(),midpoint:function(a){return(a|| -new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}, -clone:function(){return(new THREE.Triangle).copy(this)}};THREE.Vertex=function(a){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.");return a};THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}; -THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now();this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(), -a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){}; -THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(a){a.addEventListener=THREE.EventDispatcher.prototype.addEventListener;a.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener;a.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener;a.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&& -c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)?!0:!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=[],d=b.length,e=0;ef.scale.x)return s;s.push({distance:t,point:f.position,face:null,object:f})}else if(f instanceof -a.LOD)d.setFromMatrixPosition(f.matrixWorld),t=n.ray.origin.distanceTo(d),l(f.getObjectForDistance(t),n,s);else if(f instanceof a.Mesh){var r=f.geometry;null===r.boundingSphere&&r.computeBoundingSphere();b.copy(r.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return s;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(null!==r.boundingBox&&!1===c.isIntersectionBox(r.boundingBox))return s;if(r instanceof a.BufferGeometry){var v=f.material;if(void 0=== -v)return s;var w=r.attributes,u,y,L=n.precision;if(void 0!==w.index){var x=w.index.array,N=w.position.array,J=r.offsets;0===J.length&&(J=[{start:0,count:N.length,index:0}]);for(var B=0,K=J.length;Bn.far||s.push({distance:t,point:D,indices:[w,u,y],face:null,faceIndex:null,object:f}))}}else for(N=w.position.array,r=0,G=w.position.array.length;rn.far||s.push({distance:t,point:D,indices:[w,u,y],face:null,faceIndex:null,object:f}))}else if(r instanceof a.Geometry)for(N=f.material instanceof a.MeshFaceMaterial,J=!0===N?f.material.materials:null,L=n.precision,x=r.vertices,B=0,K=r.faces.length;Bn.far||s.push({distance:t,point:D,face:A, -faceIndex:B,object:f}))}}else if(f instanceof a.Line){L=n.linePrecision;v=L*L;r=f.geometry;null===r.boundingSphere&&r.computeBoundingSphere();b.copy(r.boundingSphere);b.applyMatrix4(f.matrixWorld);if(!1===n.ray.isIntersectionSphere(b))return s;e.getInverse(f.matrixWorld);c.copy(n.ray).applyMatrix4(e);if(r instanceof a.Geometry)for(x=r.vertices,L=x.length,w=new a.Vector3,u=new a.Vector3,y=f.type===a.LineStrip?1:2,r=0;rv||(t=c.origin.distanceTo(u),t< -n.near||t>n.far||s.push({distance:t,point:w.clone().applyMatrix4(f.matrixWorld),face:null,faceIndex:null,object:f}))}},n=function(a,b,c){a=a.getDescendants();for(var d=0,e=a.length;de&&0>f||0>g&& -0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z},n=function(a,b,c){if(!0===a.visible||!0===b.visible||!0===c.visible)return!0;E[0]=a.positionScreen; -E[1]=b.positionScreen;E[2]=c.positionScreen;return z.isIntersectionBox(H.setFromPoints(E))},r=function(a,b,c){return 0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*(b.positionScreen.x-a.positionScreen.x)};return{setObject:function(a){f=a;g=f.material;h.getNormalMatrix(f.matrixWorld);d.length=0;e.length=0},projectVertex:k,checkTriangleVisibility:n,checkBackfaceCulling:r,pushVertex:function(b,c,d){l=a();l.position.set(b,c,d); -k(l)},pushNormal:function(a,b,c){d.push(a,b,c)},pushUv:function(a,b){e.push(a,b)},pushLine:function(a,b){var d=q[a],e=q[b];w=c();w.id=f.id;w.v1.copy(d);w.v2.copy(e);w.z=(d.positionScreen.z+e.positionScreen.z)/2;w.material=f.material;K.elements.push(w)},pushTriangle:function(a,c,k){var l=q[a],p=q[c],t=q[k];if(!1!==n(l,p,t)&&(g.side===THREE.DoubleSide||!0===r(l,p,t))){s=b();s.id=f.id;s.v1.copy(l);s.v2.copy(p);s.v3.copy(t);s.z=(l.positionScreen.z+p.positionScreen.z+t.positionScreen.z)/3;for(l=0;3>l;l++)p= -3*arguments[l],t=s.vertexNormalsModel[l],t.set(d[p],d[p+1],d[p+2]),t.applyMatrix3(h).normalize(),p=2*arguments[l],s.uvs[l].set(e[p],e[p+1]);s.vertexNormalsLength=3;s.material=f.material;K.elements.push(s)}}}};this.projectScene=function(f,h,k,l){var r,p,v,y,L,C,z,E;N=u=t=0;K.elements.length=0;!0===f.autoUpdate&&f.updateMatrixWorld();void 0===h.parent&&h.updateMatrixWorld();Q.copy(h.matrixWorldInverse.getInverse(h.matrixWorld));Y.multiplyMatrices(h.projectionMatrix,Q);R.setFromMatrix(Y);g=0;K.objects.length= -0;K.lights.length=0;V(f);!0===k&&K.objects.sort(d);f=0;for(k=K.objects.length;fL;L++)s.uvs[L].copy(ya[L]);s.color=v.color;s.material= -ma;s.z=(ia.positionScreen.z+Z.positionScreen.z+qa.positionScreen.z)/3;K.elements.push(s)}}}}}else if(r instanceof THREE.Line)if(p instanceof THREE.BufferGeometry){if(C=p.attributes,void 0!==C.position){z=C.position.array;p=0;for(y=z.length;p=F.z&&(N===B?(y=new THREE.RenderableSprite,J.push(y),B++,N++,x=y):x=J[N++],x.id=r.id,x.x=F.x*p,x.y=F.y*p,x.z=F.z,x.object=r,x.rotation=r.rotation,x.scale.x=r.scale.x*Math.abs(x.x-(F.x+h.projectionMatrix.elements[0])/(F.w+h.projectionMatrix.elements[12])),x.scale.y=r.scale.y*Math.abs(x.y-(F.y+h.projectionMatrix.elements[5])/ -(F.w+h.projectionMatrix.elements[13])),x.material=r.material,K.elements.push(x)));!0===l&&K.elements.sort(d);return K}};THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=void 0!==f?f:0}; -THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;bb.max.x&&(b.max.x=e);fb.max.y&&(b.max.y=f);gb.max.z&&(b.max.z=g)}}if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){a.makeEmpty();for(var d=this.boundingSphere.center,e=0,f=c.length;eGa?-1:1;h[4*a]=wa.x;h[4*a+1]=wa.y;h[4*a+2]=wa.z;h[4*a+3]=Ia}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array, -e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&(this.attributes.tangent={itemSize:4,array:new Float32Array(4*g)});for(var h=this.attributes.tangent.array,k=[],l=[],n=0;nr;r++)t=a[3*c+r],-1==p[t]?(q[2*r]=t,q[2*r+1]=-1,n++):p[t]k.index+b)for(k={start:f,count:0,index:g},h.push(k),n=0;6>n;n+=2)r=q[n+1],-1n;n+=2)t=q[n],r=q[n+1],-1===r&&(r=g++),p[t]=r,s[r]=t,e[f++]=r-k.index,k.count++}this.reorderBuffers(e,s,g); -return this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;ed?-1:1,e.vertexTangents[c]=new THREE.Vector4(L.x,L.y,L.z,d);this.hasTangents=!0},computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;cd;d++)if(e[d]==e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;cc&&(h[f].counter+=1,g=h[f].hash+"_"+h[f].counter,g in this.geometryGroups||(this.geometryGroups[g]={faces3:[],materialIndex:f,vertices:0,numMorphTargets:k,numMorphNormals:l})),this.geometryGroups[g].faces3.push(d), -this.geometryGroups[g].vertices+=3;this.geometryGroupsList=[];for(var n in this.geometryGroups)this.geometryGroups[n].id=a++,this.geometryGroupsList.push(this.geometryGroups[n])}}(),clone:function(){for(var a=new THREE.Geometry,b=this.vertices,c=0,d=b.length;ca.opacity)h.transparent=a.transparent;void 0!==a.depthTest&&(h.depthTest=a.depthTest);void 0!==a.depthWrite&&(h.depthWrite=a.depthWrite);void 0!==a.visible&&(h.visible=a.visible);void 0!==a.flipSided&&(h.side=THREE.BackSide);void 0!==a.doubleSided&&(h.side=THREE.DoubleSide);void 0!==a.wireframe&& -(h.wireframe=a.wireframe);void 0!==a.vertexColors&&("face"===a.vertexColors?h.vertexColors=THREE.FaceColors:a.vertexColors&&(h.vertexColors=THREE.VertexColors));a.colorDiffuse?h.color=e(a.colorDiffuse):a.DbgColor&&(h.color=a.DbgColor);a.colorSpecular&&(h.specular=e(a.colorSpecular));a.colorAmbient&&(h.ambient=e(a.colorAmbient));a.colorEmissive&&(h.emissive=e(a.colorEmissive));a.transparency&&(h.opacity=a.transparency);a.specularCoef&&(h.shininess=a.specularCoef);a.mapDiffuse&&b&&d(h,"map",a.mapDiffuse, -a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&d(h,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&d(h,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&d(h,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&d(h,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset, -a.mapSpecularWrap,a.mapSpecularAnisotropy);a.mapBumpScale&&(h.bumpScale=a.mapBumpScale);a.mapNormal?(g=THREE.ShaderLib.normalmap,k=THREE.UniformsUtils.clone(g.uniforms),k.tNormal.value=h.normalMap,a.mapNormalFactor&&k.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor),h.map&&(k.tDiffuse.value=h.map,k.enableDiffuse.value=!0),h.specularMap&&(k.tSpecular.value=h.specularMap,k.enableSpecular.value=!0),h.lightMap&&(k.tAO.value=h.lightMap,k.enableAO.value=!0),k.diffuse.value.setHex(h.color),k.specular.value.setHex(h.specular), -k.ambient.value.setHex(h.ambient),k.shininess.value=h.shininess,void 0!==h.opacity&&(k.opacity.value=h.opacity),g=new THREE.ShaderMaterial({fragmentShader:g.fragmentShader,vertexShader:g.vertexShader,uniforms:k,lights:!0,fog:!0}),h.transparent&&(g.transparent=!0)):g=new THREE[g](h);void 0!==a.DbgName&&(g.name=a.DbgName);return g}};THREE.XHRLoader=function(a){this.cache=new THREE.Cache;this.manager=void 0!==a?a:THREE.DefaultLoadingManager}; -THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){var e=this,f=e.cache.get(a);void 0!==f?b(f):(f=new XMLHttpRequest,void 0!==b&&f.addEventListener("load",function(c){e.cache.add(a,c.target.responseText);b(c.target.responseText);e.manager.itemEnd(a)},!1),void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1),void 0!==d&&f.addEventListener("error",function(a){d(a)},!1),void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin),f.open("GET",a,!0),f.send(null),e.manager.itemStart(a))}, -setCrossOrigin:function(a){this.crossOrigin=a}};THREE.ImageLoader=function(a){this.cache=new THREE.Cache;this.manager=void 0!==a?a:THREE.DefaultLoadingManager}; -THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){var e=this,f=e.cache.get(a);if(void 0!==f)b(f);else return f=document.createElement("img"),void 0!==b&&f.addEventListener("load",function(c){e.cache.add(a,this);b(this);e.manager.itemEnd(a)},!1),void 0!==c&&f.addEventListener("progress",function(a){c(a)},!1),void 0!==d&&f.addEventListener("error",function(a){d(a)},!1),void 0!==this.crossOrigin&&(f.crossOrigin=this.crossOrigin),f.src=a,e.manager.itemStart(a),f},setCrossOrigin:function(a){this.crossOrigin= -a}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a);this.withCredentials=!1};THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype);THREE.JSONLoader.prototype.load=function(a,b,c){c=c&&"string"===typeof c?c:this.extractUrlBase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)}; -THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(f.readyState===f.DONE)if(200===f.status||0===f.status){if(f.responseText){var h=JSON.parse(f.responseText);if(void 0!==h.metadata&&"scene"===h.metadata.type){console.error('THREE.JSONLoader: "'+b+'" seems to be a Scene. Use THREE.SceneLoader instead.');return}h=a.parse(h,d);c(h.geometry,h.materials)}else console.error('THREE.JSONLoader: "'+b+'" seems to be unreachable or the file is empty.'); -a.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load \""+b+'" ('+f.status+")");else f.readyState===f.LOADING?e&&(0===g&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):f.readyState===f.HEADERS_RECEIVED&&void 0!==e&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.withCredentials=this.withCredentials;f.send(null)}; -THREE.JSONLoader.prototype.parse=function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/a.scale:1;(function(b){var d,g,h,k,l,n,q,p,s,t,r,v,w,u=a.faces;n=a.vertices;var y=a.normals,L=a.colors,x=0;if(void 0!==a.uvs){for(d=0;dg;g++)p=u[k++],w=v[2*p],p=v[2*p+1],w=new THREE.Vector2(w,p),2!==g&&c.faceVertexUvs[d][h].push(w),0!==g&&c.faceVertexUvs[d][h+1].push(w);q&&(q=3*u[k++],s.normal.set(y[q++],y[q++],y[q]),r.normal.copy(s.normal));if(t)for(d=0;4>d;d++)q=3*u[k++],t=new THREE.Vector3(y[q++], -y[q++],y[q]),2!==d&&s.vertexNormals.push(t),0!==d&&r.vertexNormals.push(t);n&&(n=u[k++],n=L[n],s.color.setHex(n),r.color.setHex(n));if(b)for(d=0;4>d;d++)n=u[k++],n=L[n],2!==d&&s.vertexColors.push(new THREE.Color(n)),0!==d&&r.vertexColors.push(new THREE.Color(n));c.faces.push(s);c.faces.push(r)}else{s=new THREE.Face3;s.a=u[k++];s.b=u[k++];s.c=u[k++];h&&(h=u[k++],s.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)p=u[k++],w=v[2*p],p=v[2*p+1], -w=new THREE.Vector2(w,p),c.faceVertexUvs[d][h].push(w);q&&(q=3*u[k++],s.normal.set(y[q++],y[q++],y[q]));if(t)for(d=0;3>d;d++)q=3*u[k++],t=new THREE.Vector3(y[q++],y[q++],y[q]),s.vertexNormals.push(t);n&&(n=u[k++],s.color.setHex(L[n]));if(b)for(d=0;3>d;d++)n=u[k++],s.vertexColors.push(new THREE.Color(L[n]));c.faces.push(s)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dz.parameters.opacity&&(z.parameters.transparent=!0);z.parameters.normalMap?(G=THREE.ShaderLib.normalmap,C=THREE.UniformsUtils.clone(G.uniforms), -u=z.parameters.color,F=z.parameters.specular,w=z.parameters.ambient,D=z.parameters.shininess,C.tNormal.value=B.textures[z.parameters.normalMap],z.parameters.normalScale&&C.uNormalScale.value.set(z.parameters.normalScale[0],z.parameters.normalScale[1]),z.parameters.map&&(C.tDiffuse.value=z.parameters.map,C.enableDiffuse.value=!0),z.parameters.envMap&&(C.tCube.value=z.parameters.envMap,C.enableReflection.value=!0,C.reflectivity.value=z.parameters.reflectivity),z.parameters.lightMap&&(C.tAO.value=z.parameters.lightMap, -C.enableAO.value=!0),z.parameters.specularMap&&(C.tSpecular.value=B.textures[z.parameters.specularMap],C.enableSpecular.value=!0),z.parameters.displacementMap&&(C.tDisplacement.value=B.textures[z.parameters.displacementMap],C.enableDisplacement.value=!0,C.uDisplacementBias.value=z.parameters.displacementBias,C.uDisplacementScale.value=z.parameters.displacementScale),C.diffuse.value.setHex(u),C.specular.value.setHex(F),C.ambient.value.setHex(w),C.shininess.value=D,z.parameters.opacity&&(C.opacity.value= -z.parameters.opacity),r=new THREE.ShaderMaterial({fragmentShader:G.fragmentShader,vertexShader:G.vertexShader,uniforms:C,lights:!0,fog:!0})):r=new THREE[z.type](z.parameters);r.name=H;B.materials[H]=r}for(H in A.materials)if(z=A.materials[H],z.parameters.materials){E=[];for(u=0;uh.end&&(h.end=e);b||(b=g)}}a.firstAnimation=b}; -THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){this.geometry.animations||(this.geometry.animations={});this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=(c.end-c.start)/b*1E3,this.time=0):console.warn("animation["+a+"] undefined")}; -THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||0>this.time)this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time&&(this.time=0,this.directionBackwards=!1)}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1);a!==this.currentKeyframe&& -(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a);b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b}; -THREE.MorphAnimMesh.prototype.clone=function(a){void 0===a&&(a=new THREE.MorphAnimMesh(this.geometry,this.material));a.duration=this.duration;a.mirroredLoop=this.mirroredLoop;a.time=this.time;a.lastKeyframe=this.lastKeyframe;a.currentKeyframe=this.currentKeyframe;a.direction=this.direction;a.directionBackwards=this.directionBackwards;THREE.Mesh.prototype.clone.call(this,a);return a};THREE.LOD=function(){THREE.Object3D.call(this);this.objects=[]};THREE.LOD.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=0;c=this.objects[d].distance)this.objects[d-1].object.visible=!1,this.objects[d].object.visible=!0;else break;for(;dD&&A.clearRect(Z.min.x|0,Z.min.y|0,Z.max.x-Z.min.x|0,Z.max.y-Z.min.y|0),0R.positionScreen.z||1I.positionScreen.z||1da.positionScreen.z||1=F||(F*=Q.intensity,H.add(Ea.multiplyScalar(F)))):Q instanceof THREE.PointLight&&(D=Da.setFromMatrixPosition(Q.matrixWorld),F=m.dot(Da.subVectors(D,G).normalize()), -0>=F||(F*=0==Q.distance?1:1-Math.min(G.distanceTo(D)/Q.distance,1),0!=F&&(F*=Q.intensity,H.add(Ea.multiplyScalar(F)))));fa.multiply(za).add(Ia);!0===z.wireframe?b(fa,z.wireframeLinewidth,z.wireframeLinecap,z.wireframeLinejoin):c(fa)}else z instanceof THREE.MeshBasicMaterial||z instanceof THREE.MeshLambertMaterial||z instanceof THREE.MeshPhongMaterial?null!==z.map?z.map.mapping instanceof THREE.UVMapping&&(ha=E.uvs,f(V,X,P,ga,wa,Ha,ha[0].x,ha[0].y,ha[1].x,ha[1].y,ha[2].x,ha[2].y,z.map)):null!==z.envMap? -z.envMap.mapping instanceof THREE.SphericalReflectionMapping?(ja.copy(E.vertexNormalsModel[0]).applyMatrix3(ra),Oa=0.5*ja.x+0.5,Ra=0.5*ja.y+0.5,ja.copy(E.vertexNormalsModel[1]).applyMatrix3(ra),Sa=0.5*ja.x+0.5,Fa=0.5*ja.y+0.5,ja.copy(E.vertexNormalsModel[2]).applyMatrix3(ra),ia=0.5*ja.x+0.5,ma=0.5*ja.y+0.5,f(V,X,P,ga,wa,Ha,Oa,Ra,Sa,Fa,ia,ma,z.envMap)):z.envMap.mapping instanceof THREE.SphericalRefractionMapping&&(ja.copy(E.vertexNormalsModel[0]).applyMatrix3(ra),Oa=-0.5*ja.x+0.5,Ra=-0.5*ja.y+0.5, -ja.copy(E.vertexNormalsModel[1]).applyMatrix3(ra),Sa=-0.5*ja.x+0.5,Fa=-0.5*ja.y+0.5,ja.copy(E.vertexNormalsModel[2]).applyMatrix3(ra),ia=-0.5*ja.x+0.5,ma=-0.5*ja.y+0.5,f(V,X,P,ga,wa,Ha,Oa,Ra,Sa,Fa,ia,ma,z.envMap)):(fa.copy(z.color),z.vertexColors===THREE.FaceColors&&fa.multiply(E.color),!0===z.wireframe?b(fa,z.wireframeLinewidth,z.wireframeLinecap,z.wireframeLinejoin):c(fa)):(z instanceof THREE.MeshDepthMaterial?fa.r=fa.g=fa.b=1-r(G.positionScreen.z*G.positionScreen.w,W.near,W.far):z instanceof THREE.MeshNormalMaterial? -(ja.copy(E.normalModel).applyMatrix3(ra),fa.setRGB(ja.x,ja.y,ja.z).multiplyScalar(0.5).addScalar(0.5)):fa.setRGB(1,1,1),!0===z.wireframe?b(fa,z.wireframeLinewidth,z.wireframeLinecap,z.wireframeLinejoin):c(fa))}}Z.union(qa)}}}}};THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tconst float LOG2 = 1.442695;\n\t\tfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\n\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\tuniform samplerCube envMap;\n\tuniform float flipEnvMap;\n\tuniform int combine;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\t\tuniform bool useRefract;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\n\tvec3 reflectVec;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = normalize( vec3( vec4( normal, 0.0 ) * viewMatrix ) );\n\t\tif ( useRefract ) {\n\t\t\treflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t} else { \n\t\t\treflectVec = reflect( cameraToVertex, worldNormal );\n\t\t}\n\t#else\n\t\treflectVec = vReflect;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t\tvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#endif\n\t#ifdef GAMMA_INPUT\n\t\tcubeColor.xyz *= cubeColor.xyz;\n\t#endif\n\tif ( combine == 1 ) {\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n\t} else if ( combine == 2 ) {\n\t\tgl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;\n\t} else {\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n\t}\n#endif", -envmap_pars_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\n\tvarying vec3 vReflect;\n\tuniform float refractionRatio;\n\tuniform bool useRefract;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#endif\n\t#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\t\tvec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );\n\t#endif\n\t#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t#endif\n#endif", -envmap_vertex:"#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP )\n\tvec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\n\tworldNormal = normalize( worldNormal );\n\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\tif ( useRefract ) {\n\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t} else {\n\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t}\n#endif", -map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\n\tgl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n#endif",map_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif", -map_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\t#ifdef GAMMA_INPUT\n\t\ttexelColor.xyz *= texelColor.xyz;\n\t#endif\n\tgl_FragColor = gl_FragColor * texelColor;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tvarying vec2 vUv2;\n\tuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\n\tvarying vec2 vUv2;\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tgl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\n\tvUv2 = uv2;\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif", -normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif", -specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",lights_lambert_pars_vertex:"uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\n\tuniform vec3 wrapRGB;\n#endif", -lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\tvec3 dirVector = normalize( lDirection.xyz );\n\tfloat dotProduct = dot( transformedNormal, dirVector );\n\tvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\t#ifdef DOUBLE_SIDED\n\t\tvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\t\t#ifdef WRAP_AROUND\n\t\t\tvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t#endif\n\t#endif\n\t#ifdef WRAP_AROUND\n\t\tvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\tdirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tdirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n\t\t#endif\n\t#endif\n\tvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n\t#ifdef DOUBLE_SIDED\n\t\tvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n\t#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\t\tlVector = normalize( lVector );\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\t\tvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\t#endif\n\t\t#endif\n\t\t#ifdef WRAP_AROUND\n\t\t\tvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\tpointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\tpointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n\t\t\t#endif\n\t\t#endif\n\t\tvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n\t\t#endif\n\t}\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\t\t\tspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\n\t\t\tfloat lDistance = 1.0;\n\t\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\t\t\tlVector = normalize( lVector );\n\t\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\t\t\tvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\tvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\t\t\t\t#ifdef WRAP_AROUND\n\t\t\t\t\tvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\t\tspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\tspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t\tvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\tvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n\t\t\t#endif\n\t\t}\n\t}\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\tfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\n\t\tvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n\t\t#endif\n\t}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n#ifdef DOUBLE_SIDED\n\tvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n#endif", -lights_phong_pars_vertex:"#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\tvarying vec3 vWorldPosition;\n#endif",lights_phong_vertex:"#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\tvWorldPosition = worldPosition.xyz;\n#endif",lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\tvarying vec3 vWorldPosition;\n#endif\n#ifdef WRAP_AROUND\n\tuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;", -lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\n\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tvec3 pointDiffuse = vec3( 0.0 );\n\tvec3 pointSpecular = vec3( 0.0 );\n\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\t\tlVector = normalize( lVector );\n\t\tfloat dotProduct = dot( normal, lVector );\n\t\t#ifdef WRAP_AROUND\n\t\t\tfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\t\t#else\n\t\t\tfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n\t\t#endif\n\t\tpointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\n\t\tvec3 pointHalfVector = normalize( lVector + viewPosition );\n\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n\t\tfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );\n\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n\t}\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tvec3 spotDiffuse = vec3( 0.0 );\n\tvec3 spotSpecular = vec3( 0.0 );\n\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\t\tfloat lDistance = 1.0;\n\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\t\tlVector = normalize( lVector );\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\t\t\tspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\n\t\t\tfloat dotProduct = dot( normal, lVector );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\t\t\t#else\n\t\t\t\tfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n\t\t\t#endif\n\t\t\tspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\n\t\t\tvec3 spotHalfVector = normalize( lVector + viewPosition );\n\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n\t\t\tfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\t\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );\n\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n\t\t}\n\t}\n#endif\n#if MAX_DIR_LIGHTS > 0\n\tvec3 dirDiffuse = vec3( 0.0 );\n\tvec3 dirSpecular = vec3( 0.0 );\n\tfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\t\tvec3 dirVector = normalize( lDirection.xyz );\n\t\tfloat dotProduct = dot( normal, dirVector );\n\t\t#ifdef WRAP_AROUND\n\t\t\tfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\t\t\tvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n\t\t#else\n\t\t\tfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n\t\t#endif\n\t\tdirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\n\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );\n\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n\t\tfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );\n\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\t}\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tvec3 hemiDiffuse = vec3( 0.0 );\n\tvec3 hemiSpecular = vec3( 0.0 );\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\t\tfloat dotProduct = dot( normal, lVector );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\t\themiDiffuse += diffuse * hemiColor;\n\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n\t\tfloat hemiSpecularWeightSky = specularStrength * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );\n\t\tvec3 lVectorGround = -lVector;\n\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n\t\tfloat hemiSpecularWeightGround = specularStrength * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );\n\t\tfloat dotProductGround = dot( normal, lVectorGround );\n\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );\n\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );\n\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\t}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\n\ttotalDiffuse += dirDiffuse;\n\ttotalSpecular += dirSpecular;\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\ttotalDiffuse += hemiDiffuse;\n\ttotalSpecular += hemiSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\n\ttotalDiffuse += pointDiffuse;\n\ttotalSpecular += pointSpecular;\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\ttotalDiffuse += spotDiffuse;\n\ttotalSpecular += spotSpecular;\n#endif\n#ifdef METAL\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif", -color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tgl_FragColor = gl_FragColor * vec4( vColor, 1.0 );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\t#ifdef GAMMA_INPUT\n\t\tvColor = color * color;\n\t#else\n\t\tvColor = color;\n\t#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneGlobalMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif", -skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\t#ifdef USE_MORPHTARGETS\n\tvec4 skinVertex = vec4( morphed, 1.0 );\n\t#else\n\tvec4 skinVertex = vec4( position, 1.0 );\n\t#endif\n\tvec4 skinned = boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n#endif", -morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\tvec3 morphed = vec3( 0.0 );\n\tmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\tmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\tmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\tmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\tmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\tmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\tmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\tmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n\tmorphed += position;\n#endif", -default_vertex:"vec4 mvPosition;\n#ifdef USE_SKINNING\n\tmvPosition = modelViewMatrix * skinned;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\n\tmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\n\tmvPosition = modelViewMatrix * vec4( position, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tvec3 morphedNormal = vec3( 0.0 );\n\tmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n\tmorphedNormal += normal;\n#endif", -skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = skinWeight.x * boneMatX;\n\tskinMatrix \t+= skinWeight.y * boneMatY;\n\tskinMatrix \t+= skinWeight.z * boneMatZ;\n\tskinMatrix \t+= skinWeight.w * boneMatW;\n\t#ifdef USE_MORPHNORMALS\n\tvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n\t#else\n\tvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n\t#endif\n#endif",defaultnormal_vertex:"vec3 objectNormal;\n#ifdef USE_SKINNING\n\tobjectNormal = skinnedNormal.xyz;\n#endif\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\n\tobjectNormal = morphedNormal;\n#endif\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\n\tobjectNormal = normal;\n#endif\n#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;", -shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\tuniform sampler2D shadowMap[ MAX_SHADOWS ];\n\tuniform vec2 shadowMapSize[ MAX_SHADOWS ];\n\tuniform float shadowDarkness[ MAX_SHADOWS ];\n\tuniform float shadowBias[ MAX_SHADOWS ];\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\tfloat unpackDepth( const in vec4 rgba_depth ) {\n\t\tconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\t\tfloat depth = dot( rgba_depth, bit_shift );\n\t\treturn depth;\n\t}\n#endif", -shadowmap_fragment:"#ifdef USE_SHADOWMAP\n\t#ifdef SHADOWMAP_DEBUG\n\t\tvec3 frustumColors[3];\n\t\tfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\n\t\tfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\n\t\tfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n\t#endif\n\t#ifdef SHADOWMAP_CASCADE\n\t\tint inFrustumCount = 0;\n\t#endif\n\tfloat fDepth;\n\tvec3 shadowColor = vec3( 1.0 );\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\t\tvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\t#ifdef SHADOWMAP_CASCADE\n\t\t\tinFrustumCount += int( inFrustum );\n\t\t\tbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n\t\t#else\n\t\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\t#endif\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t\tshadowCoord.z += shadowBias[ i ];\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\t\tfloat shadow = 0.0;\n\t\t\t\tconst float shadowDelta = 1.0 / 9.0;\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\t\t\t\tfloat dx0 = -1.25 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.25 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.25 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.25 * yPixelOffset;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\t\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\t\tfloat shadow = 0.0;\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\t\t\t\tfloat dx0 = -1.0 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.0 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.0 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.0 * yPixelOffset;\n\t\t\t\tmat3 shadowKernel;\n\t\t\t\tmat3 depthKernel;\n\t\t\t\tdepthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tdepthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tdepthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tdepthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tdepthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tdepthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tdepthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tdepthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tdepthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\t\t\t\tvec3 shadowZ = vec3( shadowCoord.z );\n\t\t\t\tshadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));\n\t\t\t\tshadowKernel[0] *= vec3(0.25);\n\t\t\t\tshadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));\n\t\t\t\tshadowKernel[1] *= vec3(0.25);\n\t\t\t\tshadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));\n\t\t\t\tshadowKernel[2] *= vec3(0.25);\n\t\t\t\tvec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );\n\t\t\t\tshadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );\n\t\t\t\tshadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );\n\t\t\t\tvec4 shadowValues;\n\t\t\t\tshadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );\n\t\t\t\tshadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );\n\t\t\t\tshadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );\n\t\t\t\tshadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );\n\t\t\t\tshadow = dot( shadowValues, vec4( 1.0 ) );\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\t\t\t#else\n\t\t\t\tvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\n\t\t\t\tfloat fDepth = unpackDepth( rgbaDepth );\n\t\t\t\tif ( fDepth < shadowCoord.z )\n\t\t\t\t\tshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n\t\t\t#endif\n\t\t}\n\t\t#ifdef SHADOWMAP_DEBUG\n\t\t\t#ifdef SHADOWMAP_CASCADE\n\t\t\t\tif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n\t\t\t#else\n\t\t\t\tif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n\t\t\t#endif\n\t\t#endif\n\t}\n\t#ifdef GAMMA_OUTPUT\n\t\tshadowColor *= shadowColor;\n\t#endif\n\tgl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", -shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\tuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\t}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\n\tgl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif", -logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max(1e-6, gl_Position.w + 1.0)) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\t#extension GL_EXT_frag_depth : enable\n\t\tvarying float vFragDepth;\n\t#endif\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif"};THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;b dashSize ) {\n\t\tdiscard;\n\t}\n\tgl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.morphtarget_vertex, -THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;\nuniform float mFar;\nuniform float opacity;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\tfloat color = 1.0 - smoothstep( mNear, mFar, depth );\n\tgl_FragColor = vec4( vec3( color ), opacity );\n}"].join("\n")}, -normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vNormal;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );", -THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},normalmap:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null}, -tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new THREE.Vector2(1,1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},diffuse:{type:"c",value:new THREE.Color(16777215)},specular:{type:"c",value:new THREE.Color(1118481)},ambient:{type:"c",value:new THREE.Color(16777215)},shininess:{type:"f",value:30},opacity:{type:"f",value:1},useRefract:{type:"i",value:0},refractionRatio:{type:"f",value:0.98},reflectivity:{type:"f",value:0.5},uOffset:{type:"v2",value:new THREE.Vector2(0, -0)},uRepeat:{type:"v2",value:new THREE.Vector2(1,1)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform bool enableReflection;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform samplerCube tCube;\nuniform vec2 uNormalScale;\nuniform bool useRefract;\nuniform float refractionRatio;\nuniform float reflectivity;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_HEMI_LIGHTS > 0\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#if MAX_SPOT_LIGHTS > 0\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\n\tuniform vec3 wrapRGB;\n#endif\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;", -THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\tgl_FragColor = vec4( vec3( 1.0 ), opacity );\n\tvec3 specularTex = vec3( 1.0 );\n\tvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\n\tnormalTex.xy *= uNormalScale;\n\tnormalTex = normalize( normalTex );\n\tif( enableDiffuse ) {\n\t\t#ifdef GAMMA_INPUT\n\t\t\tvec4 texelColor = texture2D( tDiffuse, vUv );\n\t\t\ttexelColor.xyz *= texelColor.xyz;\n\t\t\tgl_FragColor = gl_FragColor * texelColor;\n\t\t#else\n\t\t\tgl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n\t\t#endif\n\t}\n\tif( enableAO ) {\n\t\t#ifdef GAMMA_INPUT\n\t\t\tvec4 aoColor = texture2D( tAO, vUv );\n\t\t\taoColor.xyz *= aoColor.xyz;\n\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n\t\t#else\n\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n\t\t#endif\n\t}\n\tif( enableSpecular )\n\t\tspecularTex = texture2D( tSpecular, vUv ).xyz;\n\tmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\n\tvec3 finalNormal = tsb * normalTex;\n\t#ifdef FLIP_SIDED\n\t\tfinalNormal = -finalNormal;\n\t#endif\n\tvec3 normal = normalize( finalNormal );\n\tvec3 viewPosition = normalize( vViewPosition );\n\t#if MAX_POINT_LIGHTS > 0\n\t\tvec3 pointDiffuse = vec3( 0.0 );\n\t\tvec3 pointSpecular = vec3( 0.0 );\n\t\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\t\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\t\tvec3 pointVector = lPosition.xyz + vViewPosition.xyz;\n\t\t\tfloat pointDistance = 1.0;\n\t\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\t\tpointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );\n\t\t\tpointVector = normalize( pointVector );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\n\t\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\n\t\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\t\t\t#else\n\t\t\t\tfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n\t\t\t#endif\n\t\t\tpointDiffuse += pointDistance * pointLightColor[ i ] * diffuse * pointDiffuseWeight;\n\t\t\tvec3 pointHalfVector = normalize( pointVector + viewPosition );\n\t\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n\t\t\tfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\t\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( pointVector, pointHalfVector ), 5.0 );\n\t\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;\n\t\t}\n\t#endif\n\t#if MAX_SPOT_LIGHTS > 0\n\t\tvec3 spotDiffuse = vec3( 0.0 );\n\t\tvec3 spotSpecular = vec3( 0.0 );\n\t\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\t\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\t\tvec3 spotVector = lPosition.xyz + vViewPosition.xyz;\n\t\t\tfloat spotDistance = 1.0;\n\t\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\t\tspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );\n\t\t\tspotVector = normalize( spotVector );\n\t\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\t\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\t\t\t\tspotEffect = max( pow( spotEffect, spotLightExponent[ i ] ), 0.0 );\n\t\t\t\t#ifdef WRAP_AROUND\n\t\t\t\t\tfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );\n\t\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );\n\t\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\t\t\t\t#else\n\t\t\t\t\tfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );\n\t\t\t\t#endif\n\t\t\t\tspotDiffuse += spotDistance * spotLightColor[ i ] * diffuse * spotDiffuseWeight * spotEffect;\n\t\t\t\tvec3 spotHalfVector = normalize( spotVector + viewPosition );\n\t\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n\t\t\t\tfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\t\t\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( spotVector, spotHalfVector ), 5.0 );\n\t\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;\n\t\t\t}\n\t\t}\n\t#endif\n\t#if MAX_DIR_LIGHTS > 0\n\t\tvec3 dirDiffuse = vec3( 0.0 );\n\t\tvec3 dirSpecular = vec3( 0.0 );\n\t\tfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\n\t\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\t\t\tvec3 dirVector = normalize( lDirection.xyz );\n\t\t\t#ifdef WRAP_AROUND\n\t\t\t\tfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\n\t\t\t\tfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\n\t\t\t\tvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n\t\t\t#else\n\t\t\t\tfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n\t\t\t#endif\n\t\t\tdirDiffuse += directionalLightColor[ i ] * diffuse * dirDiffuseWeight;\n\t\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );\n\t\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n\t\t\tfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\t\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirVector, dirHalfVector ), 5.0 );\n\t\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\t\t}\n\t#endif\n\t#if MAX_HEMI_LIGHTS > 0\n\t\tvec3 hemiDiffuse = vec3( 0.0 );\n\t\tvec3 hemiSpecular = vec3( 0.0 );\n\t\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\t\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\t\tvec3 lVector = normalize( lDirection.xyz );\n\t\t\tfloat dotProduct = dot( normal, lVector );\n\t\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\t\t\themiDiffuse += diffuse * hemiColor;\n\t\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n\t\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n\t\t\tfloat hemiSpecularWeightSky = specularTex.r * max( pow( hemiDotNormalHalfSky, shininess ), 0.0 );\n\t\t\tvec3 lVectorGround = -lVector;\n\t\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n\t\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n\t\t\tfloat hemiSpecularWeightGround = specularTex.r * max( pow( hemiDotNormalHalfGround, shininess ), 0.0 );\n\t\t\tfloat dotProductGround = dot( normal, lVectorGround );\n\t\t\tfloat specularNormalization = ( shininess + 2.0001 ) / 8.0;\n\t\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVector, hemiHalfVectorSky ), 5.0 );\n\t\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 5.0 );\n\t\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\t\t}\n\t#endif\n\tvec3 totalDiffuse = vec3( 0.0 );\n\tvec3 totalSpecular = vec3( 0.0 );\n\t#if MAX_DIR_LIGHTS > 0\n\t\ttotalDiffuse += dirDiffuse;\n\t\ttotalSpecular += dirSpecular;\n\t#endif\n\t#if MAX_HEMI_LIGHTS > 0\n\t\ttotalDiffuse += hemiDiffuse;\n\t\ttotalSpecular += hemiSpecular;\n\t#endif\n\t#if MAX_POINT_LIGHTS > 0\n\t\ttotalDiffuse += pointDiffuse;\n\t\ttotalSpecular += pointSpecular;\n\t#endif\n\t#if MAX_SPOT_LIGHTS > 0\n\t\ttotalDiffuse += spotDiffuse;\n\t\ttotalSpecular += spotSpecular;\n\t#endif\n\t#ifdef METAL\n\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n\t#else\n\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n\t#endif\n\tif ( enableReflection ) {\n\t\tvec3 vReflect;\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tif ( useRefract ) {\n\t\t\tvReflect = refract( cameraToVertex, normal, refractionRatio );\n\t\t} else {\n\t\t\tvReflect = reflect( cameraToVertex, normal );\n\t\t}\n\t\tvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n\t\t#ifdef GAMMA_INPUT\n\t\t\tcubeColor.xyz *= cubeColor.xyz;\n\t\t#endif\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * reflectivity );\n\t}", -THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\nuniform bool enableDisplacement;\n#ifdef VERTEX_TEXTURES\n\tuniform sampler2D tDisplacement;\n\tuniform float uDisplacementScale;\n\tuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\nvarying vec3 vViewPosition;", -THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,"\t#ifdef USE_SKINNING\n\t\tvNormal = normalize( normalMatrix * skinnedNormal.xyz );\n\t\tvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );\n\t\tvTangent = normalize( normalMatrix * skinnedTangent.xyz );\n\t#else\n\t\tvNormal = normalize( normalMatrix * normal );\n\t\tvTangent = normalize( normalMatrix * tangent.xyz );\n\t#endif\n\tvBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );\n\tvUv = uv * uRepeat + uOffset;\n\tvec3 displacedPosition;\n\t#ifdef VERTEX_TEXTURES\n\t\tif ( enableDisplacement ) {\n\t\t\tvec3 dv = texture2D( tDisplacement, uv ).xyz;\n\t\t\tfloat df = uDisplacementScale * dv.x + uDisplacementBias;\n\t\t\tdisplacedPosition = position + normalize( normal ) * df;\n\t\t} else {\n\t\t\t#ifdef USE_SKINNING\n\t\t\t\tvec4 skinVertex = vec4( position, 1.0 );\n\t\t\t\tvec4 skinned = boneMatX * skinVertex * skinWeight.x;\n\t\t\t\tskinned \t += boneMatY * skinVertex * skinWeight.y;\n\t\t\t\tskinned \t += boneMatZ * skinVertex * skinWeight.z;\n\t\t\t\tskinned \t += boneMatW * skinVertex * skinWeight.w;\n\t\t\t\tdisplacedPosition = skinned.xyz;\n\t\t\t#else\n\t\t\t\tdisplacedPosition = position;\n\t\t\t#endif\n\t\t}\n\t#else\n\t\t#ifdef USE_SKINNING\n\t\t\tvec4 skinVertex = vec4( position, 1.0 );\n\t\t\tvec4 skinned = boneMatX * skinVertex * skinWeight.x;\n\t\t\tskinned \t += boneMatY * skinVertex * skinWeight.y;\n\t\t\tskinned \t += boneMatZ * skinVertex * skinWeight.z;\n\t\t\tskinned \t += boneMatW * skinVertex * skinWeight.w;\n\t\t\tdisplacedPosition = skinned.xyz;\n\t\t#else\n\t\t\tdisplacedPosition = position;\n\t\t#endif\n\t#endif\n\tvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );\n\tvec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;", -THREE.ShaderChunk.logdepthbuf_vertex,"\tvWorldPosition = worldPosition.xyz;\n\tvViewPosition = -mvPosition.xyz;\n\t#ifdef USE_SHADOWMAP\n\t\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\t\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\t\t}\n\t#endif\n}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\tvWorldPosition = worldPosition.xyz;\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", -THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex, -"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[THREE.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main() {", -THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );\n\t#else\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n\t#endif\n}"].join("\n")}};THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){void 0===a.__webglCustomAttributesList&&(a.__webglCustomAttributesList=[]);for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=m.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}} -function c(a,b){var c=b.geometry,g=a.faces3,h=3*g.length,k=1*g.length,l=3*g.length,g=d(b,a),n=f(g),p=e(g),q=g.vertexColors?g.vertexColors:!1;a.__vertexArray=new Float32Array(3*h);p&&(a.__normalArray=new Float32Array(3*h));c.hasTangents&&(a.__tangentArray=new Float32Array(4*h));q&&(a.__colorArray=new Float32Array(3*h));n&&(0p;p++)P.autoScaleCubemaps&&!f?(q=l,u=p,w=c.image[p],y=dc,w.width<=y&&w.height<=y||(A=Math.max(w.width,w.height),v=Math.floor(w.width*y/A),y=Math.floor(w.height*y/A),A=document.createElement("canvas"),A.width=v,A.height=y,A.getContext("2d").drawImage(w,0,0,w.width,w.height,0,0,v,y),w=A),q[u]=w):l[p]=c.image[p];p=l[0];q=THREE.Math.isPowerOfTwo(p.width)&&THREE.Math.isPowerOfTwo(p.height);u=z(c.format);w=z(c.type);D(m.TEXTURE_CUBE_MAP,c,q); -for(p=0;6>p;p++)if(f)for(y=l[p].mipmaps,A=0,L=y.length;A=Cb&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+Cb);Ea+=1;return a}function B(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function K(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function A(a){a!==ua&&(m.lineWidth(a),ua=a)}function G(a,b,c){ya!==a&&(a?m.enable(m.POLYGON_OFFSET_FILL):m.disable(m.POLYGON_OFFSET_FILL),ya=a);!a||Z===b&&qa===c||(m.polygonOffset(b,c),Z=b,qa=c)}function D(a, -b,c){c?(m.texParameteri(a,m.TEXTURE_WRAP_S,z(b.wrapS)),m.texParameteri(a,m.TEXTURE_WRAP_T,z(b.wrapT)),m.texParameteri(a,m.TEXTURE_MAG_FILTER,z(b.magFilter)),m.texParameteri(a,m.TEXTURE_MIN_FILTER,z(b.minFilter))):(m.texParameteri(a,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(a,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(a,m.TEXTURE_MAG_FILTER,F(b.magFilter)),m.texParameteri(a,m.TEXTURE_MIN_FILTER,F(b.minFilter)));db&&b.type!==THREE.FloatType&&(1b;b++)m.deleteFramebuffer(a.__webglFramebuffer[b]),m.deleteRenderbuffer(a.__webglRenderbuffer[b]);else m.deleteFramebuffer(a.__webglFramebuffer),m.deleteRenderbuffer(a.__webglRenderbuffer);P.info.memory.textures--},Sb=function(a){a=a.target;a.removeEventListener("dispose",Sb);Fb(a)},Qb=function(a){void 0!==a.__webglVertexBuffer&& -m.deleteBuffer(a.__webglVertexBuffer);void 0!==a.__webglNormalBuffer&&m.deleteBuffer(a.__webglNormalBuffer);void 0!==a.__webglTangentBuffer&&m.deleteBuffer(a.__webglTangentBuffer);void 0!==a.__webglColorBuffer&&m.deleteBuffer(a.__webglColorBuffer);void 0!==a.__webglUVBuffer&&m.deleteBuffer(a.__webglUVBuffer);void 0!==a.__webglUV2Buffer&&m.deleteBuffer(a.__webglUV2Buffer);void 0!==a.__webglSkinIndicesBuffer&&m.deleteBuffer(a.__webglSkinIndicesBuffer);void 0!==a.__webglSkinWeightsBuffer&&m.deleteBuffer(a.__webglSkinWeightsBuffer); -void 0!==a.__webglFaceBuffer&&m.deleteBuffer(a.__webglFaceBuffer);void 0!==a.__webglLineBuffer&&m.deleteBuffer(a.__webglLineBuffer);void 0!==a.__webglLineDistanceBuffer&&m.deleteBuffer(a.__webglLineDistanceBuffer);if(void 0!==a.__webglCustomAttributesList)for(var b in a.__webglCustomAttributesList)m.deleteBuffer(a.__webglCustomAttributesList[b].buffer);P.info.memory.geometries--},Fb=function(a){var b=a.program;if(void 0!==b){a.program=void 0;var c,d,e=!1;a=0;for(c=ga.length;ad.numSupportedMorphTargets?(p.sort(q),p.length=d.numSupportedMorphTargets):p.length> -d.numSupportedMorphNormals?p.sort(q):0===p.length&&p.push([0,0]);for(n=0;nha;ha++)Fa=U[ha],tb[eb]=Fa.x,tb[eb+1]=Fa.y, -tb[eb+2]=Fa.z,eb+=3;else for(ha=0;3>ha;ha++)tb[eb]=fa.x,tb[eb+1]=fa.y,tb[eb+2]=fa.z,eb+=3;m.bindBuffer(m.ARRAY_BUFFER,x.__webglNormalBuffer);m.bufferData(m.ARRAY_BUFFER,tb,C)}if(xb&&Bb&&N){D=0;for(F=ea.length;Dha;ha++)Ca=V[ha],cb[Ra]=Ca.x,cb[Ra+1]=Ca.y,Ra+=2;0ha;ha++)Da=W[ha],db[Sa]= -Da.x,db[Sa+1]=Da.y,Sa+=2;0f;f++){a.__webglFramebuffer[f]=m.createFramebuffer();a.__webglRenderbuffer[f]=m.createRenderbuffer();m.texImage2D(m.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=m.TEXTURE_CUBE_MAP_POSITIVE_X+f;m.bindFramebuffer(m.FRAMEBUFFER,a.__webglFramebuffer[f]);m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,h,g.__webglTexture,0);C(a.__webglRenderbuffer[f],a)}c&&m.generateMipmap(m.TEXTURE_CUBE_MAP)}else a.__webglFramebuffer=m.createFramebuffer(), -a.__webglRenderbuffer=a.shareDepthFrom?a.shareDepthFrom.__webglRenderbuffer:m.createRenderbuffer(),m.bindTexture(m.TEXTURE_2D,a.__webglTexture),D(m.TEXTURE_2D,a,c),m.texImage2D(m.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=m.TEXTURE_2D,m.bindFramebuffer(m.FRAMEBUFFER,a.__webglFramebuffer),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,d,a.__webglTexture,0),a.shareDepthFrom?a.depthBuffer&&!a.stencilBuffer?m.framebufferRenderbuffer(m.FRAMEBUFFER,m.DEPTH_ATTACHMENT,m.RENDERBUFFER,a.__webglRenderbuffer): -a.depthBuffer&&a.stencilBuffer&&m.framebufferRenderbuffer(m.FRAMEBUFFER,m.DEPTH_STENCIL_ATTACHMENT,m.RENDERBUFFER,a.__webglRenderbuffer):C(a.__webglRenderbuffer,a),c&&m.generateMipmap(m.TEXTURE_2D);b?m.bindTexture(m.TEXTURE_CUBE_MAP,null):m.bindTexture(m.TEXTURE_2D,null);m.bindRenderbuffer(m.RENDERBUFFER,null);m.bindFramebuffer(m.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=Da,a=Ja,d=Ca,e=va);b!==Ha&&(m.bindFramebuffer(m.FRAMEBUFFER, -b),m.viewport(d,e,c,a),Ha=b);ja=c;ra=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format: -THREE.RGBAFormat;this.type=void 0!==c.type?c.type:THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0;this.shareDepthFrom=null}; -THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){this.width=a;this.height=b},clone:function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.anisotropy=this.anisotropy;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;a.generateMipmaps=this.generateMipmaps; -a.shareDepthFrom=this.shareDepthFrom;return a},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLProgram=function(){var a=0;return function(b,c,d,e){var f=b.context,g=d.fragmentShader,h=d.vertexShader,k=d.uniforms,l=d.attributes,n=d.defines,q=d.index0AttributeName;void 0===q&&!0===e.morphTargets&&(q="position");var p="SHADOWMAP_TYPE_BASIC";e.shadowMapType===THREE.PCFShadowMap?p="SHADOWMAP_TYPE_PCF":e.shadowMapType===THREE.PCFSoftShadowMap&&(p="SHADOWMAP_TYPE_PCF_SOFT");var s,t;s=[];for(var r in n)t=n[r],!1!==t&&(t="#define "+r+" "+t,s.push(t));s=s.join("\n");n=f.createProgram();d instanceof -THREE.RawShaderMaterial?b=d="":(d=["precision "+e.precision+" float;","precision "+e.precision+" int;",s,e.supportsVertexTextures?"#define VERTEX_TEXTURES":"",b.gammaInput?"#define GAMMA_INPUT":"",b.gammaOutput?"#define GAMMA_OUTPUT":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SPOT_LIGHTS "+e.maxSpotLights,"#define MAX_HEMI_LIGHTS "+e.maxHemiLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP": -"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.useVertexTexture?"#define BONE_TEXTURE":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals?"#define USE_MORPHNORMALS":"",e.wrapAround?"#define WRAP_AROUND":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED": -"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+p:"",e.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",e.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\n\tattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\n\tattribute vec3 morphTarget0;\n\tattribute vec3 morphTarget1;\n\tattribute vec3 morphTarget2;\n\tattribute vec3 morphTarget3;\n\t#ifdef USE_MORPHNORMALS\n\t\tattribute vec3 morphNormal0;\n\t\tattribute vec3 morphNormal1;\n\t\tattribute vec3 morphNormal2;\n\t\tattribute vec3 morphNormal3;\n\t#else\n\t\tattribute vec3 morphTarget4;\n\t\tattribute vec3 morphTarget5;\n\t\tattribute vec3 morphTarget6;\n\t\tattribute vec3 morphTarget7;\n\t#endif\n#endif\n#ifdef USE_SKINNING\n\tattribute vec4 skinIndex;\n\tattribute vec4 skinWeight;\n#endif\n"].join("\n"), -b=["precision "+e.precision+" float;","precision "+e.precision+" int;",e.bumpMap||e.normalMap?"#extension GL_OES_standard_derivatives : enable":"",s,"#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SPOT_LIGHTS "+e.maxSpotLights,"#define MAX_HEMI_LIGHTS "+e.maxHemiLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",b.gammaInput?"#define GAMMA_INPUT":"",b.gammaOutput?"#define GAMMA_OUTPUT":"",e.useFog&&e.fog?"#define USE_FOG": -"",e.useFog&&e.fogExp?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.vertexColors?"#define USE_COLOR":"",e.metal?"#define METAL":"",e.wrapAround?"#define WRAP_AROUND":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled? -"#define "+p:"",e.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",e.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n"));h=new THREE.WebGLShader(f,f.VERTEX_SHADER,d+h);g=new THREE.WebGLShader(f,f.FRAGMENT_SHADER,b+g);f.attachShader(n,h);f.attachShader(n,g);void 0!==q&&f.bindAttribLocation(n,0,q);f.linkProgram(n);!1===f.getProgramParameter(n,f.LINK_STATUS)&&(console.error("Could not initialise shader"), -console.error("gl.VALIDATE_STATUS",f.getProgramParameter(n,f.VALIDATE_STATUS)),console.error("gl.getError()",f.getError()));""!==f.getProgramInfoLog(n)&&console.error("gl.getProgramInfoLog()",f.getProgramInfoLog(n));f.deleteShader(h);f.deleteShader(g);q="viewMatrix modelViewMatrix projectionMatrix normalMatrix modelMatrix cameraPosition morphTargetInfluences".split(" ");e.useVertexTexture?(q.push("boneTexture"),q.push("boneTextureWidth"),q.push("boneTextureHeight")):q.push("boneGlobalMatrices");e.logarithmicDepthBuffer&& -q.push("logDepthBufFC");for(var v in k)q.push(v);k=q;v={};q=0;for(b=k.length;qa?b(c,e-1):l[e]>8&255,l>>16&255,l>>24&255)),e}e.mipmapCount=1;k[2]&131072&&!1!==b&&(e.mipmapCount=Math.max(1,k[7]));e.isCubemap=k[28]&512?!0:!1;e.width=k[4];e.height=k[3];for(var k=k[1]+4,g=e.width,h=e.height,l=e.isCubemap?6:1,q=0;qq-1?0:q-1,s=q+1>e-1?e-1:q+1,t=0>n-1?0:n-1,r=n+1>d-1?d-1:n+1,v=[],w=[0,0,h[4*(q*d+n)]/255*b];v.push([-1,0,h[4*(q*d+t)]/255*b]);v.push([-1,-1,h[4*(p*d+t)]/255*b]);v.push([0,-1,h[4*(p*d+n)]/255*b]);v.push([1,-1,h[4*(p*d+r)]/255*b]);v.push([1,0,h[4*(q*d+r)]/255*b]);v.push([1,1,h[4*(s*d+r)]/255*b]);v.push([0,1,h[4*(s*d+n)]/255*b]);v.push([-1,1,h[4*(s*d+t)]/255*b]);p=[];t=v.length;for(s=0;se)return null;var f=[],g=[],h=[],k,l,n;if(0=q--){console.log("Warning, unable to triangulate polygon!");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);n=l+1;e<=n&&(n=0);var p;a:{var s=p=void 0,t=void 0,r=void 0,v=void 0,w=void 0,u=void 0,y=void 0,L= -void 0,s=a[g[k]].x,t=a[g[k]].y,r=a[g[l]].x,v=a[g[l]].y,w=a[g[n]].x,u=a[g[n]].y;if(1E-10>(r-s)*(u-t)-(v-t)*(w-s))p=!1;else{var x=void 0,N=void 0,J=void 0,B=void 0,K=void 0,A=void 0,G=void 0,D=void 0,C=void 0,F=void 0,C=D=G=L=y=void 0,x=w-r,N=u-v,J=s-w,B=t-u,K=r-s,A=v-t;for(p=0;pk)g=d+1;else if(0b&&(b=0);1=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; -THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb?b=h.x:h.xc?c=h.y:h.yd?d=h.z:h.zMath.abs(d.x-c[0].x)&&1E-10>Math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; -THREE.Path.prototype.toShapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;cl&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y==g.y){if(a.x==g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0==e)return!0;0>e||(d=!d)}}else if(a.y==g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<= -h.x))return!0}return d}var e=function(a){var b,c,d,e,f=[],g=new THREE.Path;b=0;for(c=a.length;bB||B>J)return[];k=l*n-k*q;if(0>k||k>J)return[]}else{if(0d?[]:k==d?f?[]:[g]:a<=d?[g,h]: -[g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return 1E-10f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1; -d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;cF){console.log("Infinite Loop! Holes left:"+ -l.length+", Probably Hole outside Shape!");break}for(q=A;qh;h++)l=k[h].x+":"+k[h].y, -l=n[l],void 0!==l&&(k[h]=l);return q.concat()},isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a, -b)+this.b3p1(a,c)+this.b3p2(a,d)+this.b3p3(a,e)}};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)}; -THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)}; -THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.SplineCurve=function(a){this.points=void 0==a?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,e;e=(d.length-1)*a;a=Math.floor(e);e-=a;c[0]=0==a?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};THREE.EllipseCurve=function(a,b,c,d,e,f,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype); -THREE.EllipseCurve.prototype.getPoint=function(a){var b;b=this.aEndAngle-this.aStartAngle;0>b&&(b+=2*Math.PI);b>2*Math.PI&&(b-=2*Math.PI);b=!0===this.aClockwise?this.aEndAngle+(1-a)*(2*Math.PI-b):this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);b=this.aY+this.yRadius*Math.sin(b);return new THREE.Vector2(a,b)};THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;a*=d.length-1;e=Math.floor(a);a-=e;c[0]=0==e?e:e-1;c[1]=e;c[2]=e>d.length-2?d.length-1:e+1;c[3]=e>d.length-3?d.length-1:e+2;e=d[c[0]];var f=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(e.x,f.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(e.y,f.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(e.z,f.z,g.z,c.z,a);return b});THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=Math.floor(e);e-=a;a+=0a.hierarchy[c].keys[d].time&& -(a.hierarchy[c].keys[d].time=0),void 0!==a.hierarchy[c].keys[d].rot&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=(new THREE.Quaternion).fromArray(h)}if(a.hierarchy[c].keys.length&&void 0!==a.hierarchy[c].keys[0].morphTargets){h={};for(d=0;dd;d++){for(var e=this.keyTypes[d],f=this.data.hierarchy[a].keys[0],g=this.getNextKeyWith(e,a,1);g.timef.index;)f=g,g=this.getNextKeyWith(e,a,g.index+1);c.prevKey[e]=f;c.nextKey[e]=g}}}; -THREE.Animation.prototype.update=function(){var a=[],b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Quaternion,e=function(a,b){var c=[],d=[],e,q,p,s,t,r;e=(a.length-1)*b;q=Math.floor(e);e-=q;c[0]=0===q?q:q-1;c[1]=q;c[2]=q>a.length-2?q:q+1;c[3]=q>a.length-3?q:q+2;q=a[c[0]];s=a[c[1]];t=a[c[2]];r=a[c[3]];c=e*e;p=e*c;d[0]=f(q[0],s[0],t[0],r[0],e,c,p);d[1]=f(q[1],s[1],t[1],r[1],e,c,p);d[2]=f(q[2],s[2],t[2],r[2],e,c,p);return d},f=function(a,b,c,d,e,f,p){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)* -p+(-3*(b-c)-2*a-d)*f+a*e+b};return function(f){if(!1!==this.isPlaying&&(this.currentTime+=f*this.timeScale,0!==this.weight)){var h;f=this.data.length;if(!0===this.loop&&this.currentTime>f)this.currentTime%=f,this.reset();else if(!1===this.loop&&this.currentTime>f){this.stop();return}f=0;for(var k=this.hierarchy.length;fq;q++){h=this.keyTypes[q];var p=n.prevKey[h],s=n.nextKey[h];if(s.time<=this.currentTime){p=this.data.hierarchy[f].keys[0]; -for(s=this.getNextKeyWith(h,f,1);s.timep.index;)p=s,s=this.getNextKeyWith(h,f,s.index+1);n.prevKey[h]=p;n.nextKey[h]=s}l.matrixAutoUpdate=!0;l.matrixWorldNeedsUpdate=!0;var t=(this.currentTime-p.time)/(s.time-p.time),r=p[h],v=s[h];0>t&&(t=0);1a&&(this.currentTime%=a);this.currentTime=Math.min(this.currentTime,a);a=0;for(var b=this.hierarchy.length;af.index;)f=g,g=e[f.index+1];d.prevKey= -f;d.nextKey=g}g.time>=this.currentTime?f.interpolate(g,this.currentTime):f.interpolate(g,g.time);this.data.hierarchy[a].node.updateMatrix();c.matrixWorldNeedsUpdate=!0}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;cthis.duration&&(this.currentTime%=this.duration);this.currentTime=Math.min(this.currentTime,this.duration);c=this.duration/this.frames;var d=Math.floor(this.currentTime/c);d!=b&&(this.mesh.morphTargetInfluences[a]=0,this.mesh.morphTargetInfluences[b]=1,this.mesh.morphTargetInfluences[d]= -0,a=b,b=d);this.mesh.morphTargetInfluences[d]=this.currentTime%c/c;this.mesh.morphTargetInfluences[a]=1-this.mesh.morphTargetInfluences[d]}}}()};THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90, -1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var k=new THREE.PerspectiveCamera(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new THREE.Vector3(0,0,-1));this.add(k);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,p=c.generateMipmaps;c.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace= -2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=p;c.activeCubeFace=5;a.render(b,k,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,e,f,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,f,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype); -THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPerspectiveMode=!0;this.inOrthographicMode=!1}; -THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=!1;this.inOrthographicMode=!0}; -THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){this.inPerspectiveMode?this.toPerspective():(this.toPerspective(),this.toOrthographic())}; -THREE.CombinedCamera.prototype.setLens=function(a,b){void 0===b&&(b=24);var c=2*THREE.Math.radToDeg(Math.atan(b/(2*a)));this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; -THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; -THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,r){var v,w=h.widthSegments,u=h.heightSegments,y=e/2,L=f/2,x=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)v="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)v="y",u=h.depthSegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)v="x",w=h.depthSegments;var N=w+1,J=u+1,B=e/w,K=f/u,A=new THREE.Vector3;A[v]=0=e)return new THREE.Vector2(c,a);e=Math.sqrt(e/2)}else a=!1,1E-10e?-1E-10>g&& -(a=!0):d(f)==d(h)&&(a=!0),a?(c=-f,a=e,e=Math.sqrt(k)):(c=e,a=f,e=Math.sqrt(k/2));return new THREE.Vector2(c/e,a/e)}function e(c,d){var e,f;for(I=c.length;0<=--I;){e=I;f=I-1;0>f&&(f=c.length-1);for(var g=0,h=s+2*n,g=0;gMath.abs(c-k)?[new THREE.Vector2(b,1-e),new THREE.Vector2(d,1-f),new THREE.Vector2(l,1-g),new THREE.Vector2(q,1-a)]:[new THREE.Vector2(c,1-e),new THREE.Vector2(k,1-f),new THREE.Vector2(n,1-g),new THREE.Vector2(p,1-a)]}};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2; -THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);!1===a instanceof Array&&(a=[a]);this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;cc&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new THREE.Vector2(c/2/ -Math.PI+0.5,a.y));return a.clone()}THREE.Geometry.call(this);c=c||1;d=d||0;for(var k=this,l=0,n=a.length;ls&&(0.2>d&&(b[0].x+=1),0.2>a&&(b[1].x+=1),0.2>q&&(b[2].x+=1));l=0;for(n=this.vertices.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}(); -THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=0.2*a);void 0===c&&(c=0.2*b);this.line.scale.set(1,a,1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};THREE.BoxHelper=function(a){var b=[new THREE.Vector3(1,1,1),new THREE.Vector3(-1,1,1),new THREE.Vector3(-1,-1,1),new THREE.Vector3(1,-1,1),new THREE.Vector3(1,1,-1),new THREE.Vector3(-1,1,-1),new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,-1,-1)];this.vertices=b;var c=new THREE.Geometry;c.vertices.push(b[0],b[1],b[1],b[2],b[2],b[3],b[3],b[0],b[4],b[5],b[5],b[6],b[6],b[7],b[7],b[4],b[0],b[4],b[1],b[5],b[2],b[6],b[3],b[7]);THREE.Line.call(this,c,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces); -void 0!==a&&this.update(a)};THREE.BoxHelper.prototype=Object.create(THREE.Line.prototype); -THREE.BoxHelper.prototype.update=function(a){var b=a.geometry;null===b.boundingBox&&b.computeBoundingBox();var c=b.boundingBox.min,b=b.boundingBox.max,d=this.vertices;d[0].set(b.x,b.y,b.z);d[1].set(c.x,b.y,b.z);d[2].set(c.x,c.y,b.z);d[3].set(b.x,c.y,b.z);d[4].set(b.x,b.y,c.z);d[5].set(c.x,b.y,c.z);d[6].set(c.x,c.y,c.z);d[7].set(b.x,c.y,c.z);this.geometry.computeBoundingSphere();this.geometry.verticesNeedUpdate=!0;this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.BoundingBoxHelper=function(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box=new THREE.Box3;THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:c,wireframe:!0}))};THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object);this.box.size(this.scale);this.box.center(this.position)};THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new THREE.Vector3);d.colors.push(new THREE.Color(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new THREE.Geometry,e=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200); -b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);THREE.Line.call(this,d,e,THREE.LinePieces);this.camera=a;this.matrixWorld=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()}; -THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype); -THREE.CameraHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Camera,c=new THREE.Projector;return function(){function d(d,g,h,k){a.set(g,h,k);c.unprojectVector(a,b);d=e.pointMap[d];if(void 0!==d)for(g=0,h=d.length;gt;t++){d[0]=s[g[t]];d[1]=s[g[(t+1)%3]];d.sort(f);var r=d.toString();void 0===e[r]?(e[r]={vert1:d[0],vert2:d[1],face1:q,face2:void 0},n++):e[r].face2=q}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d=h.attributes.position.array; -f=0;for(r in e)if(g=e[r],void 0===g.face2||0.9999>k[g.face1].normal.dot(k[g.face2].normal))n=l[g.vert1],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z,n=l[g.vert2],d[f++]=n.x,d[f++]=n.y,d[f++]=n.z;THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype);THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=new THREE.Geometry;c=0;for(var e=this.object.geometry.faces.length;cb;b++)a.faces[b].color=this.colors[4>b?0:1];b=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0});this.lightSphere=new THREE.Mesh(a,b);this.add(this.lightSphere); -this.update()};THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose();this.lightSphere.material.dispose()}; -THREE.HemisphereLightHelper.prototype.update=function(){var a=new THREE.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity);this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity);this.lightSphere.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate());this.lightSphere.geometry.colorsNeedUpdate=!0}}();THREE.PointLightHelper=function(a,b){this.light=a;this.light.updateMatrixWorld();var c=new THREE.SphereGeometry(b,4,2),d=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);THREE.Mesh.call(this,c,d);this.matrixWorld=this.light.matrixWorld;this.matrixAutoUpdate=!1};THREE.PointLightHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.PointLightHelper.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()}; -THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)};THREE.SkeletonHelper=function(a){for(var b=a.skeleton,c=new THREE.Geometry,d=0;dr;r++){d[0]=t[g[r]];d[1]=t[g[(r+1)%3]];d.sort(f);var v=d.toString();void 0===e[v]&&(q[2*n]=d[0],q[2*n+1]=d[1],e[v]=!0,n++)}h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d= -h.attributes.position.array;p=0;for(s=n;pr;r++)n=k[q[2*p+r]],g=6*p+3*r,d[g+0]=n.x,d[g+1]=n.y,d[g+2]=n.z}else if(a.geometry instanceof THREE.BufferGeometry&&void 0!==a.geometry.attributes.index){for(var k=a.geometry.attributes.position.array,s=a.geometry.attributes.index.array,l=a.geometry.offsets,n=0,q=new Uint32Array(2*s.length),t=0,w=l.length;tr;r++)d[0]=g+s[p+r],d[1]=g+s[p+(r+1)%3],d.sort(f),v=d.toString(), -void 0===e[v]&&(q[2*n]=d[0],q[2*n+1]=d[1],e[v]=!0,n++);h.addAttribute("position",new THREE.Float32Attribute(2*n,3));d=h.attributes.position.array;p=0;for(s=n;pr;r++)g=6*p+3*r,n=3*q[2*p+r],d[g+0]=k[n],d[g+1]=k[n+1],d[g+2]=k[n+2]}else if(a.geometry instanceof THREE.BufferGeometry)for(k=a.geometry.attributes.position.array,n=k.length/3,q=n/3,h.addAttribute("position",new THREE.Float32Attribute(2*n,3)),d=h.attributes.position.array,p=0,s=q;pr;r++)g=18*p+6*r,q=9*p+3*r, -d[g+0]=k[q],d[g+1]=k[q+1],d[g+2]=k[q+2],n=9*p+(r+1)%3*3,d[g+3]=k[n],d[g+4]=k[n+1],d[g+5]=k[n+2];THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:c}),THREE.LinePieces);this.matrixAutoUpdate=!1;this.matrixWorld=a.matrixWorld};THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype);THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this);this.render=function(a){}};THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype); -THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new THREE.Color(16777215));void 0===d&&(d=THREE.NormalBlending);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})}; -THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;ah.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c}; -THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)}; -THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b}; -THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("animation["+a+"] undefined")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1}; -THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight; -f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}};THREE.LensFlarePlugin=function(){function a(a,c){var d=b.createProgram(),e=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER),g="precision "+c+" float;\n";b.shaderSource(e,g+a.fragmentShader);b.shaderSource(f,g+a.vertexShader);b.compileShader(e);b.compileShader(f);b.attachShader(d,e);b.attachShader(d,f);b.linkProgram(d);return d}var b,c,d,e,f,g,h,k,l,n,q,p,s;this.init=function(t){b=t.context;c=t;d=t.getPrecision();e=new Float32Array(16);f=new Uint16Array(6);t=0;e[t++]=-1;e[t++]=-1; -e[t++]=0;e[t++]=0;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=1;e[t++]=-1;e[t++]=1;e[t++]=0;e[t++]=1;t=0;f[t++]=0;f[t++]=1;f[t++]=2;f[t++]=0;f[t++]=2;f[t++]=3;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,e,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);k=b.createTexture();l=b.createTexture();b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16, -0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,l);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE); -b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(n=!1,q=a(THREE.ShaderFlares.lensFlare,d)):(n=!0,q=a(THREE.ShaderFlares.lensFlareVertexTexture,d));p={};s={};p.vertex=b.getAttribLocation(q,"position");p.uv=b.getAttribLocation(q,"uv");s.renderType=b.getUniformLocation(q,"renderType");s.map=b.getUniformLocation(q,"map");s.occlusionMap=b.getUniformLocation(q,"occlusionMap");s.opacity= -b.getUniformLocation(q,"opacity");s.color=b.getUniformLocation(q,"color");s.scale=b.getUniformLocation(q,"scale");s.rotation=b.getUniformLocation(q,"rotation");s.screenPosition=b.getUniformLocation(q,"screenPosition")};this.render=function(a,d,e,f){a=a.__webglFlares;var u=a.length;if(u){var y=new THREE.Vector3,L=f/e,x=0.5*e,N=0.5*f,J=16/f,B=new THREE.Vector2(J*L,J),K=new THREE.Vector3(1,1,0),A=new THREE.Vector2(1,1),G=s,J=p;b.useProgram(q);b.enableVertexAttribArray(p.vertex);b.enableVertexAttribArray(p.uv); -b.uniform1i(G.occlusionMap,0);b.uniform1i(G.map,1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(J.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(J.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var D,C,F,z,H;for(D=0;DL;L++)B[L]=new THREE.Vector3,u[L]=new THREE.Vector3;B=x.shadowCascadeNearZ[y];x=x.shadowCascadeFarZ[y];u[0].set(-1,-1,B);u[1].set(1,-1,B);u[2].set(-1, -1,B);u[3].set(1,1,B);u[4].set(-1,-1,x);u[5].set(1,-1,x);u[6].set(-1,1,x);u[7].set(1,1,x);J.originalCamera=p;u=new THREE.Gyroscope;u.position.copy(r.shadowCascadeOffset);u.add(J);u.add(J.target);p.add(u);r.shadowCascadeArray[w]=J;console.log("Created virtualLight",J)}y=r;B=w;x=y.shadowCascadeArray[B];x.position.copy(y.position);x.target.position.copy(y.target.position);x.lookAt(x.target);x.shadowCameraVisible=y.shadowCameraVisible;x.shadowDarkness=y.shadowDarkness;x.shadowBias=y.shadowCascadeBias[B]; -u=y.shadowCascadeNearZ[B];y=y.shadowCascadeFarZ[B];x=x.pointsFrustum;x[0].z=u;x[1].z=u;x[2].z=u;x[3].z=u;x[4].z=y;x[5].z=y;x[6].z=y;x[7].z=y;N[v]=J;v++}else N[v]=r,v++;s=0;for(t=N.length;sy;y++)B=x[y],B.copy(u[y]),THREE.ShadowMapPlugin.__projector.unprojectVector(B,w),B.applyMatrix4(v.matrixWorldInverse),B.xl.x&&(l.x=B.x),B.yl.y&&(l.y=B.y),B.zl.z&&(l.z=B.z);v.left=k.x;v.right=l.x;v.top=l.y;v.bottom=k.y;v.updateProjectionMatrix()}v=r.shadowMap;u=r.shadowMatrix;w=r.shadowCamera;w.position.setFromMatrixPosition(r.matrixWorld);n.setFromMatrixPosition(r.target.matrixWorld);w.lookAt(n);w.updateMatrixWorld();w.matrixWorldInverse.getInverse(w.matrixWorld);r.cameraHelper&&(r.cameraHelper.visible=r.shadowCameraVisible);r.shadowCameraVisible&&r.cameraHelper.update();u.set(0.5,0,0,0.5,0,0.5,0,0.5, -0,0,0.5,0.5,0,0,0,1);u.multiply(w.projectionMatrix);u.multiply(w.matrixWorldInverse);h.multiplyMatrices(w.projectionMatrix,w.matrixWorldInverse);g.setFromMatrix(h);b.setRenderTarget(v);b.clear();x=q.__webglObjects;r=0;for(v=x.length;r 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -u.compileShader(G);u.compileShader(D);u.attachShader(w,G);u.attachShader(w,D);u.linkProgram(w);K=w;r=u.getAttribLocation(K,"position");v=u.getAttribLocation(K,"uv");a=u.getUniformLocation(K,"uvOffset");b=u.getUniformLocation(K,"uvScale");c=u.getUniformLocation(K,"rotation");d=u.getUniformLocation(K,"scale");e=u.getUniformLocation(K,"color");f=u.getUniformLocation(K,"map");g=u.getUniformLocation(K,"opacity");h=u.getUniformLocation(K,"modelViewMatrix");k=u.getUniformLocation(K,"projectionMatrix");l= -u.getUniformLocation(K,"fogType");n=u.getUniformLocation(K,"fogDensity");q=u.getUniformLocation(K,"fogNear");p=u.getUniformLocation(K,"fogFar");s=u.getUniformLocation(K,"fogColor");t=u.getUniformLocation(K,"alphaTest");w=document.createElement("canvas");w.width=8;w.height=8;G=w.getContext("2d");G.fillStyle="#ffffff";G.fillRect(0,0,w.width,w.height);L=new THREE.Texture(w);L.needsUpdate=!0};this.render=function(A,x,D,C){D=A.__webglSprites;if(C=D.length){u.useProgram(K);u.enableVertexAttribArray(r); -u.enableVertexAttribArray(v);u.disable(u.CULL_FACE);u.enable(u.BLEND);u.bindBuffer(u.ARRAY_BUFFER,J);u.vertexAttribPointer(r,2,u.FLOAT,!1,16,0);u.vertexAttribPointer(v,2,u.FLOAT,!1,16,8);u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,B);u.uniformMatrix4fv(k,!1,x.projectionMatrix.elements);u.activeTexture(u.TEXTURE0);u.uniform1i(f,0);var F=0,z=0,H=A.fog;H?(u.uniform3f(s,H.color.r,H.color.g,H.color.b),H instanceof THREE.Fog?(u.uniform1f(q,H.near),u.uniform1f(p,H.far),u.uniform1i(l,1),z=F=1):H instanceof THREE.FogExp2&& -(u.uniform1f(n,H.density),u.uniform1i(l,2),z=F=2)):(u.uniform1i(l,0),z=F=0);for(var E,N=[],H=0;He?-1:e>0?1:+e}),THREE.log=function(){console.log.apply(console,arguments)},THREE.warn=function(){console.warn.apply(console,arguments)},THREE.error=function(){console.error.apply(console,arguments)},THREE.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},THREE.CullFaceNone=0,THREE.CullFaceBack=1,THREE.CullFaceFront=2,THREE.CullFaceFrontBack=3,THREE.FrontFaceDirectionCW=0,THREE.FrontFaceDirectionCCW=1,THREE.BasicShadowMap=0,THREE.PCFShadowMap=1,THREE.PCFSoftShadowMap=2,THREE.FrontSide=0,THREE.BackSide=1,THREE.DoubleSide=2,THREE.NoShading=0,THREE.FlatShading=1,THREE.SmoothShading=2,THREE.NoColors=0,THREE.FaceColors=1,THREE.VertexColors=2,THREE.NoBlending=0,THREE.NormalBlending=1,THREE.AdditiveBlending=2,THREE.SubtractiveBlending=3,THREE.MultiplyBlending=4,THREE.CustomBlending=5,THREE.AddEquation=100,THREE.SubtractEquation=101,THREE.ReverseSubtractEquation=102,THREE.MinEquation=103,THREE.MaxEquation=104,THREE.ZeroFactor=200,THREE.OneFactor=201,THREE.SrcColorFactor=202,THREE.OneMinusSrcColorFactor=203,THREE.SrcAlphaFactor=204,THREE.OneMinusSrcAlphaFactor=205,THREE.DstAlphaFactor=206,THREE.OneMinusDstAlphaFactor=207,THREE.DstColorFactor=208,THREE.OneMinusDstColorFactor=209,THREE.SrcAlphaSaturateFactor=210,THREE.MultiplyOperation=0,THREE.MixOperation=1,THREE.AddOperation=2,THREE.UVMapping=300,THREE.CubeReflectionMapping=301,THREE.CubeRefractionMapping=302,THREE.EquirectangularReflectionMapping=303,THREE.EquirectangularRefractionMapping=304,THREE.SphericalReflectionMapping=305,THREE.RepeatWrapping=1e3,THREE.ClampToEdgeWrapping=1001,THREE.MirroredRepeatWrapping=1002,THREE.NearestFilter=1003,THREE.NearestMipMapNearestFilter=1004,THREE.NearestMipMapLinearFilter=1005,THREE.LinearFilter=1006,THREE.LinearMipMapNearestFilter=1007,THREE.LinearMipMapLinearFilter=1008,THREE.UnsignedByteType=1009,THREE.ByteType=1010,THREE.ShortType=1011,THREE.UnsignedShortType=1012,THREE.IntType=1013,THREE.UnsignedIntType=1014,THREE.FloatType=1015,THREE.HalfFloatType=1025,THREE.UnsignedShort4444Type=1016,THREE.UnsignedShort5551Type=1017,THREE.UnsignedShort565Type=1018,THREE.AlphaFormat=1019,THREE.RGBFormat=1020,THREE.RGBAFormat=1021,THREE.LuminanceFormat=1022,THREE.LuminanceAlphaFormat=1023,THREE.RGBEFormat=THREE.RGBAFormat,THREE.RGB_S3TC_DXT1_Format=2001,THREE.RGBA_S3TC_DXT1_Format=2002,THREE.RGBA_S3TC_DXT3_Format=2003,THREE.RGBA_S3TC_DXT5_Format=2004,THREE.RGB_PVRTC_4BPPV1_Format=2100,THREE.RGB_PVRTC_2BPPV1_Format=2101,THREE.RGBA_PVRTC_4BPPV1_Format=2102,THREE.RGBA_PVRTC_2BPPV1_Format=2103,THREE.Projector=function(){THREE.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js."),this.projectVector=function(e,t){THREE.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){THREE.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(e,t){THREE.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}},THREE.CanvasRenderer=function(){THREE.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js"),this.domElement=document.createElement("canvas"),this.clear=function(){},this.render=function(){},this.setClearColor=function(){},this.setSize=function(){}},THREE.Color=function(e){return 3===arguments.length?this.setRGB(arguments[0],arguments[1],arguments[2]):this.set(e)},THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,set:function(e){return e instanceof THREE.Color?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(e,t,r){if(0===t)this.r=this.g=this.b=r;else{var i=function(e,t,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?e+6*(t-e)*r:.5>r?t:2/3>r?e+6*(t-e)*(2/3-r):e};t=.5>=r?r*(1+t):r+t-r*t,r=2*r-t,this.r=i(r,t,e+1/3),this.g=i(r,t,e),this.b=i(r,t,e-1/3)}return this},setStyle:function(e){return/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.test(e)?(e=/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.exec(e),this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,this):/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.test(e)?(e=/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.exec(e),this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,this):/^\#([0-9a-f]{6})$/i.test(e)?(e=/^\#([0-9a-f]{6})$/i.exec(e),this.setHex(parseInt(e[1],16)),this):/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(e)?(e=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e),this.setHex(parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3],16)),this):/^(\w+)$/i.test(e)?(this.setHex(THREE.ColorKeywords[e]),this):void 0},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(){var e=this.r,t=this.g,r=this.b;return this.r=e*e,this.g=t*t,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){e=e||{h:0,s:0,l:0};var t,r=this.r,i=this.g,n=this.b,o=Math.max(r,i,n),a=Math.min(r,i,n),s=(a+o)/2;if(a===o)a=t=0;else{var h=o-a,a=.5>=s?h/(o+a):h/(2-o-a);switch(o){case r:t=(i-n)/h+(n>i?6:0);break;case i:t=(n-r)/h+2;break;case n:t=(r-i)/h+4}t/=6}return e.h=t,e.s=a,e.l=s,e},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(e,t,r){var i=this.getHSL();return i.h+=e,i.s+=t,i.l+=r,this.setHSL(i.h,i.s,i.l),this},add:function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this},addColors:function(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this},addScalar:function(e){return this.r+=e,this.g+=e,this.b+=e,this},multiply:function(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this},multiplyScalar:function(e){return this.r*=e,this.g*=e,this.b*=e,this},lerp:function(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this},equals:function(e){return e.r===this.r&&e.g===this.g&&e.b===this.b},fromArray:function(e){return this.r=e[0],this.g=e[1],this.b=e[2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}},THREE.ColorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},THREE.Quaternion=function(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==i?i:1},THREE.Quaternion.prototype={constructor:THREE.Quaternion,_x:0,_y:0,_z:0,_w:0,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get w(){return this._w},set w(e){this._w=e,this.onChangeCallback()},set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this.onChangeCallback(),this},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!1==e instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var r=Math.cos(e._x/2),i=Math.cos(e._y/2),n=Math.cos(e._z/2),o=Math.sin(e._x/2),a=Math.sin(e._y/2),s=Math.sin(e._z/2);return"XYZ"===e.order?(this._x=o*i*n+r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n-o*a*s):"YXZ"===e.order?(this._x=o*i*n+r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n+o*a*s):"ZXY"===e.order?(this._x=o*i*n-r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n-o*a*s):"ZYX"===e.order?(this._x=o*i*n-r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n+o*a*s):"YZX"===e.order?(this._x=o*i*n+r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n-o*a*s):"XZY"===e.order&&(this._x=o*i*n-r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n+o*a*s),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t=e.elements,r=t[0];e=t[4];var i=t[8],n=t[1],o=t[5],a=t[9],s=t[2],h=t[6],t=t[10],l=r+o+t;return l>0?(r=.5/Math.sqrt(l+1),this._w=.25/r,this._x=(h-a)*r,this._y=(i-s)*r,this._z=(n-e)*r):r>o&&r>t?(r=2*Math.sqrt(1+r-o-t),this._w=(h-a)/r,this._x=.25*r,this._y=(e+n)/r,this._z=(i+s)/r):o>t?(r=2*Math.sqrt(1+o-r-t),this._w=(i-s)/r,this._x=(e+n)/r,this._y=.25*r,this._z=(a+h)/r):(r=2*Math.sqrt(1+t-r-o),this._w=(n-e)/r,this._x=(i+s)/r,this._y=(a+h)/r,this._z=.25*r),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector3),t=r.dot(i)+1,1e-6>t?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,i),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize(),this}}(),inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._z=this._y=this._x=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(THREE.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},multiplyQuaternions:function(e,t){var r=e._x,i=e._y,n=e._z,o=e._w,a=t._x,s=t._y,h=t._z,l=t._w;return this._x=r*l+o*a+i*h-n*s,this._y=i*l+o*s+n*a-r*h,this._z=n*l+o*h+r*s-i*a,this._w=o*l-r*a-i*s-n*h,this.onChangeCallback(),this},multiplyVector3:function(e){return THREE.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,i=this._y,n=this._z,o=this._w,a=o*e._w+r*e._x+i*e._y+n*e._z;if(0>a?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=r,this._y=i,this._z=n,this;var s=Math.acos(a),h=Math.sqrt(1-a*a);return.001>Math.abs(h)?(this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(i+this._y),this._z=.5*(n+this._z),this):(a=Math.sin((1-t)*s)/h,s=Math.sin(t*s)/h,this._w=o*a+this._w*s,this._x=r*a+this._x*s,this._y=i*a+this._y*s,this._z=n*a+this._z*s,this.onChangeCallback(),this)},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){},clone:function(){return new THREE.Quaternion(this._x,this._y,this._z,this._w)}},THREE.Quaternion.slerp=function(e,t,r,i){return r.copy(e).slerp(t,i)},THREE.Vector2=function(e,t){this.x=e||0,this.y=t||0},THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(e,t){return this.x=e,this.y=t,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},sub:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return 0!==e?(e=1/e,this.x*=e,this.y*=e):this.y=this.x=0,this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector2,t=new THREE.Vector2),e.set(r,r),t.set(i,i),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x;return e=this.y-e.y,t*t+e*e},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this},clone:function(){return new THREE.Vector2(this.x,this.y)}},THREE.Vector3=function(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0},THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},sub:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return!1==t instanceof THREE.Euler&&THREE.error("THREE.Vector3: .applyEuler() now expects a Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new THREE.Quaternion),this.applyQuaternion(e.setFromEuler(t)),this}}(),applyAxisAngle:function(){var e;return function(t,r){return void 0===e&&(e=new THREE.Quaternion),this.applyQuaternion(e.setFromAxisAngle(t,r)),this}}(),applyMatrix3:function(e){var t=this.x,r=this.y,i=this.z;return e=e.elements,this.x=e[0]*t+e[3]*r+e[6]*i,this.y=e[1]*t+e[4]*r+e[7]*i,this.z=e[2]*t+e[5]*r+e[8]*i,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z;return e=e.elements,this.x=e[0]*t+e[4]*r+e[8]*i+e[12],this.y=e[1]*t+e[5]*r+e[9]*i+e[13],this.z=e[2]*t+e[6]*r+e[10]*i+e[14],this},applyProjection:function(e){var t=this.x,r=this.y,i=this.z;e=e.elements;var n=1/(e[3]*t+e[7]*r+e[11]*i+e[15]);return this.x=(e[0]*t+e[4]*r+e[8]*i+e[12])*n,this.y=(e[1]*t+e[5]*r+e[9]*i+e[13])*n,this.z=(e[2]*t+e[6]*r+e[10]*i+e[14])*n,this},applyQuaternion:function(e){var t=this.x,r=this.y,i=this.z,n=e.x,o=e.y,a=e.z;e=e.w;var s=e*t+o*i-a*r,h=e*r+a*t-n*i,l=e*i+n*r-o*t,t=-n*t-o*r-a*i;return this.x=s*e+t*-n+h*-a-l*-o,this.y=h*e+t*-o+l*-n-s*-a,this.z=l*e+t*-a+s*-o-h*-n,this},project:function(){var e;return function(t){return void 0===e&&(e=new THREE.Matrix4),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyProjection(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new THREE.Matrix4),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyProjection(e)}}(),transformDirection:function(e){var t=this.x,r=this.y,i=this.z;return e=e.elements,this.x=e[0]*t+e[4]*r+e[8]*i,this.y=e[1]*t+e[5]*r+e[9]*i,this.z=e[2]*t+e[6]*r+e[10]*i,this.normalize(),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return 0!==e?(e=1/e,this.x*=e,this.y*=e,this.z*=e):this.z=this.y=this.x=0,this},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector3,t=new THREE.Vector3),e.set(r,r,r),t.set(i,i,i),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e),this},cross:function(e,t){if(void 0!==t)return THREE.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var r=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-r*e.z,this.z=r*e.y-i*e.x,this},crossVectors:function(e,t){var r=e.x,i=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=i*s-n*a,this.y=n*o-r*s,this.z=r*a-i*o,this},projectOnVector:function(){var e,t;return function(r){return void 0===e&&(e=new THREE.Vector3),e.copy(r).normalize(),t=this.dot(e),this.copy(e).multiplyScalar(t)}}(),projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new THREE.Vector3),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new THREE.Vector3),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){return e=this.dot(e)/(this.length()*e.length()),Math.acos(THREE.Math.clamp(e,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return e=this.z-e.z,t*t+r*r+e*e},setEulerFromRotationMatrix:function(e,t){THREE.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(e,t){THREE.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(e){return THREE.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},getScaleFromMatrix:function(e){return THREE.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},getColumnFromMatrix:function(e,t){return THREE.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},setFromMatrixPosition:function(e){return this.x=e.elements[12],this.y=e.elements[13],this.z=e.elements[14],this},setFromMatrixScale:function(e){var t=this.set(e.elements[0],e.elements[1],e.elements[2]).length(),r=this.set(e.elements[4],e.elements[5],e.elements[6]).length();return e=this.set(e.elements[8],e.elements[9],e.elements[10]).length(),this.x=t,this.y=r,this.z=e,this},setFromMatrixColumn:function(e,t){var r=4*e,i=t.elements;return this.x=i[r],this.y=i[r+1],this.z=i[r+2],this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}},THREE.Vector4=function(e,t,r,i){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==i?i:1},THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("index is out of range: "+e)}},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},sub:function(e,t){return void 0!==t?(THREE.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,r=this.y,i=this.z,n=this.w;return e=e.elements,this.x=e[0]*t+e[4]*r+e[8]*i+e[12]*n,this.y=e[1]*t+e[5]*r+e[9]*i+e[13]*n,this.z=e[2]*t+e[6]*r+e[10]*i+e[14]*n,this.w=e[3]*t+e[7]*r+e[11]*i+e[15]*n,this},divideScalar:function(e){return 0!==e?(e=1/e,this.x*=e,this.y*=e,this.z*=e,this.w*=e):(this.z=this.y=this.x=0,this.w=1),this},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return 1e-4>t?(this.x=1,this.z=this.y=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,i;e=e.elements;var n=e[0];i=e[4];var o=e[8],a=e[1],s=e[5],h=e[9];r=e[2],t=e[6];var l=e[10];return.01>Math.abs(i-a)&&.01>Math.abs(o-r)&&.01>Math.abs(h-t)?.1>Math.abs(i+a)&&.1>Math.abs(o+r)&&.1>Math.abs(h+t)&&.1>Math.abs(n+s+l-3)?(this.set(1,0,0,0),this):(e=Math.PI,n=(n+1)/2,s=(s+1)/2,l=(l+1)/2,i=(i+a)/4,o=(o+r)/4,h=(h+t)/4,n>s&&n>l?.01>n?(t=0,i=r=.707106781):(t=Math.sqrt(n),r=i/t,i=o/t):s>l?.01>s?(t=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),t=i/r,i=h/r):.01>l?(r=t=.707106781,i=0):(i=Math.sqrt(l),t=o/i,r=h/i),this.set(t,r,i,e),this):(e=Math.sqrt((t-h)*(t-h)+(o-r)*(o-r)+(a-i)*(a-i)),.001>Math.abs(e)&&(e=1),this.x=(t-h)/e,this.y=(o-r)/e,this.z=(a-i)/e,this.w=Math.acos((n+s+l-1)/2),this)},min:function(e){return this.x>e.x&&(this.x=e.x),this.y>e.y&&(this.y=e.y),this.z>e.z&&(this.z=e.z),this.w>e.w&&(this.w=e.w),this},max:function(e){return this.xt.x&&(this.x=t.x),this.yt.y&&(this.y=t.y),this.zt.z&&(this.z=t.z),this.wt.w&&(this.w=t.w),this},clampScalar:function(){var e,t;return function(r,i){return void 0===e&&(e=new THREE.Vector4,t=new THREE.Vector4),e.set(r,r,r,r),t.set(i,i,i,i),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x),this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y),this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z),this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){var t=this.length();return 0!==t&&e!==t&&this.multiplyScalar(e/t),this},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e),this},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromAttribute:function(e,t,r){return void 0===r&&(r=0),t=t*e.itemSize+r,this.x=e.array[t],this.y=e.array[t+1],this.z=e.array[t+2],this.w=e.array[t+3],this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}},THREE.Euler=function(e,t,r,i){this._x=e||0,this._y=t||0,this._z=r||0,this._order=i||THREE.Euler.DefaultOrder}, +THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" "),THREE.Euler.DefaultOrder="XYZ",THREE.Euler.prototype={constructor:THREE.Euler,_x:0,_y:0,_z:0,_order:THREE.Euler.DefaultOrder,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var i=THREE.Math.clamp,n=e.elements;e=n[0];var o=n[4],a=n[8],s=n[1],h=n[5],l=n[9],c=n[2],u=n[6],n=n[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(i(a,-1,1)),.99999>Math.abs(a)?(this._x=Math.atan2(-l,n),this._z=Math.atan2(-o,e)):(this._x=Math.atan2(u,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-i(l,-1,1)),.99999>Math.abs(l)?(this._y=Math.atan2(a,n),this._z=Math.atan2(s,h)):(this._y=Math.atan2(-c,e),this._z=0)):"ZXY"===t?(this._x=Math.asin(i(u,-1,1)),.99999>Math.abs(u)?(this._y=Math.atan2(-c,n),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(s,e))):"ZYX"===t?(this._y=Math.asin(-i(c,-1,1)),.99999>Math.abs(c)?(this._x=Math.atan2(u,n),this._z=Math.atan2(s,e)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===t?(this._z=Math.asin(i(s,-1,1)),.99999>Math.abs(s)?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,e)):(this._x=0,this._y=Math.atan2(a,n))):"XZY"===t?(this._z=Math.asin(-i(o,-1,1)),.99999>Math.abs(o)?(this._x=Math.atan2(u,h),this._y=Math.atan2(a,e)):(this._x=Math.atan2(-l,n),this._y=0)):THREE.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,r,i){return void 0===e&&(e=new THREE.Matrix4),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,r,i),this}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new THREE.Quaternion;return function(t){e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){},clone:function(){return new THREE.Euler(this._x,this._y,this._z,this._order)}},THREE.Line3=function(e,t){this.start=void 0!==e?e:new THREE.Vector3,this.end=void 0!==t?t:new THREE.Vector3},THREE.Line3.prototype={constructor:THREE.Line3,set:function(e,t){return this.start.copy(e),this.end.copy(t),this},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},center:function(e){return(e||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return(e||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var r=t||new THREE.Vector3;return this.delta(r).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(r,i){e.subVectors(r,this.start),t.subVectors(this.end,this.start);var n=t.dot(t),n=t.dot(e)/n;return i&&(n=THREE.Math.clamp(n,0,1)),n}}(),closestPointToPoint:function(e,t,r){return e=this.closestPointToPointParameter(e,t),r=r||new THREE.Vector3,this.delta(r).multiplyScalar(e).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)},clone:function(){return(new THREE.Line3).copy(this)}},THREE.Box2=function(e,t){this.min=void 0!==e?e:new THREE.Vector2(1/0,1/0),this.max=void 0!==t?t:new THREE.Vector2(-(1/0),-(1/0))},THREE.Box2.prototype={constructor:THREE.Box2,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;r>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new THREE.Vector2;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-(1/0),this},empty:function(){return this.max.xthis.max.x||e.ythis.max.y?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y?!0:!1},getParameter:function(e,t){return(t||new THREE.Vector2).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox:function(e){return e.max.xthis.max.x||e.max.ythis.max.y?!1:!0},clampPoint:function(e,t){return(t||new THREE.Vector2).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector2;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},clone:function(){return(new THREE.Box2).copy(this)}},THREE.Box3=function(e,t){this.min=void 0!==e?e:new THREE.Vector3(1/0,1/0,1/0),this.max=void 0!==t?t:new THREE.Vector3(-(1/0),-(1/0),-(1/0))},THREE.Box3.prototype={constructor:THREE.Box3,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;r>t;t++)this.expandByPoint(e[t]);return this},setFromCenterAndSize:function(){var e=new THREE.Vector3;return function(t,r){var i=e.copy(r).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}}(),setFromObject:function(){var e=new THREE.Vector3;return function(t){var r=this;return t.updateMatrixWorld(!0),this.makeEmpty(),t.traverse(function(t){var i=t.geometry;if(void 0!==i)if(i instanceof THREE.Geometry)for(var n=i.vertices,i=0,o=n.length;o>i;i++)e.copy(n[i]),e.applyMatrix4(t.matrixWorld),r.expandByPoint(e);else if(i instanceof THREE.BufferGeometry&&void 0!==i.attributes.position)for(n=i.attributes.position.array,i=0,o=n.length;o>i;i+=3)e.set(n[i],n[i+1],n[i+2]),e.applyMatrix4(t.matrixWorld),r.expandByPoint(e)}),this}}(),copy:function(e){return this.min.copy(e.min),this.max.copy(e.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-(1/0),this},empty:function(){return this.max.xthis.max.x||e.ythis.max.y||e.zthis.max.z?!1:!0},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z?!0:!1},getParameter:function(e,t){return(t||new THREE.Vector3).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(e){return e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z?!1:!0},clampPoint:function(e,t){return(t||new THREE.Vector3).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new THREE.Vector3;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new THREE.Vector3;return function(t){return t=t||new THREE.Sphere,t.center=this.center(),t.radius=.5*this.size(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(t){return e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.makeEmpty(),this.setFromPoints(e),this}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)},clone:function(){return(new THREE.Box3).copy(this)}},THREE.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),0n;n+=3,r+=3)e.x=t[r],e.y=t[r+1],e.z=t[r+2],e.applyMatrix3(this),t[r]=e.x,t[r+1]=e.y,t[r+2]=e.z;return t}}(),multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this},determinant:function(){var e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],s=e[6],h=e[7],e=e[8];return t*o*e-t*a*h-r*n*e+r*a*s+i*n*h-i*o*s},getInverse:function(e,t){var r=e.elements,i=this.elements;if(i[0]=r[10]*r[5]-r[6]*r[9],i[1]=-r[10]*r[1]+r[2]*r[9],i[2]=r[6]*r[1]-r[2]*r[5],i[3]=-r[10]*r[4]+r[6]*r[8],i[4]=r[10]*r[0]-r[2]*r[8],i[5]=-r[6]*r[0]+r[2]*r[4],i[6]=r[9]*r[4]-r[5]*r[8],i[7]=-r[9]*r[0]+r[1]*r[8],i[8]=r[5]*r[0]-r[1]*r[4],r=r[0]*i[0]+r[1]*i[3]+r[2]*i[6],0===r){if(t)throw Error("Matrix3.getInverse(): can't invert matrix, determinant is 0");return THREE.warn("Matrix3.getInverse(): can't invert matrix, determinant is 0"),this.identity(),this}return this.multiplyScalar(1/r),this},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this},flattenToArrayOffset:function(e,t){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e},getNormalMatrix:function(e){return this.getInverse(e).transpose(),this},transposeIntoArray:function(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this},fromArray:function(e){return this.elements.set(e),this},toArray:function(){var e=this.elements;return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]]},clone:function(){return(new THREE.Matrix3).fromArray(this.elements)}},THREE.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),0n;n+=3,r+=3)e.x=t[r],e.y=t[r+1],e.z=t[r+2],e.applyMatrix4(this),t[r]=e.x,t[r+1]=e.y,t[r+2]=e.z;return t}}(),rotateAxis:function(e){THREE.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},crossVector:function(e){return THREE.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},determinant:function(){var e=this.elements,t=e[0],r=e[4],i=e[8],n=e[12],o=e[1],a=e[5],s=e[9],h=e[13],l=e[2],c=e[6],u=e[10],E=e[14];return e[3]*(+n*s*c-i*h*c-n*a*u+r*h*u+i*a*E-r*s*E)+e[7]*(+t*s*E-t*h*u+n*o*u-i*o*E+i*h*l-n*s*l)+e[11]*(+t*h*c-t*a*E-n*o*c+r*o*E+n*a*l-r*h*l)+e[15]*(-i*a*l-t*s*c+t*a*u+i*o*c-r*o*u+r*s*l)},transpose:function(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this},flattenToArrayOffset:function(e,t){var r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e},getPosition:function(){var e=new THREE.Vector3;return function(){THREE.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");var t=this.elements;return e.set(t[12],t[13],t[14])}}(),setPosition:function(e){var t=this.elements;return t[12]=e.x,t[13]=e.y,t[14]=e.z,this},getInverse:function(e,t){var r=this.elements,i=e.elements,n=i[0],o=i[4],a=i[8],s=i[12],h=i[1],l=i[5],c=i[9],u=i[13],E=i[2],p=i[6],d=i[10],f=i[14],m=i[3],T=i[7],g=i[11],i=i[15];if(r[0]=c*f*T-u*d*T+u*p*g-l*f*g-c*p*i+l*d*i,r[4]=s*d*T-a*f*T-s*p*g+o*f*g+a*p*i-o*d*i,r[8]=a*u*T-s*c*T+s*l*g-o*u*g-a*l*i+o*c*i,r[12]=s*c*p-a*u*p-s*l*d+o*u*d+a*l*f-o*c*f,r[1]=u*d*m-c*f*m-u*E*g+h*f*g+c*E*i-h*d*i,r[5]=a*f*m-s*d*m+s*E*g-n*f*g-a*E*i+n*d*i,r[9]=s*c*m-a*u*m-s*h*g+n*u*g+a*h*i-n*c*i,r[13]=a*u*E-s*c*E+s*h*d-n*u*d-a*h*f+n*c*f,r[2]=l*f*m-u*p*m+u*E*T-h*f*T-l*E*i+h*p*i,r[6]=s*p*m-o*f*m-s*E*T+n*f*T+o*E*i-n*p*i,r[10]=o*u*m-s*l*m+s*h*T-n*u*T-o*h*i+n*l*i,r[14]=s*l*E-o*u*E-s*h*p+n*u*p+o*h*f-n*l*f,r[3]=c*p*m-l*d*m-c*E*T+h*d*T+l*E*g-h*p*g,r[7]=o*d*m-a*p*m+a*E*T-n*d*T-o*E*g+n*p*g,r[11]=a*l*m-o*c*m-a*h*T+n*c*T+o*h*g-n*l*g,r[15]=o*c*E-a*l*E+a*h*p-n*c*p-o*h*d+n*l*d,r=n*r[0]+h*r[4]+E*r[8]+m*r[12],0==r){if(t)throw Error("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");return THREE.warn("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0"),this.identity(),this}return this.multiplyScalar(1/r),this},translate:function(e){THREE.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(e){THREE.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(e){THREE.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(e){THREE.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(e,t){THREE.error("THREE.Matrix4: .rotateByAxis() has been removed.")},scale:function(e){var t=this.elements,r=e.x,i=e.y;return e=e.z,t[0]*=r,t[4]*=i,t[8]*=e,t[1]*=r,t[5]*=i,t[9]*=e,t[2]*=r,t[6]*=i,t[10]*=e,t[3]*=r,t[7]*=i,t[11]*=e,this},getMaxScaleOnAxis:function(){var e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],Math.max(e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10])))},makeTranslation:function(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this},makeRotationX:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this},makeRotationY:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this},makeRotationZ:function(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(e,t){var r=Math.cos(t),i=Math.sin(t),n=1-r,o=e.x,a=e.y,s=e.z,h=n*o,l=n*a;return this.set(h*o+r,h*a-i*s,h*s+i*a,0,h*a+i*s,l*a+r,l*s-i*o,0,h*s-i*a,l*s+i*o,n*s*s+r,0,0,0,0,1),this},makeScale:function(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this},compose:function(e,t,r){return this.makeRotationFromQuaternion(t),this.scale(r),this.setPosition(e),this},decompose:function(){var e=new THREE.Vector3,t=new THREE.Matrix4;return function(r,i,n){var o=this.elements,a=e.set(o[0],o[1],o[2]).length(),s=e.set(o[4],o[5],o[6]).length(),h=e.set(o[8],o[9],o[10]).length();0>this.determinant()&&(a=-a),r.x=o[12],r.y=o[13],r.z=o[14],t.elements.set(this.elements),r=1/a;var o=1/s,l=1/h;return t.elements[0]*=r,t.elements[1]*=r,t.elements[2]*=r,t.elements[4]*=o,t.elements[5]*=o,t.elements[6]*=o,t.elements[8]*=l,t.elements[9]*=l,t.elements[10]*=l,i.setFromRotationMatrix(t),n.x=a,n.y=s,n.z=h,this}}(),makeFrustum:function(e,t,r,i,n,o){var a=this.elements;return a[0]=2*n/(t-e),a[4]=0,a[8]=(t+e)/(t-e),a[12]=0,a[1]=0,a[5]=2*n/(i-r),a[9]=(i+r)/(i-r),a[13]=0,a[2]=0,a[6]=0,a[10]=-(o+n)/(o-n),a[14]=-2*o*n/(o-n),a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makePerspective:function(e,t,r,i){e=r*Math.tan(THREE.Math.degToRad(.5*e));var n=-e;return this.makeFrustum(n*t,e*t,n,e,r,i)},makeOrthographic:function(e,t,r,i,n,o){var a=this.elements,s=t-e,h=r-i,l=o-n;return a[0]=2/s,a[4]=0,a[8]=0,a[12]=-((t+e)/s),a[1]=0,a[5]=2/h,a[9]=0,a[13]=-((r+i)/h),a[2]=0,a[6]=0,a[10]=-2/l,a[14]=-((o+n)/l),a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},fromArray:function(e){return this.elements.set(e),this},toArray:function(){var e=this.elements;return[e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]]},clone:function(){return(new THREE.Matrix4).fromArray(this.elements)}},THREE.Ray=function(e,t){this.origin=void 0!==e?e:new THREE.Vector3,this.direction=void 0!==t?t:new THREE.Vector3},THREE.Ray.prototype={constructor:THREE.Ray,set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return(t||new THREE.Vector3).copy(this.direction).multiplyScalar(e).add(this.origin)},recast:function(){var e=new THREE.Vector3;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var r=t||new THREE.Vector3;r.subVectors(e,this.origin);var i=r.dot(this.direction);return 0>i?r.copy(this.origin):r.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:function(){var e=new THREE.Vector3;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return 0>r?this.origin.distanceTo(t):(e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceTo(t))}}(),distanceSqToSegment:function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(i,n,o,a){e.copy(i).add(n).multiplyScalar(.5),t.copy(n).sub(i).normalize(),r.copy(this.origin).sub(e);var s,h=.5*i.distanceTo(n),l=-this.direction.dot(t),c=r.dot(this.direction),u=-r.dot(t),E=r.lengthSq(),p=Math.abs(1-l*l);return p>0?(i=l*u-c,n=l*c-u,s=h*p,i>=0?n>=-s?s>=n?(h=1/p,i*=h,n*=h,l=i*(i+l*n+2*c)+n*(l*i+n+2*u)+E):(n=h,i=Math.max(0,-(l*n+c)),l=-i*i+n*(n+2*u)+E):(n=-h,i=Math.max(0,-(l*n+c)),l=-i*i+n*(n+2*u)+E):-s>=n?(i=Math.max(0,-(-l*h+c)),n=i>0?-h:Math.min(Math.max(-h,-u),h),l=-i*i+n*(n+2*u)+E):s>=n?(i=0,n=Math.min(Math.max(-h,-u),h),l=n*(n+2*u)+E):(i=Math.max(0,-(l*h+c)),n=i>0?h:Math.min(Math.max(-h,-u),h),l=-i*i+n*(n+2*u)+E)):(n=l>0?-h:h,i=Math.max(0,-(l*n+c)),l=-i*i+n*(n+2*u)+E),o&&o.copy(this.direction).multiplyScalar(i).add(this.origin),a&&a.copy(t).multiplyScalar(n).add(e),l}}(),isIntersectionSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},intersectSphere:function(){var e=new THREE.Vector3;return function(t,r){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),n=e.dot(e)-i*i,o=t.radius*t.radius;return n>o?null:(o=Math.sqrt(o-n),n=i-o,i+=o,0>n&&0>i?null:0>n?this.at(i,r):this.at(n,r))}}(),isIntersectionPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||0>e.normal.dot(this.direction)*t?!0:!1},distanceToPlane:function(e){var t=e.normal.dot(this.direction);return 0==t?0==e.distanceToPoint(this.origin)?0:null:(e=-(this.origin.dot(e.normal)+e.constant)/t,e>=0?e:null)},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},isIntersectionBox:function(){var e=new THREE.Vector3;return function(t){return null!==this.intersectBox(t,e)}}(),intersectBox:function(e,t){var r,i,n,o,a;i=1/this.direction.x,o=1/this.direction.y,a=1/this.direction.z;var s=this.origin;return i>=0?(r=(e.min.x-s.x)*i,i*=e.max.x-s.x):(r=(e.max.x-s.x)*i,i*=e.min.x-s.x),o>=0?(n=(e.min.y-s.y)*o,o*=e.max.y-s.y):(n=(e.max.y-s.y)*o,o*=e.min.y-s.y),r>o||n>i?null:((n>r||r!==r)&&(r=n),(i>o||i!==i)&&(i=o),a>=0?(n=(e.min.z-s.z)*a,a*=e.max.z-s.z):(n=(e.max.z-s.z)*a,a*=e.min.z-s.z),r>a||n>i?null:((n>r||r!==r)&&(r=n),(i>a||i!==i)&&(i=a),0>i?null:this.at(r>=0?r:i,t)))},intersectTriangle:function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3,i=new THREE.Vector3;return function(n,o,a,s,h){if(t.subVectors(o,n),r.subVectors(a,n),i.crossVectors(t,r),o=this.direction.dot(i),o>0){if(s)return null;s=1}else{if(!(0>o))return null;s=-1,o=-o}return e.subVectors(this.origin,n),n=s*this.direction.dot(r.crossVectors(e,r)),0>n?null:(a=s*this.direction.dot(t.cross(e)),0>a||n+a>o?null:(n=-s*e.dot(i),0>n?null:this.at(n/o,h)))}}(),applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)},clone:function(){return(new THREE.Ray).copy(this)}},THREE.Sphere=function(e,t){this.center=void 0!==e?e:new THREE.Vector3,this.radius=void 0!==t?t:0},THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new THREE.Box3;return function(t,r){var i=this.center;void 0!==r?i.copy(r):e.setFromPoints(t).center(i);for(var n=0,o=0,a=t.length;a>o;o++)n=Math.max(n,i.distanceToSquared(t[o]));return this.radius=Math.sqrt(n),this}}(),copy:function(e){return this.center.copy(e.center),this.radius=e.radius,this},empty:function(){return 0>=this.radius},containsPoint:function(e){return e.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(e){return e.distanceTo(this.center)-this.radius},intersectsSphere:function(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t},clampPoint:function(e,t){var r=this.center.distanceToSquared(e),i=t||new THREE.Vector3;return i.copy(e),r>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(e){return e=e||new THREE.Box3,e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius},clone:function(){return(new THREE.Sphere).copy(this)}},THREE.Frustum=function(e,t,r,i,n,o){this.planes=[void 0!==e?e:new THREE.Plane,void 0!==t?t:new THREE.Plane,void 0!==r?r:new THREE.Plane,void 0!==i?i:new THREE.Plane,void 0!==n?n:new THREE.Plane,void 0!==o?o:new THREE.Plane]},THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(e,t,r,i,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},copy:function(e){for(var t=this.planes,r=0;6>r;r++)t[r].copy(e.planes[r]);return this},setFromMatrix:function(e){var t=this.planes,r=e.elements;e=r[0];var i=r[1],n=r[2],o=r[3],a=r[4],s=r[5],h=r[6],l=r[7],c=r[8],u=r[9],E=r[10],p=r[11],d=r[12],f=r[13],m=r[14],r=r[15];return t[0].setComponents(o-e,l-a,p-c,r-d).normalize(),t[1].setComponents(o+e,l+a,p+c,r+d).normalize(),t[2].setComponents(o+i,l+s,p+u,r+f).normalize(),t[3].setComponents(o-i,l-s,p-u,r-f).normalize(),t[4].setComponents(o-n,l-h,p-E,r-m).normalize(),t[5].setComponents(o+n,l+h,p+E,r+m).normalize(),this},intersectsObject:function(){var e=new THREE.Sphere;return function(t){var r=t.geometry;return null===r.boundingSphere&&r.computeBoundingSphere(),e.copy(r.boundingSphere),e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){var t=this.planes,r=e.center;e=-e.radius;for(var i=0;6>i;i++)if(t[i].distanceToPoint(r)n;n++){var o=i[n];e.x=0a&&0>o)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,r=0;6>r;r++)if(0>t[r].distanceToPoint(e))return!1;return!0},clone:function(){return(new THREE.Frustum).copy(this)}},THREE.Plane=function(e,t){this.normal=void 0!==e?e:new THREE.Vector3(1,0,0),this.constant=void 0!==t?t:0},THREE.Plane.prototype={constructor:THREE.Plane,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){ +var e=new THREE.Vector3,t=new THREE.Vector3;return function(r,i,n){return i=e.subVectors(n,i).cross(t.subVectors(r,i)).normalize(),this.setFromNormalAndCoplanarPoint(i,r),this}}(),copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return this.orthoPoint(e,t).sub(e).negate()},orthoPoint:function(e,t){var r=this.distanceToPoint(e);return(t||new THREE.Vector3).copy(this.normal).multiplyScalar(r)},isIntersectionLine:function(e){var t=this.distanceToPoint(e.start);return e=this.distanceToPoint(e.end),0>t&&e>0||0>e&&t>0},intersectLine:function(){var e=new THREE.Vector3;return function(t,r){var i=r||new THREE.Vector3,n=t.delta(e),o=this.normal.dot(n);return 0!=o?(o=-(t.start.dot(this.normal)+this.constant)/o,0>o||o>1?void 0:i.copy(n).multiplyScalar(o).add(t.start)):0==this.distanceToPoint(t.start)?i.copy(t.start):void 0}}(),coplanarPoint:function(e){return(e||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Matrix3;return function(i,n){var o=n||r.getNormalMatrix(i),o=e.copy(this.normal).applyMatrix3(o),a=this.coplanarPoint(t);return a.applyMatrix4(i),this.setFromNormalAndCoplanarPoint(o,a),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant==this.constant},clone:function(){return(new THREE.Plane).copy(this)}},THREE.Math={generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=Array(36),i=0;return function(){for(var n=0;36>n;n++)8==n||13==n||18==n||23==n?r[n]="-":14==n?r[n]="4":(2>=i&&(i=33554432+16777216*Math.random()|0),e=15&i,i>>=4,r[n]=t[19==n?3&e|8:e]);return r.join("")}}(),clamp:function(e,t,r){return t>e?t:e>r?r:e},clampBottom:function(e,t){return t>e?t:e},mapLinear:function(e,t,r,i,n){return i+(e-t)*(n-i)/(r-t)},smoothstep:function(e,t,r){return t>=e?0:e>=r?1:(e=(e-t)/(r-t),e*e*(3-2*e))},smootherstep:function(e,t,r){return t>=e?0:e>=r?1:(e=(e-t)/(r-t),e*e*e*(e*(6*e-15)+10))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(e,t){return Math.floor(this.randFloat(e,t))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(){var e=Math.PI/180;return function(t){return t*e}}(),radToDeg:function(){var e=180/Math.PI;return function(t){return t*e}}(),isPowerOfTwo:function(e){return 0===(e&e-1)&&0!==e},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}},THREE.Spline=function(e){function t(e,t,r,i,n,o,a){return e=.5*(r-e),i=.5*(i-t),(2*(t-r)+e+i)*a+(-3*(t-r)-2*e-i)*o+e*n+t}this.points=e;var r,i,n,o,a,s,h,l,c,u=[],E={x:0,y:0,z:0};this.initFromArray=function(e){this.points=[];for(var t=0;tthis.points.length-2?this.points.length-1:i+1,u[3]=i>this.points.length-3?this.points.length-1:i+2,s=this.points[u[0]],h=this.points[u[1]],l=this.points[u[2]],c=this.points[u[3]],o=n*n,a=n*o,E.x=t(s.x,h.x,l.x,c.x,n,o,a),E.y=t(s.y,h.y,l.y,c.y,n,o,a),E.z=t(s.z,h.z,l.z,c.z,n,o,a),E},this.getControlPointsArray=function(){var e,t,r=this.points.length,i=[];for(e=0;r>e;e++)t=this.points[e],i[e]=[t.x,t.y,t.z];return i},this.getLength=function(e){var t,r,i,n=t=t=0,o=new THREE.Vector3,a=new THREE.Vector3,s=[],h=0;for(s[0]=0,e||(e=100),r=this.points.length*e,o.copy(this.points[0]),e=1;r>e;e++)t=e/r,i=this.getPoint(t),a.copy(i),h+=a.distanceTo(o),o.copy(i),t*=this.points.length-1,t=Math.floor(t),t!=n&&(s[t]=h,n=t);return s[s.length]=h,{chunks:s,total:h}},this.reparametrizeByArcLength=function(e){var t,r,i,n,o,a,s=[],h=new THREE.Vector3,l=this.getLength();for(s.push(h.copy(this.points[0]).clone()),t=1;tr;r++)i=n+1/a*r*(o-n),i=this.getPoint(i),s.push(h.copy(i).clone());s.push(h.copy(this.points[t]).clone())}this.points=s}},THREE.Triangle=function(e,t,r){this.a=void 0!==e?e:new THREE.Vector3,this.b=void 0!==t?t:new THREE.Vector3,this.c=void 0!==r?r:new THREE.Vector3},THREE.Triangle.normal=function(){var e=new THREE.Vector3;return function(t,r,i,n){return n=n||new THREE.Vector3,n.subVectors(i,r),e.subVectors(t,r),n.cross(e),t=n.lengthSq(),t>0?n.multiplyScalar(1/Math.sqrt(t)):n.set(0,0,0)}}(),THREE.Triangle.barycoordFromPoint=function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(i,n,o,a,s){e.subVectors(a,n),t.subVectors(o,n),r.subVectors(i,n),i=e.dot(e),n=e.dot(t),o=e.dot(r);var h=t.dot(t);a=t.dot(r);var l=i*h-n*n;return s=s||new THREE.Vector3,0==l?s.set(-2,-1,-1):(l=1/l,h=(h*o-n*a)*l,i=(i*a-n*o)*l,s.set(1-h-i,i,h))}}(),THREE.Triangle.containsPoint=function(){var e=new THREE.Vector3;return function(t,r,i,n){return t=THREE.Triangle.barycoordFromPoint(t,r,i,n,e),0<=t.x&&0<=t.y&&1>=t.x+t.y}}(),THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return THREE.Triangle.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return THREE.Triangle.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return THREE.Triangle.containsPoint(e,this.a,this.b,this.c)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)},clone:function(){return(new THREE.Triangle).copy(this)}},THREE.Clock=function(e){this.autoStart=void 0!==e?e:!0,this.elapsedTime=this.oldTime=this.startTime=0,this.running=!1},THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(),this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var e=0;if(this.autoStart&&!this.running&&this.start(),this.running){var t=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():Date.now(),e=.001*(t-this.oldTime);this.oldTime=t,this.elapsedTime+=e}return e}},THREE.EventDispatcher=function(){},THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(e){e.addEventListener=THREE.EventDispatcher.prototype.addEventListener,e.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener,e.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener,e.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;var r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)?!0:!1},removeEventListener:function(e,t){if(void 0!==this._listeners){var r=this._listeners[e];if(void 0!==r){var i=r.indexOf(t);-1!==i&&r.splice(i,1)}}},dispatchEvent:function(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;for(var r=[],i=t.length,n=0;i>n;n++)r[n]=t[n];for(n=0;i>n;n++)r[n].call(this,e)}}}},function(e){e.Raycaster=function(t,r,i,n){this.ray=new e.Ray(t,r),this.near=i||0,this.far=n||1/0,this.params={Sprite:{},Mesh:{},PointCloud:{threshold:1},LOD:{},Line:{}}};var t=function(e,t){return e.distance-t.distance},r=function(e,t,i,n){if(e.raycast(t,i),!0===n){e=e.children,n=0;for(var o=e.length;o>n;n++)r(e[n],t,i,!0)}};e.Raycaster.prototype={constructor:e.Raycaster,precision:1e-4,linePrecision:1,set:function(e,t){this.ray.set(e,t)},setFromCamera:function(t,r){r instanceof e.PerspectiveCamera?(this.ray.origin.copy(r.position),this.ray.direction.set(t.x,t.y,.5).unproject(r).sub(r.position).normalize()):r instanceof e.OrthographicCamera?(this.ray.origin.set(t.x,t.y,-1).unproject(r),this.ray.direction.set(0,0,-1).transformDirection(r.matrixWorld)):e.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(e,i){var n=[];return r(e,this,n,i),n.sort(t),n},intersectObjects:function(i,n){var o=[];if(!1==i instanceof Array)return e.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),o;for(var a=0,s=i.length;s>a;a++)r(i[a],this,o,n);return o.sort(t),o}}}(THREE),THREE.Object3D=function(){Object.defineProperty(this,"id",{value:THREE.Object3DIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="Object3D",this.parent=void 0,this.children=[],this.up=THREE.Object3D.DefaultUp.clone();var e=new THREE.Vector3,t=new THREE.Euler,r=new THREE.Quaternion,i=new THREE.Vector3(1,1,1);t.onChange(function(){r.setFromEuler(t,!1)}),r.onChange(function(){t.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:e},rotation:{enumerable:!0,value:t},quaternion:{enumerable:!0,value:r},scale:{enumerable:!0,value:i}}),this.rotationAutoUpdate=!0,this.matrix=new THREE.Matrix4,this.matrixWorld=new THREE.Matrix4,this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!1,this.visible=!0,this.receiveShadow=this.castShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}},THREE.Object3D.DefaultUp=new THREE.Vector3(0,1,0),THREE.Object3D.prototype={constructor:THREE.Object3D,get eulerOrder(){return THREE.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order},set eulerOrder(e){THREE.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order=e},get useQuaternion(){THREE.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set useQuaternion(e){THREE.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},applyMatrix:function(e){this.matrix.multiplyMatrices(e,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(e,t){this.quaternion.setFromAxisAngle(e,t)},setRotationFromEuler:function(e){this.quaternion.setFromEuler(e,!0)},setRotationFromMatrix:function(e){this.quaternion.setFromRotationMatrix(e)},setRotationFromQuaternion:function(e){this.quaternion.copy(e)},rotateOnAxis:function(){var e=new THREE.Quaternion;return function(t,r){return e.setFromAxisAngle(t,r),this.quaternion.multiply(e),this}}(),rotateX:function(){var e=new THREE.Vector3(1,0,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateY:function(){var e=new THREE.Vector3(0,1,0);return function(t){return this.rotateOnAxis(e,t)}}(),rotateZ:function(){var e=new THREE.Vector3(0,0,1);return function(t){return this.rotateOnAxis(e,t)}}(),translateOnAxis:function(){var e=new THREE.Vector3;return function(t,r){return e.copy(t).applyQuaternion(this.quaternion),this.position.add(e.multiplyScalar(r)),this}}(),translate:function(e,t){return THREE.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},translateX:function(){var e=new THREE.Vector3(1,0,0);return function(t){return this.translateOnAxis(e,t)}}(),translateY:function(){var e=new THREE.Vector3(0,1,0);return function(t){return this.translateOnAxis(e,t)}}(),translateZ:function(){var e=new THREE.Vector3(0,0,1);return function(t){return this.translateOnAxis(e,t)}}(),localToWorld:function(e){return e.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var e=new THREE.Matrix4;return function(t){return t.applyMatrix4(e.getInverse(this.matrixWorld))}}(),lookAt:function(){var e=new THREE.Matrix4;return function(t){e.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(e)}}(),add:function(e){if(1r;r++){var n=this.children[r].getObjectByProperty(e,t);if(void 0!==n)return n}},getWorldPosition:function(e){return e=e||new THREE.Vector3,this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var e=new THREE.Vector3,t=new THREE.Vector3;return function(r){return r=r||new THREE.Quaternion,this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,r,t),r}}(),getWorldRotation:function(){var e=new THREE.Quaternion;return function(t){return t=t||new THREE.Euler,this.getWorldQuaternion(e),t.setFromQuaternion(e,this.rotation.order,!1)}}(),getWorldScale:function(){var e=new THREE.Vector3,t=new THREE.Quaternion;return function(r){return r=r||new THREE.Vector3,this.updateMatrixWorld(!0),this.matrixWorld.decompose(e,t,r),r}}(),getWorldDirection:function(){var e=new THREE.Quaternion;return function(t){return t=t||new THREE.Vector3,this.getWorldQuaternion(e),t.set(0,0,1).applyQuaternion(e)}}(),raycast:function(){},traverse:function(e){e(this);for(var t=0,r=this.children.length;r>t;t++)this.children[t].traverse(e)},traverseVisible:function(e){if(!1!==this.visible){e(this);for(var t=0,r=this.children.length;r>t;t++)this.children[t].traverseVisible(e)}},traverseAncestors:function(e){this.parent&&(e(this.parent),this.parent.traverseAncestors(e))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(e){!0===this.matrixAutoUpdate&&this.updateMatrix(),(!0===this.matrixWorldNeedsUpdate||!0===e)&&(void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(var t=0,r=this.children.length;r>t;t++)this.children[t].updateMatrixWorld(e)},toJSON:function(){var e={metadata:{version:4.3,type:"Object",generator:"ObjectExporter"}},t={},r={},i=function(t){if(void 0===e.materials&&(e.materials=[]),void 0===r[t.uuid]){var i=t.toJSON();delete i.metadata,r[t.uuid]=i,e.materials.push(i)}return t.uuid},n=function(r){var o={};if(o.uuid=r.uuid,o.type=r.type,""!==r.name&&(o.name=r.name),"{}"!==JSON.stringify(r.userData)&&(o.userData=r.userData),!0!==r.visible&&(o.visible=r.visible),r instanceof THREE.PerspectiveCamera)o.fov=r.fov,o.aspect=r.aspect,o.near=r.near,o.far=r.far;else if(r instanceof THREE.OrthographicCamera)o.left=r.left,o.right=r.right,o.top=r.top,o.bottom=r.bottom,o.near=r.near,o.far=r.far;else if(r instanceof THREE.AmbientLight)o.color=r.color.getHex();else if(r instanceof THREE.DirectionalLight)o.color=r.color.getHex(),o.intensity=r.intensity;else if(r instanceof THREE.PointLight)o.color=r.color.getHex(),o.intensity=r.intensity,o.distance=r.distance,o.decay=r.decay;else if(r instanceof THREE.SpotLight)o.color=r.color.getHex(),o.intensity=r.intensity,o.distance=r.distance,o.angle=r.angle,o.exponent=r.exponent,o.decay=r.decay;else if(r instanceof THREE.HemisphereLight)o.color=r.color.getHex(),o.groundColor=r.groundColor.getHex();else if(r instanceof THREE.Mesh||r instanceof THREE.Line||r instanceof THREE.PointCloud){var a=r.geometry;if(void 0===e.geometries&&(e.geometries=[]),void 0===t[a.uuid]){var s=a.toJSON();delete s.metadata,t[a.uuid]=s,e.geometries.push(s)}o.geometry=a.uuid,o.material=i(r.material),r instanceof THREE.Line&&(o.mode=r.mode)}else r instanceof THREE.Sprite&&(o.material=i(r.material));if(o.matrix=r.matrix.toArray(),0t;t++)e.vertexNormals[t]=this.vertexNormals[t].clone();for(t=0,r=this.vertexColors.length;r>t;t++)e.vertexColors[t]=this.vertexColors[t].clone();for(t=0,r=this.vertexTangents.length;r>t;t++)e.vertexTangents[t]=this.vertexTangents[t].clone();return e}},THREE.Face4=function(e,t,r,i,n,o,a){return THREE.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new THREE.Face3(e,t,r,n,o,a)},THREE.BufferAttribute=function(e,t){this.array=e,this.itemSize=t,this.needsUpdate=!1},THREE.BufferAttribute.prototype={constructor:THREE.BufferAttribute,get length(){return this.array.length},copyAt:function(e,t,r){e*=this.itemSize,r*=t.itemSize;for(var i=0,n=this.itemSize;n>i;i++)this.array[e+i]=t.array[r+i];return this},set:function(e,t){return void 0===t&&(t=0),this.array.set(e,t),this},setX:function(e,t){return this.array[e*this.itemSize]=t,this},setY:function(e,t){return this.array[e*this.itemSize+1]=t,this},setZ:function(e,t){return this.array[e*this.itemSize+2]=t,this},setXY:function(e,t,r){return e*=this.itemSize,this.array[e]=t,this.array[e+1]=r,this},setXYZ:function(e,t,r,i){return e*=this.itemSize,this.array[e]=t,this.array[e+1]=r,this.array[e+2]=i,this},setXYZW:function(e,t,r,i,n){return e*=this.itemSize,this.array[e]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=n,this},clone:function(){return new THREE.BufferAttribute(new this.array.constructor(this.array),this.itemSize)}},THREE.Int8Attribute=function(e,t){return THREE.warn("THREE.Int8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Uint8Attribute=function(e,t){return THREE.warn("THREE.Uint8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Uint8ClampedAttribute=function(e,t){return THREE.warn("THREE.Uint8ClampedAttribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Int16Attribute=function(e,t){return THREE.warn("THREE.Int16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Uint16Attribute=function(e,t){return THREE.warn("THREE.Uint16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Int32Attribute=function(e,t){return THREE.warn("THREE.Int32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Uint32Attribute=function(e,t){return THREE.warn("THREE.Uint32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Float32Attribute=function(e,t){return THREE.warn("THREE.Float32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.Float64Attribute=function(e,t){return THREE.warn("THREE.Float64Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new THREE.BufferAttribute(e,t)},THREE.DynamicBufferAttribute=function(e,t){THREE.BufferAttribute.call(this,e,t),this.updateRange={offset:0,count:-1}},THREE.DynamicBufferAttribute.prototype=Object.create(THREE.BufferAttribute.prototype),THREE.DynamicBufferAttribute.prototype.constructor=THREE.DynamicBufferAttribute,THREE.DynamicBufferAttribute.prototype.clone=function(){return new THREE.DynamicBufferAttribute(new this.array.constructor(this.array),this.itemSize)},THREE.BufferGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="BufferGeometry",this.attributes={},this.attributesKeys=[],this.offsets=this.drawcalls=[],this.boundingSphere=this.boundingBox=null},THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,addAttribute:function(e,t,r){!1==t instanceof THREE.BufferAttribute?(THREE.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.attributes[e]={array:t,itemSize:r}):(this.attributes[e]=t,this.attributesKeys=Object.keys(this.attributes))},getAttribute:function(e){return this.attributes[e]},addDrawCall:function(e,t,r){this.drawcalls.push({start:e,count:t,index:void 0!==r?r:0})},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToVector3Array(t.array),t.needsUpdate=!0),t=this.attributes.normal,void 0!==t&&((new THREE.Matrix3).getNormalMatrix(e).applyToVector3Array(t.array),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere()},center:function(){this.computeBoundingBox();var e=this.boundingBox.center().negate();return this.applyMatrix((new THREE.Matrix4).setPosition(e)),e},fromGeometry:function(e,t){t=t||{vertexColors:THREE.NoColors};var r=e.vertices,i=e.faces,n=e.faceVertexUvs,o=t.vertexColors,a=0i;i+=3)e.set(t[i],t[i+1],t[i+2]),r.expandByPoint(e)}(void 0===t||0===t.length)&&(this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&THREE.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.')}}(),computeBoundingSphere:function(){var e=new THREE.Box3,t=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var r=this.attributes.position.array;if(r){e.makeEmpty();for(var i=this.boundingSphere.center,n=0,o=r.length;o>n;n+=3)t.set(r[n],r[n+1],r[n+2]),e.expandByPoint(t);e.center(i);for(var a=0,n=0,o=r.length;o>n;n+=3)t.set(r[n],r[n+1],r[n+2]),a=Math.max(a,i.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(a),isNaN(this.boundingSphere.radius)&&THREE.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var e=this.attributes;if(e.position){var t=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(t.length),3));else for(var r=e.normal.array,i=0,n=r.length;n>i;i++)r[i]=0;var o,a,s,r=e.normal.array,h=new THREE.Vector3,l=new THREE.Vector3,c=new THREE.Vector3,u=new THREE.Vector3,E=new THREE.Vector3;if(e.index)for(var p=e.index.array,d=0f;++f){n=d[f].start,o=d[f].count;for(var T=d[f].index,i=n,n=n+o;n>i;i+=3)o=3*(T+p[i]),a=3*(T+p[i+1]),s=3*(T+p[i+2]),h.fromArray(t,o),l.fromArray(t,a),c.fromArray(t,s),u.subVectors(c,l),E.subVectors(h,l),u.cross(E),r[o]+=u.x,r[o+1]+=u.y,r[o+2]+=u.z,r[a]+=u.x,r[a+1]+=u.y,r[a+2]+=u.z,r[s]+=u.x,r[s+1]+=u.y,r[s+2]+=u.z}else for(i=0,n=t.length;n>i;i+=9)h.fromArray(t,i),l.fromArray(t,i+3),c.fromArray(t,i+6),u.subVectors(c,l),E.subVectors(h,l),u.cross(E),r[i]=u.x,r[i+1]=u.y,r[i+2]=u.z,r[i+3]=u.x,r[i+4]=u.y,r[i+5]=u.z,r[i+6]=u.x,r[i+7]=u.y,r[i+8]=u.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},computeTangents:function(){function e(e,t,r){M.fromArray(i,3*e),S.fromArray(i,3*t),C.fromArray(i,3*r),A.fromArray(o,2*e),L.fromArray(o,2*t),P.fromArray(o,2*r),u=S.x-M.x,E=C.x-M.x,p=S.y-M.y,d=C.y-M.y,f=S.z-M.z,m=C.z-M.z,T=L.x-A.x,g=P.x-A.x,R=L.y-A.y,y=P.y-A.y,v=1/(T*y-g*R),F.set((y*u-R*E)*v,(y*p-R*d)*v,(y*f-R*m)*v),B.set((T*E-g*u)*v,(T*d-g*p)*v,(T*m-g*f)*v),h[e].add(F),h[t].add(F),h[r].add(F),l[e].add(B),l[t].add(B),l[r].add(B)}function t(e){G.fromArray(n,3*e),I.copy(G),z=h[e],N.copy(z),N.sub(G.multiplyScalar(G.dot(z))).normalize(),O.crossVectors(I,z),k=O.dot(l[e]),V=0>k?-1:1,s[4*e]=N.x,s[4*e+1]=N.y,s[4*e+2]=N.z,s[4*e+3]=V}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal||void 0===this.attributes.uv)THREE.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");else{var r=this.attributes.index.array,i=this.attributes.position.array,n=this.attributes.normal.array,o=this.attributes.uv.array,a=i.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new THREE.BufferAttribute(new Float32Array(4*a),4));for(var s=this.attributes.tangent.array,h=[],l=[],c=0;a>c;c++)h[c]=new THREE.Vector3,l[c]=new THREE.Vector3;var u,E,p,d,f,m,T,g,R,y,v,H,x,b,w,_,M=new THREE.Vector3,S=new THREE.Vector3,C=new THREE.Vector3,A=new THREE.Vector2,L=new THREE.Vector2,P=new THREE.Vector2,F=new THREE.Vector3,B=new THREE.Vector3;0===this.drawcalls.length&&this.addDrawCall(0,r.length,0);var U=this.drawcalls,c=0;for(x=U.length;x>c;++c){H=U[c].start,b=U[c].count;var D=U[c].index,a=H;for(H+=b;H>a;a+=3)b=D+r[a],w=D+r[a+1],_=D+r[a+2],e(b,w,_)}var V,z,k,N=new THREE.Vector3,O=new THREE.Vector3,G=new THREE.Vector3,I=new THREE.Vector3,c=0;for(x=U.length;x>c;++c)for(H=U[c].start,b=U[c].count,D=U[c].index,a=H,H+=b;H>a;a+=3)b=D+r[a],w=D+r[a+1],_=D+r[a+2],t(b),t(w),t(_)}},computeOffsets:function(e){void 0===e&&(e=65535);for(var t=this.attributes.index.array,r=this.attributes.position.array,i=t.length/3,n=new Uint16Array(t.length),o=0,a=0,s=[{start:0,count:0,index:0}],h=s[0],l=0,c=0,u=new Int32Array(6),E=new Int32Array(r.length),p=new Int32Array(r.length),d=0;dr;r++){for(var f=c=0;3>f;f++)d=t[3*r+f],-1==E[d]?(u[2*f]=d,u[2*f+1]=-1,c++):E[d]h.index+e)for(h={start:o,count:0,index:a},s.push(h),c=0;6>c;c+=2)f=u[c+1],f>-1&&fc;c+=2)d=u[c],f=u[c+1],-1===f&&(f=a++),E[d]=f,p[f]=d,n[o++]=f-h.index,h.count++}return this.reorderBuffers(n,p,a),this.drawcalls=this.offsets=s},merge:function(e,t){if(!1!=e instanceof THREE.BufferGeometry){void 0===t&&(t=0);var r,i=this.attributes;for(r in i)if(void 0!==e.attributes[r])for(var n=i[r].array,o=e.attributes[r],a=o.array,s=0,o=o.itemSize*t;sn;n+=3)e=i[n],t=i[n+1],r=i[n+2],e=1/Math.sqrt(e*e+t*t+r*r),i[n]*=e,i[n+1]*=e,i[n+2]*=e},reorderBuffers:function(e,t,r){var i,n={};for(i in this.attributes)"index"!=i&&(n[i]=new this.attributes[i].array.constructor(this.attributes[i].itemSize*r));for(var o=0;r>o;o++){var a=t[o];for(i in this.attributes)if("index"!=i)for(var s=this.attributes[i].array,h=this.attributes[i].itemSize,l=n[i],c=0;h>c;c++)l[o*h+c]=s[a*h+c]}this.attributes.index.array=e;for(i in this.attributes)"index"!=i&&(this.attributes[i].array=n[i],this.attributes[i].numItems=this.attributes[i].itemSize*r)},toJSON:function(){var e,t={metadata:{version:4,type:"BufferGeometry",generator:"BufferGeometryExporter"},uuid:this.uuid,type:this.type,data:{attributes:{}}},r=this.attributes,i=this.offsets,n=this.boundingSphere;for(e in r){var o=r[e],a=Array.prototype.slice.call(o.array);t.data.attributes[e]={itemSize:o.itemSize,type:o.array.constructor.name,array:a}}return 0e;e++){var i=this.offsets[e];t.offsets.push({start:i.start,index:i.index,count:i.count})}return t},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.BufferGeometry.prototype),THREE.Geometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++}),this.uuid=THREE.Math.generateUUID(),this.name="",this.type="Geometry",this.vertices=[], +this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphColors=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingSphere=this.boundingBox=null,this.hasTangents=!1,this.dynamic=!0,this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.tangentsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.elementsNeedUpdate=this.verticesNeedUpdate=!1},THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(e){for(var t=(new THREE.Matrix3).getNormalMatrix(e),r=0,i=this.vertices.length;i>r;r++)this.vertices[r].applyMatrix4(e);for(r=0,i=this.faces.length;i>r;r++){e=this.faces[r],e.normal.applyMatrix3(t).normalize();for(var n=0,o=e.vertexNormals.length;o>n;n++)e.vertexNormals[n].applyMatrix3(t).normalize()}null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.normalsNeedUpdate=this.verticesNeedUpdate=!0},fromBufferGeometry:function(e){for(var t=this,r=e.attributes,i=r.position.array,n=void 0!==r.index?r.index.array:void 0,o=void 0!==r.normal?r.normal.array:void 0,a=void 0!==r.color?r.color.array:void 0,s=void 0!==r.uv?r.uv.array:void 0,h=[],l=[],c=r=0;rc;c+=3)u(d+n[c],d+n[c+1],d+n[c+2]);else for(r=0;rr;r++){var n=this.faces[r],o=this.vertices[n.a],a=this.vertices[n.b];e.subVectors(this.vertices[n.c],a),t.subVectors(o,a),e.cross(t),e.normalize(),n.normal.copy(e)}},computeVertexNormals:function(e){var t,r,i;for(i=Array(this.vertices.length),t=0,r=this.vertices.length;r>t;t++)i[t]=new THREE.Vector3;if(e){var n,o,a,s=new THREE.Vector3,h=new THREE.Vector3;for(e=0,t=this.faces.length;t>e;e++)r=this.faces[e],n=this.vertices[r.a],o=this.vertices[r.b],a=this.vertices[r.c],s.subVectors(a,o),h.subVectors(n,o),s.cross(h),i[r.a].add(s),i[r.b].add(s),i[r.c].add(s)}else for(e=0,t=this.faces.length;t>e;e++)r=this.faces[e],i[r.a].add(r.normal),i[r.b].add(r.normal),i[r.c].add(r.normal);for(t=0,r=this.vertices.length;r>t;t++)i[t].normalize();for(e=0,t=this.faces.length;t>e;e++)r=this.faces[e],r.vertexNormals[0]=i[r.a].clone(),r.vertexNormals[1]=i[r.b].clone(),r.vertexNormals[2]=i[r.c].clone()},computeMorphNormals:function(){var e,t,r,i,n;for(r=0,i=this.faces.length;i>r;r++)for(n=this.faces[r],n.__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),e=0,t=n.vertexNormals.length;t>e;e++)n.__originalVertexNormals[e]?n.__originalVertexNormals[e].copy(n.vertexNormals[e]):n.__originalVertexNormals[e]=n.vertexNormals[e].clone();var o=new THREE.Geometry;for(o.faces=this.faces,e=0,t=this.morphTargets.length;t>e;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[],n=this.morphNormals[e].faceNormals;var a,s,h=this.morphNormals[e].vertexNormals;for(r=0,i=this.faces.length;i>r;r++)a=new THREE.Vector3,s={a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3},n.push(a),h.push(s)}for(h=this.morphNormals[e],o.vertices=this.morphTargets[e].vertices,o.computeFaceNormals(),o.computeVertexNormals(),r=0,i=this.faces.length;i>r;r++)n=this.faces[r],a=h.faceNormals[r],s=h.vertexNormals[r],a.copy(n.normal),s.a.copy(n.vertexNormals[0]),s.b.copy(n.vertexNormals[1]),s.c.copy(n.vertexNormals[2])}for(r=0,i=this.faces.length;i>r;r++)n=this.faces[r],n.normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeTangents:function(){var e,t,r,i,n,o,a,s,h,l,c,u,E,p,d,f,m,T=[],g=[];r=new THREE.Vector3;var R=new THREE.Vector3,y=new THREE.Vector3,v=new THREE.Vector3,H=new THREE.Vector3;for(e=0,t=this.vertices.length;t>e;e++)T[e]=new THREE.Vector3,g[e]=new THREE.Vector3;for(e=0,t=this.faces.length;t>e;e++)n=this.faces[e],o=this.faceVertexUvs[0][e],i=n.a,m=n.b,n=n.c,a=this.vertices[i],s=this.vertices[m],h=this.vertices[n],l=o[0],c=o[1],u=o[2],o=s.x-a.x,E=h.x-a.x,p=s.y-a.y,d=h.y-a.y,s=s.z-a.z,a=h.z-a.z,h=c.x-l.x,f=u.x-l.x,c=c.y-l.y,l=u.y-l.y,u=1/(h*l-f*c),r.set((l*o-c*E)*u,(l*p-c*d)*u,(l*s-c*a)*u),R.set((h*E-f*o)*u,(h*d-f*p)*u,(h*a-f*s)*u),T[i].add(r),T[m].add(r),T[n].add(r),g[i].add(R),g[m].add(R),g[n].add(R);for(R=["a","b","c","d"],e=0,t=this.faces.length;t>e;e++)for(n=this.faces[e],r=0;ri?-1:1,n.vertexTangents[r]=new THREE.Vector4(y.x,y.y,y.z,i);this.hasTangents=!0},computeLineDistances:function(){for(var e=0,t=this.vertices,r=0,i=t.length;i>r;r++)r>0&&(e+=t[r].distanceTo(t[r-1])),this.lineDistances[r]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,r){if(!1==e instanceof THREE.Geometry)THREE.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);else{var i,n=this.vertices.length,o=this.vertices,a=e.vertices,s=this.faces,h=e.faces,l=this.faceVertexUvs[0];e=e.faceVertexUvs[0],void 0===r&&(r=0),void 0!==t&&(i=(new THREE.Matrix3).getNormalMatrix(t));for(var c=0,u=a.length;u>c;c++){var E=a[c].clone();void 0!==t&&E.applyMatrix4(t),o.push(E)}for(c=0,u=h.length;u>c;c++){var p,a=h[c],d=a.vertexNormals,f=a.vertexColors,E=new THREE.Face3(a.a+n,a.b+n,a.c+n);for(E.normal.copy(a.normal),void 0!==i&&E.normal.applyMatrix3(i).normalize(),t=0,o=d.length;o>t;t++)p=d[t].clone(),void 0!==i&&p.applyMatrix3(i).normalize(),E.vertexNormals.push(p);for(E.color.copy(a.color),t=0,o=f.length;o>t;t++)p=f[t],E.vertexColors.push(p.clone());E.materialIndex=a.materialIndex+r,s.push(E)}for(c=0,u=e.length;u>c;c++)if(r=e[c],i=[],void 0!==r){for(t=0,o=r.length;o>t;t++)i.push(r[t].clone());l.push(i)}}},mergeMesh:function(e){!1==e instanceof THREE.Mesh?THREE.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e):(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix))},mergeVertices:function(){var e,t,r,i={},n=[],o=[],a=Math.pow(10,4);for(t=0,r=this.vertices.length;r>t;t++)e=this.vertices[t],e=Math.round(e.x*a)+"_"+Math.round(e.y*a)+"_"+Math.round(e.z*a),void 0===i[e]?(i[e]=t,n.push(this.vertices[t]),o[t]=n.length-1):o[t]=o[i[e]];for(i=[],t=0,r=this.faces.length;r>t;t++)for(a=this.faces[t],a.a=o[a.a],a.b=o[a.b],a.c=o[a.c],a=[a.a,a.b,a.c],e=0;3>e;e++)if(a[e]==a[(e+1)%3]){i.push(t);break}for(t=i.length-1;t>=0;t--)for(a=i[t],this.faces.splice(a,1),o=0,r=this.faceVertexUvs.length;r>o;o++)this.faceVertexUvs[o].splice(a,1);return t=this.vertices.length-n.length,this.vertices=n,t},toJSON:function(){function e(e,t,r){return r?e|1<r;r++)e.vertices.push(t[r].clone());for(t=this.faces,r=0,i=t.length;i>r;r++)e.faces.push(t[r].clone());for(r=0,i=this.faceVertexUvs.length;i>r;r++){t=this.faceVertexUvs[r],void 0===e.faceVertexUvs[r]&&(e.faceVertexUvs[r]=[]);for(var n=0,o=t.length;o>n;n++){for(var a=t[n],s=[],h=0,l=a.length;l>h;h++)s.push(a[h].clone());e.faceVertexUvs[r].push(s)}}return e},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Geometry.prototype),THREE.GeometryIdCount=0,THREE.Camera=function(){THREE.Object3D.call(this),this.type="Camera",this.matrixWorldInverse=new THREE.Matrix4,this.projectionMatrix=new THREE.Matrix4},THREE.Camera.prototype=Object.create(THREE.Object3D.prototype),THREE.Camera.prototype.constructor=THREE.Camera,THREE.Camera.prototype.getWorldDirection=function(){var e=new THREE.Quaternion;return function(t){return t=t||new THREE.Vector3,this.getWorldQuaternion(e),t.set(0,0,-1).applyQuaternion(e)}}(),THREE.Camera.prototype.lookAt=function(){var e=new THREE.Matrix4;return function(t){e.lookAt(this.position,t,this.up),this.quaternion.setFromRotationMatrix(e)}}(),THREE.Camera.prototype.clone=function(e){return void 0===e&&(e=new THREE.Camera),THREE.Object3D.prototype.clone.call(this,e),e.matrixWorldInverse.copy(this.matrixWorldInverse),e.projectionMatrix.copy(this.projectionMatrix),e},THREE.CubeCamera=function(e,t,r){THREE.Object3D.call(this),this.type="CubeCamera";var i=new THREE.PerspectiveCamera(90,1,e,t);i.up.set(0,-1,0),i.lookAt(new THREE.Vector3(1,0,0)),this.add(i);var n=new THREE.PerspectiveCamera(90,1,e,t);n.up.set(0,-1,0),n.lookAt(new THREE.Vector3(-1,0,0)),this.add(n);var o=new THREE.PerspectiveCamera(90,1,e,t);o.up.set(0,0,1),o.lookAt(new THREE.Vector3(0,1,0)),this.add(o);var a=new THREE.PerspectiveCamera(90,1,e,t);a.up.set(0,0,-1),a.lookAt(new THREE.Vector3(0,-1,0)),this.add(a);var s=new THREE.PerspectiveCamera(90,1,e,t);s.up.set(0,-1,0),s.lookAt(new THREE.Vector3(0,0,1)),this.add(s);var h=new THREE.PerspectiveCamera(90,1,e,t);h.up.set(0,-1,0),h.lookAt(new THREE.Vector3(0,0,-1)),this.add(h),this.renderTarget=new THREE.WebGLRenderTargetCube(r,r,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter}),this.updateCubeMap=function(e,t){var r=this.renderTarget,l=r.generateMipmaps;r.generateMipmaps=!1,r.activeCubeFace=0,e.render(t,i,r),r.activeCubeFace=1,e.render(t,n,r),r.activeCubeFace=2,e.render(t,o,r),r.activeCubeFace=3,e.render(t,a,r),r.activeCubeFace=4,e.render(t,s,r),r.generateMipmaps=l,r.activeCubeFace=5,e.render(t,h,r)}},THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype),THREE.CubeCamera.prototype.constructor=THREE.CubeCamera,THREE.OrthographicCamera=function(e,t,r,i,n,o){THREE.Camera.call(this),this.type="OrthographicCamera",this.zoom=1,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()},THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype),THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera,THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(r-e,r+e,i+t,i-t,this.near,this.far)},THREE.OrthographicCamera.prototype.clone=function(){var e=new THREE.OrthographicCamera;return THREE.Camera.prototype.clone.call(this,e),e.zoom=this.zoom,e.left=this.left,e.right=this.right,e.top=this.top,e.bottom=this.bottom,e.near=this.near,e.far=this.far,e.projectionMatrix.copy(this.projectionMatrix),e},THREE.PerspectiveCamera=function(e,t,r,i){THREE.Camera.call(this),this.type="PerspectiveCamera",this.zoom=1,this.fov=void 0!==e?e:50,this.aspect=void 0!==t?t:1,this.near=void 0!==r?r:.1,this.far=void 0!==i?i:2e3,this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype),THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera,THREE.PerspectiveCamera.prototype.setLens=function(e,t){void 0===t&&(t=24),this.fov=2*THREE.Math.radToDeg(Math.atan(t/(2*e))),this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype.setViewOffset=function(e,t,r,i,n,o){this.fullWidth=e,this.fullHeight=t,this.x=r,this.y=i,this.width=n,this.height=o,this.updateProjectionMatrix()},THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var e=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var t=this.fullWidth/this.fullHeight,e=Math.tan(THREE.Math.degToRad(.5*e))*this.near,r=-e,i=t*r,t=Math.abs(t*e-i),r=Math.abs(e-r);this.projectionMatrix.makeFrustum(i+this.x*t/this.fullWidth,i+(this.x+this.width)*t/this.fullWidth,e-(this.y+this.height)*r/this.fullHeight,e-this.y*r/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(e,this.aspect,this.near,this.far)},THREE.PerspectiveCamera.prototype.clone=function(){var e=new THREE.PerspectiveCamera;return THREE.Camera.prototype.clone.call(this,e),e.zoom=this.zoom,e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e.projectionMatrix.copy(this.projectionMatrix),e},THREE.Light=function(e){THREE.Object3D.call(this),this.type="Light",this.color=new THREE.Color(e)},THREE.Light.prototype=Object.create(THREE.Object3D.prototype),THREE.Light.prototype.constructor=THREE.Light,THREE.Light.prototype.clone=function(e){return void 0===e&&(e=new THREE.Light),THREE.Object3D.prototype.clone.call(this,e),e.color.copy(this.color),e},THREE.AmbientLight=function(e){THREE.Light.call(this,e),this.type="AmbientLight"},THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype),THREE.AmbientLight.prototype.constructor=THREE.AmbientLight,THREE.AmbientLight.prototype.clone=function(){var e=new THREE.AmbientLight;return THREE.Light.prototype.clone.call(this,e),e},THREE.AreaLight=function(e,t){THREE.Light.call(this,e),this.type="AreaLight",this.normal=new THREE.Vector3(0,-1,0),this.right=new THREE.Vector3(1,0,0),this.intensity=void 0!==t?t:1,this.height=this.width=1,this.constantAttenuation=1.5,this.linearAttenuation=.5,this.quadraticAttenuation=.1},THREE.AreaLight.prototype=Object.create(THREE.Light.prototype),THREE.AreaLight.prototype.constructor=THREE.AreaLight,THREE.DirectionalLight=function(e,t){THREE.Light.call(this,e),this.type="DirectionalLight",this.position.set(0,1,0),this.target=new THREE.Object3D,this.intensity=void 0!==t?t:1,this.onlyShadow=this.castShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraLeft=-500,this.shadowCameraTop=this.shadowCameraRight=500,this.shadowCameraBottom=-500,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapHeight=this.shadowMapWidth=512,this.shadowCascade=!1,this.shadowCascadeOffset=new THREE.Vector3(0,0,-1e3),this.shadowCascadeCount=2,this.shadowCascadeBias=[0,0,0],this.shadowCascadeWidth=[512,512,512],this.shadowCascadeHeight=[512,512,512],this.shadowCascadeNearZ=[-1,.99,.998],this.shadowCascadeFarZ=[.99,.998,1],this.shadowCascadeArray=[],this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null},THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype),THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight,THREE.DirectionalLight.prototype.clone=function(){var e=new THREE.DirectionalLight;return THREE.Light.prototype.clone.call(this,e),e.target=this.target.clone(),e.intensity=this.intensity,e.castShadow=this.castShadow,e.onlyShadow=this.onlyShadow,e.shadowCameraNear=this.shadowCameraNear,e.shadowCameraFar=this.shadowCameraFar,e.shadowCameraLeft=this.shadowCameraLeft,e.shadowCameraRight=this.shadowCameraRight,e.shadowCameraTop=this.shadowCameraTop,e.shadowCameraBottom=this.shadowCameraBottom,e.shadowCameraVisible=this.shadowCameraVisible,e.shadowBias=this.shadowBias,e.shadowDarkness=this.shadowDarkness,e.shadowMapWidth=this.shadowMapWidth,e.shadowMapHeight=this.shadowMapHeight,e.shadowCascade=this.shadowCascade,e.shadowCascadeOffset.copy(this.shadowCascadeOffset),e.shadowCascadeCount=this.shadowCascadeCount,e.shadowCascadeBias=this.shadowCascadeBias.slice(0),e.shadowCascadeWidth=this.shadowCascadeWidth.slice(0),e.shadowCascadeHeight=this.shadowCascadeHeight.slice(0),e.shadowCascadeNearZ=this.shadowCascadeNearZ.slice(0),e.shadowCascadeFarZ=this.shadowCascadeFarZ.slice(0),e},THREE.HemisphereLight=function(e,t,r){THREE.Light.call(this,e),this.type="HemisphereLight",this.position.set(0,100,0),this.groundColor=new THREE.Color(t),this.intensity=void 0!==r?r:1},THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype),THREE.HemisphereLight.prototype.constructor=THREE.HemisphereLight,THREE.HemisphereLight.prototype.clone=function(){var e=new THREE.HemisphereLight;return THREE.Light.prototype.clone.call(this,e),e.groundColor.copy(this.groundColor),e.intensity=this.intensity,e},THREE.PointLight=function(e,t,r,i){THREE.Light.call(this,e),this.type="PointLight",this.intensity=void 0!==t?t:1,this.distance=void 0!==r?r:0,this.decay=void 0!==i?i:1},THREE.PointLight.prototype=Object.create(THREE.Light.prototype),THREE.PointLight.prototype.constructor=THREE.PointLight,THREE.PointLight.prototype.clone=function(){var e=new THREE.PointLight;return THREE.Light.prototype.clone.call(this,e),e.intensity=this.intensity,e.distance=this.distance,e.decay=this.decay,e},THREE.SpotLight=function(e,t,r,i,n,o){THREE.Light.call(this,e),this.type="SpotLight",this.position.set(0,1,0),this.target=new THREE.Object3D,this.intensity=void 0!==t?t:1,this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.exponent=void 0!==n?n:10,this.decay=void 0!==o?o:1,this.onlyShadow=this.castShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraFov=50,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapHeight=this.shadowMapWidth=512,this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null},THREE.SpotLight.prototype=Object.create(THREE.Light.prototype),THREE.SpotLight.prototype.constructor=THREE.SpotLight,THREE.SpotLight.prototype.clone=function(){var e=new THREE.SpotLight;return THREE.Light.prototype.clone.call(this,e),e.target=this.target.clone(),e.intensity=this.intensity,e.distance=this.distance,e.angle=this.angle,e.exponent=this.exponent,e.decay=this.decay,e.castShadow=this.castShadow,e.onlyShadow=this.onlyShadow,e.shadowCameraNear=this.shadowCameraNear,e.shadowCameraFar=this.shadowCameraFar,e.shadowCameraFov=this.shadowCameraFov,e.shadowCameraVisible=this.shadowCameraVisible,e.shadowBias=this.shadowBias,e.shadowDarkness=this.shadowDarkness,e.shadowMapWidth=this.shadowMapWidth,e.shadowMapHeight=this.shadowMapHeight,e},THREE.Cache={files:{},add:function(e,t){this.files[e]=t},get:function(e){return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}},THREE.Loader=function(e){this.statusDomElement=(this.showStatus=e)?THREE.Loader.prototype.addStatusElement():null,this.imageLoader=new THREE.ImageLoader,this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}},THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,addStatusElement:function(){var e=document.createElement("div");return e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.fontSize="0.8em",e.style.textAlign="left",e.style.background="rgba(0,0,0,0.25)",e.style.color="#fff",e.style.width="120px",e.style.padding="0.5em 0.5em 0.5em 0.5em",e.style.zIndex=1e3,e.innerHTML="Loading ...",e},updateProgress:function(e){var t="Loaded ",t=e.total?t+((100*e.loaded/e.total).toFixed(0)+"%"):t+((e.loaded/1024).toFixed(2)+" KB");this.statusDomElement.innerHTML=t},extractUrlBase:function(e){return e=e.split("/"),1===e.length?"./":(e.pop(),e.join("/")+"/")},initMaterials:function(e,t){for(var r=[],i=0;it;t++)if(e[t]instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(e,t){function r(e){return e=Math.log(e)/Math.LN2,Math.pow(2,Math.round(e))}function i(e,i,n,a,s,h,l){var c,u=t+n,E=THREE.Loader.Handlers.get(u);null!==E?c=E.load(u):(c=new THREE.Texture,E=o.imageLoader,E.crossOrigin=o.crossOrigin,E.load(u,function(e){if(!1===THREE.Math.isPowerOfTwo(e.width)||!1===THREE.Math.isPowerOfTwo(e.height)){var t=r(e.width),i=r(e.height),n=document.createElement("canvas");n.width=t,n.height=i,n.getContext("2d").drawImage(e,0,0,t,i),c.image=n}else c.image=e;c.needsUpdate=!0})),c.sourceFile=n,a&&(c.repeat.set(a[0],a[1]),1!==a[0]&&(c.wrapS=THREE.RepeatWrapping),1!==a[1]&&(c.wrapT=THREE.RepeatWrapping)),s&&c.offset.set(s[0],s[1]),h&&(n={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping},void 0!==n[h[0]]&&(c.wrapS=n[h[0]]),void 0!==n[h[1]]&&(c.wrapT=n[h[1]])),l&&(c.anisotropy=l),e[i]=c}function n(e){return(255*e[0]<<16)+(255*e[1]<<8)+255*e[2]}var o=this,a="MeshLambertMaterial",s={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(e.shading){var h=e.shading.toLowerCase();"phong"===h?a="MeshPhongMaterial":"basic"===h&&(a="MeshBasicMaterial")}return void 0!==e.blending&&void 0!==THREE[e.blending]&&(s.blending=THREE[e.blending]),void 0!==e.transparent&&(s.transparent=e.transparent),void 0!==e.opacity&&1>e.opacity&&(s.transparent=!0),void 0!==e.depthTest&&(s.depthTest=e.depthTest),void 0!==e.depthWrite&&(s.depthWrite=e.depthWrite),void 0!==e.visible&&(s.visible=e.visible),void 0!==e.flipSided&&(s.side=THREE.BackSide),void 0!==e.doubleSided&&(s.side=THREE.DoubleSide),void 0!==e.wireframe&&(s.wireframe=e.wireframe),void 0!==e.vertexColors&&("face"===e.vertexColors?s.vertexColors=THREE.FaceColors:e.vertexColors&&(s.vertexColors=THREE.VertexColors)),e.colorDiffuse?s.color=n(e.colorDiffuse):e.DbgColor&&(s.color=e.DbgColor),e.colorSpecular&&(s.specular=n(e.colorSpecular)),e.colorEmissive&&(s.emissive=n(e.colorEmissive)),void 0!==e.transparency&&(console.warn("THREE.Loader: transparency has been renamed to opacity"),e.opacity=e.transparency),void 0!==e.opacity&&(s.opacity=e.opacity),e.specularCoef&&(s.shininess=e.specularCoef),e.mapDiffuse&&t&&i(s,"map",e.mapDiffuse,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy),e.mapLight&&t&&i(s,"lightMap",e.mapLight,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy),e.mapBump&&t&&i(s,"bumpMap",e.mapBump,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy),e.mapNormal&&t&&i(s,"normalMap",e.mapNormal,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy),e.mapSpecular&&t&&i(s,"specularMap",e.mapSpecular,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy),e.mapAlpha&&t&&i(s,"alphaMap",e.mapAlpha,e.mapAlphaRepeat,e.mapAlphaOffset,e.mapAlphaWrap,e.mapAlphaAnisotropy),e.mapBumpScale&&(s.bumpScale=e.mapBumpScale),e.mapNormalFactor&&(s.normalScale=new THREE.Vector2(e.mapNormalFactor,e.mapNormalFactor)),a=new THREE[a](s),void 0!==e.DbgName&&(a.name=e.DbgName),a}},THREE.Loader.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=0,r=this.handlers.length;r>t;t+=2){var i=this.handlers[t+1];if(this.handlers[t].test(e))return i}return null}},THREE.XHRLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(e,t,r,i){var n=this,o=THREE.Cache.get(e);void 0!==o?t&&t(o):(o=new XMLHttpRequest,o.open("GET",e,!0),o.addEventListener("load",function(r){THREE.Cache.add(e,this.response),t&&t(this.response),n.manager.itemEnd(e)},!1),void 0!==r&&o.addEventListener("progress",function(e){r(e)},!1),void 0!==i&&o.addEventListener("error",function(e){i(e)},!1),void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),void 0!==this.responseType&&(o.responseType=this.responseType),o.send(null),n.manager.itemStart(e))},setResponseType:function(e){this.responseType=e},setCrossOrigin:function(e){this.crossOrigin=e}},THREE.ImageLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(e,t,r,i){var n=this,o=THREE.Cache.get(e);return void 0===o?(o=document.createElement("img"),o.addEventListener("load",function(r){THREE.Cache.add(e,this),t&&t(this),n.manager.itemEnd(e)},!1),void 0!==r&&o.addEventListener("progress",function(e){r(e)},!1),void 0!==i&&o.addEventListener("error",function(e){i(e)},!1),void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),o.src=e,n.manager.itemStart(e),o):void t(o)},setCrossOrigin:function(e){this.crossOrigin=e}},THREE.JSONLoader=function(e){THREE.Loader.call(this,e),this.withCredentials=!1},THREE.JSONLoader.prototype=Object.create(THREE.Loader.prototype),THREE.JSONLoader.prototype.constructor=THREE.JSONLoader,THREE.JSONLoader.prototype.load=function(e,t,r){r=r&&"string"==typeof r?r:this.extractUrlBase(e),this.onLoadStart(),this.loadAjaxJSON(this,e,t,r)},THREE.JSONLoader.prototype.loadAjaxJSON=function(e,t,r,i,n){var o=new XMLHttpRequest,a=0;o.onreadystatechange=function(){if(o.readyState===o.DONE)if(200===o.status||0===o.status){if(o.responseText){var s=JSON.parse(o.responseText),h=s.metadata;if(void 0!==h){if("object"===h.type)return void THREE.error("THREE.JSONLoader: "+t+" should be loaded with THREE.ObjectLoader instead.");if("scene"===h.type)return void THREE.error("THREE.JSONLoader: "+t+" seems to be a Scene. Use THREE.SceneLoader instead.")}s=e.parse(s,i),r(s.geometry,s.materials)}else THREE.error("THREE.JSONLoader: "+t+" seems to be unreachable or the file is empty.");e.onLoadComplete()}else THREE.error("THREE.JSONLoader: Couldn't load "+t+" ("+o.status+")");else o.readyState===o.LOADING?n&&(0===a&&(a=o.getResponseHeader("Content-Length")),n({total:a,loaded:o.responseText.length})):o.readyState===o.HEADERS_RECEIVED&&void 0!==n&&(a=o.getResponseHeader("Content-Length"))},o.open("GET",t,!0),o.withCredentials=this.withCredentials,o.send(null)},THREE.JSONLoader.prototype.parse=function(e,t){var r=new THREE.Geometry,i=void 0!==e.scale?1/e.scale:1;return function(t){var i,n,o,a,s,h,l,c,u,E,p,d,f,m=e.faces;h=e.vertices;var T=e.normals,g=e.colors,R=0;if(void 0!==e.uvs){for(i=0;ii;i++)r.faceVertexUvs[i]=[]}for(a=0,s=h.length;s>a;)i=new THREE.Vector3,i.x=h[a++]*t,i.y=h[a++]*t,i.z=h[a++]*t,r.vertices.push(i);for(a=0,s=m.length;s>a;)if(t=m[a++],u=1&t,o=2&t,i=8&t,l=16&t,E=32&t,h=64&t,t&=128,u){if(u=new THREE.Face3,u.a=m[a],u.b=m[a+1],u.c=m[a+3],p=new THREE.Face3,p.a=m[a+1],p.b=m[a+2],p.c=m[a+3],a+=4,o&&(o=m[a++],u.materialIndex=o,p.materialIndex=o),o=r.faces.length,i)for(i=0;R>i;i++)for(d=e.uvs[i],r.faceVertexUvs[i][o]=[],r.faceVertexUvs[i][o+1]=[],n=0;4>n;n++)c=m[a++],f=d[2*c],c=d[2*c+1],f=new THREE.Vector2(f,c),2!==n&&r.faceVertexUvs[i][o].push(f),0!==n&&r.faceVertexUvs[i][o+1].push(f);if(l&&(l=3*m[a++],u.normal.set(T[l++],T[l++],T[l]),p.normal.copy(u.normal)),E)for(i=0;4>i;i++)l=3*m[a++],E=new THREE.Vector3(T[l++],T[l++],T[l]),2!==i&&u.vertexNormals.push(E),0!==i&&p.vertexNormals.push(E);if(h&&(h=m[a++],h=g[h],u.color.setHex(h),p.color.setHex(h)),t)for(i=0;4>i;i++)h=m[a++],h=g[h],2!==i&&u.vertexColors.push(new THREE.Color(h)),0!==i&&p.vertexColors.push(new THREE.Color(h));r.faces.push(u),r.faces.push(p)}else{if(u=new THREE.Face3,u.a=m[a++],u.b=m[a++],u.c=m[a++],o&&(o=m[a++],u.materialIndex=o),o=r.faces.length,i)for(i=0;R>i;i++)for(d=e.uvs[i],r.faceVertexUvs[i][o]=[],n=0;3>n;n++)c=m[a++],f=d[2*c],c=d[2*c+1],f=new THREE.Vector2(f,c),r.faceVertexUvs[i][o].push(f);if(l&&(l=3*m[a++],u.normal.set(T[l++],T[l++],T[l])),E)for(i=0;3>i;i++)l=3*m[a++],E=new THREE.Vector3(T[l++],T[l++],T[l]),u.vertexNormals.push(E);if(h&&(h=m[a++],u.color.setHex(g[h])),t)for(i=0;3>i;i++)h=m[a++],u.vertexColors.push(new THREE.Color(g[h]));r.faces.push(u)}}(i),function(){var t=void 0!==e.influencesPerVertex?e.influencesPerVertex:2;if(e.skinWeights)for(var i=0,n=e.skinWeights.length;n>i;i+=t)r.skinWeights.push(new THREE.Vector4(e.skinWeights[i],t>1?e.skinWeights[i+1]:0,t>2?e.skinWeights[i+2]:0,t>3?e.skinWeights[i+3]:0));if(e.skinIndices)for(i=0,n=e.skinIndices.length;n>i;i+=t)r.skinIndices.push(new THREE.Vector4(e.skinIndices[i],t>1?e.skinIndices[i+1]:0,t>2?e.skinIndices[i+2]:0,t>3?e.skinIndices[i+3]:0));r.bones=e.bones,r.bones&&0i;i++)for(r.morphTargets[i]={},r.morphTargets[i].name=e.morphTargets[i].name,r.morphTargets[i].vertices=[],s=r.morphTargets[i].vertices,h=e.morphTargets[i].vertices,o=0,a=h.length;a>o;o+=3){var l=new THREE.Vector3;l.x=h[o]*t,l.y=h[o+1]*t,l.z=h[o+2]*t,s.push(l)}}if(void 0!==e.morphColors)for(i=0,n=e.morphColors.length;n>i;i++)for(r.morphColors[i]={},r.morphColors[i].name=e.morphColors[i].name,r.morphColors[i].colors=[],a=r.morphColors[i].colors,s=e.morphColors[i].colors,t=0,o=s.length;o>t;t+=3)h=new THREE.Color(16755200),h.setRGB(s[t],s[t+1],s[t+2]),a.push(h)}(i),r.computeFaceNormals(),r.computeBoundingSphere(),void 0===e.materials||0===e.materials.length?{geometry:r}:(i=this.initMaterials(e.materials,t),this.needsTangents(i)&&r.computeTangents(),{geometry:r,materials:i})},THREE.LoadingManager=function(e,t,r){var i=this,n=0,o=0;this.onLoad=e,this.onProgress=t,this.onError=r,this.itemStart=function(e){o++},this.itemEnd=function(e){n++,void 0!==i.onProgress&&i.onProgress(e,n,o),n===o&&void 0!==i.onLoad&&i.onLoad()}},THREE.DefaultLoadingManager=new THREE.LoadingManager,THREE.BufferGeometryLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.BufferGeometryLoader.prototype={constructor:THREE.BufferGeometryLoader,load:function(e,t,r,i){var n=this,o=new THREE.XHRLoader(n.manager);o.setCrossOrigin(this.crossOrigin),o.load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e){var t,r=new THREE.BufferGeometry,i=e.data.attributes;for(t in i){var n=i[t],o=new self[n.type](n.array);r.addAttribute(t,new THREE.BufferAttribute(o,n.itemSize))}return i=e.data.offsets, +void 0!==i&&(r.offsets=JSON.parse(JSON.stringify(i))),e=e.data.boundingSphere,void 0!==e&&(i=new THREE.Vector3,void 0!==e.center&&i.fromArray(e.center),r.boundingSphere=new THREE.Sphere(i,e.radius)),r}},THREE.MaterialLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.MaterialLoader.prototype={constructor:THREE.MaterialLoader,load:function(e,t,r,i){var n=this,o=new THREE.XHRLoader(n.manager);o.setCrossOrigin(this.crossOrigin),o.load(e,function(e){t(n.parse(JSON.parse(e)))},r,i)},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e){var t=new THREE[e.type];if(void 0!==e.color&&t.color.setHex(e.color),void 0!==e.emissive&&t.emissive.setHex(e.emissive),void 0!==e.specular&&t.specular.setHex(e.specular),void 0!==e.shininess&&(t.shininess=e.shininess),void 0!==e.uniforms&&(t.uniforms=e.uniforms),void 0!==e.vertexShader&&(t.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(t.fragmentShader=e.fragmentShader),void 0!==e.vertexColors&&(t.vertexColors=e.vertexColors),void 0!==e.shading&&(t.shading=e.shading),void 0!==e.blending&&(t.blending=e.blending),void 0!==e.side&&(t.side=e.side),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.transparent&&(t.transparent=e.transparent),void 0!==e.wireframe&&(t.wireframe=e.wireframe),void 0!==e.size&&(t.size=e.size),void 0!==e.sizeAttenuation&&(t.sizeAttenuation=e.sizeAttenuation),void 0!==e.materials)for(var r=0,i=e.materials.length;i>r;r++)t.materials.push(this.parse(e.materials[r]));return t}},THREE.ObjectLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager,this.texturePath=""},THREE.ObjectLoader.prototype={constructor:THREE.ObjectLoader,load:function(e,t,r,i){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var n=this,o=new THREE.XHRLoader(n.manager);o.setCrossOrigin(this.crossOrigin),o.load(e,function(e){n.parse(JSON.parse(e),t)},r,i)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var r=this.parseGeometries(e.geometries),i=this.parseImages(e.images,function(){void 0!==t&&t(n)}),i=this.parseTextures(e.textures,i),i=this.parseMaterials(e.materials,i),n=this.parseObject(e.object,r,i);return void 0!==e.images&&0!==e.images.length||void 0===t||t(n),n},parseGeometries:function(e){var t={};if(void 0!==e)for(var r=new THREE.JSONLoader,i=new THREE.BufferGeometryLoader,n=0,o=e.length;o>n;n++){var a,s=e[n];switch(s.type){case"PlaneGeometry":case"PlaneBufferGeometry":a=new THREE[s.type](s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"CubeGeometry":a=new THREE.BoxGeometry(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":a=new THREE.CircleGeometry(s.radius,s.segments);break;case"CylinderGeometry":a=new THREE.CylinderGeometry(s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded);break;case"SphereGeometry":a=new THREE.SphereGeometry(s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"IcosahedronGeometry":a=new THREE.IcosahedronGeometry(s.radius,s.detail);break;case"TorusGeometry":a=new THREE.TorusGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":a=new THREE.TorusKnotGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.p,s.q,s.heightScale);break;case"BufferGeometry":a=i.parse(s);break;case"Geometry":a=r.parse(s.data).geometry}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),t[s.uuid]=a}return t},parseMaterials:function(e,t){var r={};if(void 0!==e)for(var i=function(e){return void 0===t[e]&&THREE.warn("THREE.ObjectLoader: Undefined texture",e),t[e]},n=new THREE.MaterialLoader,o=0,a=e.length;a>o;o++){var s=e[o],h=n.parse(s);h.uuid=s.uuid,void 0!==s.name&&(h.name=s.name),void 0!==s.map&&(h.map=i(s.map)),void 0!==s.bumpMap&&(h.bumpMap=i(s.bumpMap),s.bumpScale&&(h.bumpScale=new THREE.Vector2(s.bumpScale,s.bumpScale))),void 0!==s.alphaMap&&(h.alphaMap=i(s.alphaMap)),void 0!==s.envMap&&(h.envMap=i(s.envMap)),void 0!==s.normalMap&&(h.normalMap=i(s.normalMap),s.normalScale&&(h.normalScale=new THREE.Vector2(s.normalScale,s.normalScale))),void 0!==s.lightMap&&(h.lightMap=i(s.lightMap)),void 0!==s.specularMap&&(h.specularMap=i(s.specularMap)),r[s.uuid]=h}return r},parseImages:function(e,t){var r=this,i={};if(void 0!==e&&0a;a++){var h=e[a],l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?h.url:r.texturePath+h.url;i[h.uuid]=n(l)}}return i},parseTextures:function(e,t){var r={};if(void 0!==e)for(var i=0,n=e.length;n>i;i++){var o=e[i];void 0===o.image&&THREE.warn('THREE.ObjectLoader: No "image" speficied for',o.uuid),void 0===t[o.image]&&THREE.warn("THREE.ObjectLoader: Undefined image",o.image);var a=new THREE.Texture(t[o.image]);a.needsUpdate=!0,a.uuid=o.uuid,void 0!==o.name&&(a.name=o.name),void 0!==o.repeat&&(a.repeat=new THREE.Vector2(o.repeat[0],o.repeat[1])),void 0!==o.minFilter&&(a.minFilter=THREE[o.minFilter]),void 0!==o.magFilter&&(a.magFilter=THREE[o.magFilter]),void 0!==o.anisotropy&&(a.anisotropy=o.anisotropy),o.wrap instanceof Array&&(a.wrapS=THREE[o.wrap[0]],a.wrapT=THREE[o.wrap[1]]),r[o.uuid]=a}return r},parseObject:function(){var e=new THREE.Matrix4;return function(t,r,i){var n;n=function(e){return void 0===r[e]&&THREE.warn("THREE.ObjectLoader: Undefined geometry",e),r[e]};var o=function(e){return void 0===i[e]&&THREE.warn("THREE.ObjectLoader: Undefined material",e),i[e]};switch(t.type){case"Scene":n=new THREE.Scene;break;case"PerspectiveCamera":n=new THREE.PerspectiveCamera(t.fov,t.aspect,t.near,t.far);break;case"OrthographicCamera":n=new THREE.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far);break;case"AmbientLight":n=new THREE.AmbientLight(t.color);break;case"DirectionalLight":n=new THREE.DirectionalLight(t.color,t.intensity);break;case"PointLight":n=new THREE.PointLight(t.color,t.intensity,t.distance,t.decay);break;case"SpotLight":n=new THREE.SpotLight(t.color,t.intensity,t.distance,t.angle,t.exponent,t.decay);break;case"HemisphereLight":n=new THREE.HemisphereLight(t.color,t.groundColor,t.intensity);break;case"Mesh":n=new THREE.Mesh(n(t.geometry),o(t.material));break;case"Line":n=new THREE.Line(n(t.geometry),o(t.material),t.mode);break;case"PointCloud":n=new THREE.PointCloud(n(t.geometry),o(t.material));break;case"Sprite":n=new THREE.Sprite(o(t.material));break;case"Group":n=new THREE.Group;break;default:n=new THREE.Object3D}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var a in t.children)n.add(this.parseObject(t.children[a],r,i));return n}}()},THREE.TextureLoader=function(e){this.manager=void 0!==e?e:THREE.DefaultLoadingManager},THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(e,t,r,i){var n=new THREE.ImageLoader(this.manager);n.setCrossOrigin(this.crossOrigin),n.load(e,function(e){e=new THREE.Texture(e),e.needsUpdate=!0,void 0!==t&&t(e)},r,i)},setCrossOrigin:function(e){this.crossOrigin=e}},THREE.DataTextureLoader=THREE.BinaryTextureLoader=function(){this._parser=null},THREE.BinaryTextureLoader.prototype={constructor:THREE.BinaryTextureLoader,load:function(e,t,r,i){var n=this,o=new THREE.DataTexture,a=new THREE.XHRLoader;return a.setResponseType("arraybuffer"),a.load(e,function(e){(e=n._parser(e))&&(void 0!==e.image?o.image=e.image:void 0!==e.data&&(o.image.width=e.width,o.image.height=e.height,o.image.data=e.data),o.wrapS=void 0!==e.wrapS?e.wrapS:THREE.ClampToEdgeWrapping,o.wrapT=void 0!==e.wrapT?e.wrapT:THREE.ClampToEdgeWrapping,o.magFilter=void 0!==e.magFilter?e.magFilter:THREE.LinearFilter,o.minFilter=void 0!==e.minFilter?e.minFilter:THREE.LinearMipMapLinearFilter,o.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.format&&(o.format=e.format),void 0!==e.type&&(o.type=e.type),void 0!==e.mipmaps&&(o.mipmaps=e.mipmaps),1===e.mipmapCount&&(o.minFilter=THREE.LinearFilter),o.needsUpdate=!0,t&&t(o,e))},r,i),o}},THREE.CompressedTextureLoader=function(){this._parser=null},THREE.CompressedTextureLoader.prototype={constructor:THREE.CompressedTextureLoader,load:function(e,t,r){var i=this,n=[],o=new THREE.CompressedTexture;o.image=n;var a=new THREE.XHRLoader;if(a.setResponseType("arraybuffer"),e instanceof Array){var s=0;r=function(r){a.load(e[r],function(e){e=i._parser(e,!0),n[r]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},s+=1,6===s&&(1==e.mipmapCount&&(o.minFilter=THREE.LinearFilter),o.format=e.format,o.needsUpdate=!0,t&&t(o))})};for(var h=0,l=e.length;l>h;++h)r(h)}else a.load(e,function(e){if(e=i._parser(e,!0),e.isCubemap)for(var r=e.mipmaps.length/e.mipmapCount,a=0;r>a;a++){n[a]={mipmaps:[]};for(var s=0;sthis.opacity&&(e.opacity=this.opacity),!1!==this.transparent&&(e.transparent=this.transparent),!1!==this.wireframe&&(e.wireframe=this.wireframe),e},clone:function(e){return void 0===e&&(e=new THREE.Material),e.name=this.name,e.side=this.side,e.opacity=this.opacity,e.transparent=this.transparent,e.blending=this.blending,e.blendSrc=this.blendSrc,e.blendDst=this.blendDst,e.blendEquation=this.blendEquation,e.blendSrcAlpha=this.blendSrcAlpha,e.blendDstAlpha=this.blendDstAlpha,e.blendEquationAlpha=this.blendEquationAlpha,e.depthTest=this.depthTest,e.depthWrite=this.depthWrite,e.polygonOffset=this.polygonOffset,e.polygonOffsetFactor=this.polygonOffsetFactor,e.polygonOffsetUnits=this.polygonOffsetUnits,e.alphaTest=this.alphaTest,e.overdraw=this.overdraw,e.visible=this.visible,e},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.Material.prototype),THREE.MaterialIdCount=0,THREE.LineBasicMaterial=function(e){THREE.Material.call(this),this.type="LineBasicMaterial",this.color=new THREE.Color(16777215),this.linewidth=1,this.linejoin=this.linecap="round",this.vertexColors=THREE.NoColors,this.fog=!0,this.setValues(e)},THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial,THREE.LineBasicMaterial.prototype.clone=function(){var e=new THREE.LineBasicMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.linewidth=this.linewidth,e.linecap=this.linecap,e.linejoin=this.linejoin,e.vertexColors=this.vertexColors,e.fog=this.fog,e},THREE.LineDashedMaterial=function(e){THREE.Material.call(this),this.type="LineDashedMaterial",this.color=new THREE.Color(16777215),this.scale=this.linewidth=1,this.dashSize=3,this.gapSize=1,this.vertexColors=!1,this.fog=!0,this.setValues(e)},THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype),THREE.LineDashedMaterial.prototype.constructor=THREE.LineDashedMaterial,THREE.LineDashedMaterial.prototype.clone=function(){var e=new THREE.LineDashedMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.linewidth=this.linewidth,e.scale=this.scale,e.dashSize=this.dashSize,e.gapSize=this.gapSize,e.vertexColors=this.vertexColors,e.fog=this.fog,e},THREE.MeshBasicMaterial=function(e){THREE.Material.call(this),this.type="MeshBasicMaterial",this.color=new THREE.Color(16777215),this.envMap=this.alphaMap=this.specularMap=this.lightMap=this.map=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphTargets=this.skinning=!1,this.setValues(e)},THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial,THREE.MeshBasicMaterial.prototype.clone=function(){var e=new THREE.MeshBasicMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.alphaMap=this.alphaMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e},THREE.MeshLambertMaterial=function(e){THREE.Material.call(this),this.type="MeshLambertMaterial",this.color=new THREE.Color(16777215),this.emissive=new THREE.Color(0),this.wrapAround=!1,this.wrapRGB=new THREE.Vector3(1,1,1),this.envMap=this.alphaMap=this.specularMap=this.lightMap=this.map=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(e)},THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial,THREE.MeshLambertMaterial.prototype.clone=function(){var e=new THREE.MeshLambertMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.emissive.copy(this.emissive),e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.specularMap=this.specularMap,e.alphaMap=this.alphaMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e},THREE.MeshPhongMaterial=function(e){THREE.Material.call(this),this.type="MeshPhongMaterial",this.color=new THREE.Color(16777215),this.emissive=new THREE.Color(0),this.specular=new THREE.Color(1118481),this.shininess=30,this.wrapAround=this.metal=!1,this.wrapRGB=new THREE.Vector3(1,1,1),this.bumpMap=this.lightMap=this.map=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new THREE.Vector2(1,1),this.envMap=this.alphaMap=this.specularMap=null,this.combine=THREE.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=THREE.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinejoin=this.wireframeLinecap="round",this.vertexColors=THREE.NoColors,this.morphNormals=this.morphTargets=this.skinning=!1,this.setValues(e)},THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial,THREE.MeshPhongMaterial.prototype.clone=function(){var e=new THREE.MeshPhongMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.emissive.copy(this.emissive),e.specular.copy(this.specular),e.shininess=this.shininess,e.metal=this.metal,e.wrapAround=this.wrapAround,e.wrapRGB.copy(this.wrapRGB),e.map=this.map,e.lightMap=this.lightMap,e.bumpMap=this.bumpMap,e.bumpScale=this.bumpScale,e.normalMap=this.normalMap,e.normalScale.copy(this.normalScale),e.specularMap=this.specularMap,e.alphaMap=this.alphaMap,e.envMap=this.envMap,e.combine=this.combine,e.reflectivity=this.reflectivity,e.refractionRatio=this.refractionRatio,e.fog=this.fog,e.shading=this.shading,e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e.wireframeLinecap=this.wireframeLinecap,e.wireframeLinejoin=this.wireframeLinejoin,e.vertexColors=this.vertexColors,e.skinning=this.skinning,e.morphTargets=this.morphTargets,e.morphNormals=this.morphNormals,e},THREE.MeshDepthMaterial=function(e){THREE.Material.call(this),this.type="MeshDepthMaterial",this.wireframe=this.morphTargets=!1,this.wireframeLinewidth=1,this.setValues(e)},THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial,THREE.MeshDepthMaterial.prototype.clone=function(){var e=new THREE.MeshDepthMaterial;return THREE.Material.prototype.clone.call(this,e),e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e},THREE.MeshNormalMaterial=function(e){THREE.Material.call(this,e),this.type="MeshNormalMaterial",this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.setValues(e)},THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype),THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial,THREE.MeshNormalMaterial.prototype.clone=function(){var e=new THREE.MeshNormalMaterial;return THREE.Material.prototype.clone.call(this,e),e.wireframe=this.wireframe,e.wireframeLinewidth=this.wireframeLinewidth,e},THREE.MeshFaceMaterial=function(e){this.uuid=THREE.Math.generateUUID(),this.type="MeshFaceMaterial",this.materials=e instanceof Array?e:[]},THREE.MeshFaceMaterial.prototype={constructor:THREE.MeshFaceMaterial,toJSON:function(){for(var e={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},t=0,r=this.materials.length;r>t;t++)e.materials.push(this.materials[t].toJSON());return e},clone:function(){for(var e=new THREE.MeshFaceMaterial,t=0;ta){var h=t.closestPointToPoint(e);h.applyMatrix4(n.matrixWorld);var l=r.ray.origin.distanceTo(h);i.push({distance:l,distanceToRay:a,point:h.clone(),index:o,face:null,object:n})}};if(o instanceof THREE.BufferGeometry){var l=o.attributes,c=l.position.array;if(void 0!==l.index){var l=l.index.array,u=o.offsets;0===u.length&&(u=[{start:0,count:l.length,index:0}]);for(var E=0,p=u.length;p>E;++E)for(var d=u[E].start,f=u[E].index,o=d,d=d+u[E].count;d>o;o++){var m=f+l[o];h.fromArray(c,3*m),a(h,m)}}else for(l=c.length/3,o=0;l>o;o++)h.set(c[3*o],c[3*o+1],c[3*o+2]),a(h,o)}else for(h=this.geometry.vertices,o=0;oa;a+=u){var R=g+p[a+1];s.fromArray(E,3*(g+p[a])),h.fromArray(E,3*R),R=t.distanceSqToSegment(s,h,c,l),R>o||(R=t.origin.distanceTo(c),Ri.far||n.push({distance:R,point:l.clone().applyMatrix4(this.matrixWorld),index:a,offsetIndex:f,face:null,faceIndex:null,object:this}))}}else for(E=E.position.array,a=0;ao||(R=t.origin.distanceTo(c),Ri.far||n.push({distance:R,point:l.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this}))}else if(a instanceof THREE.Geometry)for(s=a.vertices,h=s.length,a=0;h-1>a;a+=u)R=t.distanceSqToSegment(s[a],s[a+1],c,l),R>o||(R=t.origin.distanceTo(c),Ri.far||n.push({distance:R,point:l.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this}))}}}(),THREE.Line.prototype.clone=function(e){return void 0===e&&(e=new THREE.Line(this.geometry,this.material,this.mode)),THREE.Object3D.prototype.clone.call(this,e), +e},THREE.Mesh=function(e,t){THREE.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==e?e:new THREE.Geometry,this.material=void 0!==t?t:new THREE.MeshBasicMaterial({color:16777215*Math.random()}),this.updateMorphTargets()},THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype),THREE.Mesh.prototype.constructor=THREE.Mesh,THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0e;e++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[e].name]=e}},THREE.Mesh.prototype.getMorphTargetIndexByName=function(e){return void 0!==this.morphTargetDictionary[e]?this.morphTargetDictionary[e]:(THREE.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+e+" does not exist. Returning 0."),0)},THREE.Mesh.prototype.raycast=function(){var e=new THREE.Matrix4,t=new THREE.Ray,r=new THREE.Sphere,i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3;return function(a,s){var h=this.geometry;if(null===h.boundingSphere&&h.computeBoundingSphere(),r.copy(h.boundingSphere),r.applyMatrix4(this.matrixWorld),!1!==a.ray.isIntersectionSphere(r)&&(e.getInverse(this.matrixWorld),t.copy(a.ray).applyMatrix4(e),null===h.boundingBox||!1!==t.isIntersectionBox(h.boundingBox)))if(h instanceof THREE.BufferGeometry){var l=this.material;if(void 0!==l){var c,u,E=h.attributes,p=a.precision;if(void 0!==E.index){var d=E.index.array,f=E.position.array,m=h.offsets;0===m.length&&(m=[{start:0,count:d.length,index:0}]);for(var T=0,g=m.length;g>T;++T)for(var E=m[T].start,R=m[T].index,h=E,y=E+m[T].count;y>h;h+=3){E=R+d[h],c=R+d[h+1],u=R+d[h+2],i.fromArray(f,3*E),n.fromArray(f,3*c),o.fromArray(f,3*u);var v=l.side===THREE.BackSide?t.intersectTriangle(o,n,i,!0):t.intersectTriangle(i,n,o,l.side!==THREE.DoubleSide);if(null!==v){v.applyMatrix4(this.matrixWorld);var H=a.ray.origin.distanceTo(v);p>H||Ha.far||s.push({distance:H,point:v,face:new THREE.Face3(E,c,u,THREE.Triangle.normal(i,n,o)),faceIndex:null,object:this})}}}else for(f=E.position.array,d=h=0,y=f.length;y>h;h+=3,d+=9)E=h,c=h+1,u=h+2,i.fromArray(f,d),n.fromArray(f,d+3),o.fromArray(f,d+6),v=l.side===THREE.BackSide?t.intersectTriangle(o,n,i,!0):t.intersectTriangle(i,n,o,l.side!==THREE.DoubleSide),null!==v&&(v.applyMatrix4(this.matrixWorld),H=a.ray.origin.distanceTo(v),p>H||Ha.far||s.push({distance:H,point:v,face:new THREE.Face3(E,c,u,THREE.Triangle.normal(i,n,o)),faceIndex:null,object:this}))}}else if(h instanceof THREE.Geometry)for(d=this.material instanceof THREE.MeshFaceMaterial,f=!0===d?this.material.materials:null,p=a.precision,m=h.vertices,T=0,g=h.faces.length;g>T;T++)if(R=h.faces[T],l=!0===d?f[R.materialIndex]:this.material,void 0!==l){if(E=m[R.a],c=m[R.b],u=m[R.c],!0===l.morphTargets){v=h.morphTargets,H=this.morphTargetInfluences,i.set(0,0,0),n.set(0,0,0),o.set(0,0,0);for(var y=0,x=v.length;x>y;y++){var b=H[y];if(0!==b){var w=v[y].vertices;i.x+=(w[R.a].x-E.x)*b,i.y+=(w[R.a].y-E.y)*b,i.z+=(w[R.a].z-E.z)*b,n.x+=(w[R.b].x-c.x)*b,n.y+=(w[R.b].y-c.y)*b,n.z+=(w[R.b].z-c.z)*b,o.x+=(w[R.c].x-u.x)*b,o.y+=(w[R.c].y-u.y)*b,o.z+=(w[R.c].z-u.z)*b}}i.add(E),n.add(c),o.add(u),E=i,c=n,u=o}v=l.side===THREE.BackSide?t.intersectTriangle(u,c,E,!0):t.intersectTriangle(E,c,u,l.side!==THREE.DoubleSide),null!==v&&(v.applyMatrix4(this.matrixWorld),H=a.ray.origin.distanceTo(v),p>H||Ha.far||s.push({distance:H,point:v,face:R,faceIndex:T,object:this}))}}}(),THREE.Mesh.prototype.clone=function(e,t){return void 0===e&&(e=new THREE.Mesh(this.geometry,this.material)),THREE.Object3D.prototype.clone.call(this,e,t),e},THREE.Bone=function(e){THREE.Object3D.call(this),this.type="Bone",this.skin=e},THREE.Bone.prototype=Object.create(THREE.Object3D.prototype),THREE.Bone.prototype.constructor=THREE.Bone,THREE.Skeleton=function(e,t,r){if(this.useVertexTexture=void 0!==r?r:!0,this.identityMatrix=new THREE.Matrix4,e=e||[],this.bones=e.slice(0),this.useVertexTexture?(this.boneTextureHeight=this.boneTextureWidth=e=256t;t++)this.boneInverses.push(new THREE.Matrix4)},THREE.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var e=0,t=this.bones.length;t>e;e++){var r=new THREE.Matrix4;this.bones[e]&&r.getInverse(this.bones[e].matrixWorld),this.boneInverses.push(r)}},THREE.Skeleton.prototype.pose=function(){for(var e,t=0,r=this.bones.length;r>t;t++)(e=this.bones[t])&&e.matrixWorld.getInverse(this.boneInverses[t]);for(t=0,r=this.bones.length;r>t;t++)(e=this.bones[t])&&(e.parent?(e.matrix.getInverse(e.parent.matrixWorld),e.matrix.multiply(e.matrixWorld)):e.matrix.copy(e.matrixWorld),e.matrix.decompose(e.position,e.quaternion,e.scale))},THREE.Skeleton.prototype.update=function(){var e=new THREE.Matrix4;return function(){for(var t=0,r=this.bones.length;r>t;t++)e.multiplyMatrices(this.bones[t]?this.bones[t].matrixWorld:this.identityMatrix,this.boneInverses[t]),e.flattenToArrayOffset(this.boneMatrices,16*t);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}(),THREE.SkinnedMesh=function(e,t,r){if(THREE.Mesh.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new THREE.Matrix4,this.bindMatrixInverse=new THREE.Matrix4,e=[],this.geometry&&void 0!==this.geometry.bones){for(var i,n,o,a,s=0,h=this.geometry.bones.length;h>s;++s)i=this.geometry.bones[s],n=i.pos,o=i.rotq,a=i.scl,t=new THREE.Bone(this),e.push(t),t.name=i.name,t.position.set(n[0],n[1],n[2]),t.quaternion.set(o[0],o[1],o[2],o[3]),void 0!==a?t.scale.set(a[0],a[1],a[2]):t.scale.set(1,1,1);for(s=0,h=this.geometry.bones.length;h>s;++s)i=this.geometry.bones[s],-1!==i.parent?e[i.parent].add(e[s]):this.add(e[s])}this.normalizeSkinWeights(),this.updateMatrixWorld(!0),this.bind(new THREE.Skeleton(e,void 0,r))},THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh,THREE.SkinnedMesh.prototype.bind=function(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.getInverse(t)},THREE.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()},THREE.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof THREE.Geometry)for(var e=0;en;n++){var a=e.morphTargets[n].name.match(i);if(a&&1s.end&&(s.end=n),t||(t=a)}}e.firstAnimation=t},THREE.MorphAnimMesh.prototype.setAnimationLabel=function(e,t,r){this.geometry.animations||(this.geometry.animations={}),this.geometry.animations[e]={start:t,end:r}},THREE.MorphAnimMesh.prototype.playAnimation=function(e,t){var r=this.geometry.animations[e];r?(this.setFrameRange(r.start,r.end),this.duration=(r.end-r.start)/t*1e3,this.time=0):THREE.warn("THREE.MorphAnimMesh: animation["+e+"] undefined in .playAnimation()")},THREE.MorphAnimMesh.prototype.updateAnimation=function(e){var t=this.duration/this.length;this.time+=this.direction*e,this.mirroredLoop?(this.time>this.duration||0>this.time)&&(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),0>this.time&&(this.time=0,this.directionBackwards=!1)):(this.time%=this.duration,0>this.time&&(this.time+=this.duration)),e=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/t),0,this.length-1),e!==this.currentKeyframe&&(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[e]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=e),t=this.time%t/t,this.directionBackwards&&(t=1-t),this.morphTargetInfluences[this.currentKeyframe]=t,this.morphTargetInfluences[this.lastKeyframe]=1-t},THREE.MorphAnimMesh.prototype.interpolateTargets=function(e,t,r){for(var i=this.morphTargetInfluences,n=0,o=i.length;o>n;n++)i[n]=0;e>-1&&(i[e]=1-r),t>-1&&(i[t]=r)},THREE.MorphAnimMesh.prototype.clone=function(e){return void 0===e&&(e=new THREE.MorphAnimMesh(this.geometry,this.material)),e.duration=this.duration,e.mirroredLoop=this.mirroredLoop,e.time=this.time,e.lastKeyframe=this.lastKeyframe,e.currentKeyframe=this.currentKeyframe,e.direction=this.direction,e.directionBackwards=this.directionBackwards,THREE.Mesh.prototype.clone.call(this,e),e},THREE.LOD=function(){THREE.Object3D.call(this),this.objects=[]},THREE.LOD.prototype=Object.create(THREE.Object3D.prototype),THREE.LOD.prototype.constructor=THREE.LOD,THREE.LOD.prototype.addLevel=function(e,t){void 0===t&&(t=0),t=Math.abs(t);for(var r=0;rt&&!(ei&&r>=this.objects[i].distance;i++)this.objects[i-1].object.visible=!1,this.objects[i].object.visible=!0;for(;n>i;i++)this.objects[i].object.visible=!1}}}(),THREE.LOD.prototype.clone=function(e){void 0===e&&(e=new THREE.LOD),THREE.Object3D.prototype.clone.call(this,e);for(var t=0,r=this.objects.length;r>t;t++){var i=this.objects[t].object.clone();i.visible=0===t,e.addLevel(i,this.objects[t].distance)}return e},THREE.Sprite=function(){var e=new Uint16Array([0,1,2,0,2,3]),t=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),r=new Float32Array([0,0,1,0,1,1,0,1]),i=new THREE.BufferGeometry;return i.addAttribute("index",new THREE.BufferAttribute(e,1)),i.addAttribute("position",new THREE.BufferAttribute(t,3)),i.addAttribute("uv",new THREE.BufferAttribute(r,2)),function(e){THREE.Object3D.call(this),this.type="Sprite",this.geometry=i,this.material=void 0!==e?e:new THREE.SpriteMaterial}}(),THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype),THREE.Sprite.prototype.constructor=THREE.Sprite,THREE.Sprite.prototype.raycast=function(){var e=new THREE.Vector3;return function(t,r){e.setFromMatrixPosition(this.matrixWorld);var i=t.ray.distanceToPoint(e);i>this.scale.x||r.push({distance:i,point:this.position,face:null,object:this})}}(),THREE.Sprite.prototype.clone=function(e){return void 0===e&&(e=new THREE.Sprite(this.material)),THREE.Object3D.prototype.clone.call(this,e),e},THREE.Particle=THREE.Sprite,THREE.LensFlare=function(e,t,r,i,n){THREE.Object3D.call(this),this.lensFlares=[],this.positionScreen=new THREE.Vector3,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,r,i,n)},THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype),THREE.LensFlare.prototype.constructor=THREE.LensFlare,THREE.LensFlare.prototype.add=function(e,t,r,i,n,o){void 0===t&&(t=-1),void 0===r&&(r=0),void 0===o&&(o=1),void 0===n&&(n=new THREE.Color(16777215)),void 0===i&&(i=THREE.NormalBlending),r=Math.min(r,Math.max(0,r)),this.lensFlares.push({texture:e,size:t,distance:r,x:0,y:0,z:0,scale:1,rotation:1,opacity:o,color:n,blending:i})},THREE.LensFlare.prototype.updateLensFlares=function(){var e,t,r=this.lensFlares.length,i=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(e=0;r>e;e++)t=this.lensFlares[e],t.x=this.positionScreen.x+i*t.distance,t.y=this.positionScreen.y+n*t.distance,t.wantedRotation=t.x*Math.PI*.25,t.rotation+=.25*(t.wantedRotation-t.rotation)},THREE.Scene=function(){THREE.Object3D.call(this),this.type="Scene",this.overrideMaterial=this.fog=null,this.autoUpdate=!0},THREE.Scene.prototype=Object.create(THREE.Object3D.prototype),THREE.Scene.prototype.constructor=THREE.Scene,THREE.Scene.prototype.clone=function(e){return void 0===e&&(e=new THREE.Scene),THREE.Object3D.prototype.clone.call(this,e),null!==this.fog&&(e.fog=this.fog.clone()),null!==this.overrideMaterial&&(e.overrideMaterial=this.overrideMaterial.clone()),e.autoUpdate=this.autoUpdate,e.matrixAutoUpdate=this.matrixAutoUpdate,e},THREE.Fog=function(e,t,r){this.name="",this.color=new THREE.Color(e),this.near=void 0!==t?t:1,this.far=void 0!==r?r:1e3},THREE.Fog.prototype.clone=function(){return new THREE.Fog(this.color.getHex(),this.near,this.far)},THREE.FogExp2=function(e,t){this.name="",this.color=new THREE.Color(e),this.density=void 0!==t?t:25e-5},THREE.FogExp2.prototype.clone=function(){return new THREE.FogExp2(this.color.getHex(),this.density)},THREE.ShaderChunk={},THREE.ShaderChunk.common="#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n\nfloat square( in float a ) { return a*a; }\nvec2 square( in vec2 a ) { return vec2( a.x*a.x, a.y*a.y ); }\nvec3 square( in vec3 a ) { return vec3( a.x*a.x, a.y*a.y, a.z*a.z ); }\nvec4 square( in vec4 a ) { return vec4( a.x*a.x, a.y*a.y, a.z*a.z, a.w*a.w ); }\nfloat saturate( in float a ) { return clamp( a, 0.0, 1.0 ); }\nvec2 saturate( in vec2 a ) { return clamp( a, 0.0, 1.0 ); }\nvec3 saturate( in vec3 a ) { return clamp( a, 0.0, 1.0 ); }\nvec4 saturate( in vec4 a ) { return clamp( a, 0.0, 1.0 ); }\nfloat average( in float a ) { return a; }\nfloat average( in vec2 a ) { return ( a.x + a.y) * 0.5; }\nfloat average( in vec3 a ) { return ( a.x + a.y + a.z) / 3.0; }\nfloat average( in vec4 a ) { return ( a.x + a.y + a.z + a.w) * 0.25; }\nfloat whiteCompliment( in float a ) { return saturate( 1.0 - a ); }\nvec2 whiteCompliment( in vec2 a ) { return saturate( vec2(1.0) - a ); }\nvec3 whiteCompliment( in vec3 a ) { return saturate( vec3(1.0) - a ); }\nvec4 whiteCompliment( in vec4 a ) { return saturate( vec4(1.0) - a ); }\nvec3 transformDirection( in vec3 normal, in mat4 matrix ) {\n return normalize( ( matrix * vec4( normal, 0.0 ) ).xyz );\n}\n// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\nvec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {\n return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\n float distance = dot( planeNormal, point-pointOnPlane );\n return point - distance * planeNormal;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n return pointOnLine + lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) );\n}\nfloat calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {\n if ( decayExponent > 0.0 ) {\n return pow( saturate( 1.0 - lightDistance / cutoffDistance ), decayExponent );\n }\n return 1.0;\n}\n\nvec3 inputToLinear( in vec3 a ) {\n#ifdef GAMMA_INPUT\n return pow( a, vec3( float( GAMMA_FACTOR ) ) );\n#else\n return a;\n#endif\n}\nvec3 linearToOutput( in vec3 a ) {\n#ifdef GAMMA_OUTPUT\n return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n#else\n return a;\n#endif\n}\n",THREE.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\n if ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n",THREE.ShaderChunk.lights_lambert_vertex="vLightFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\n vLightBack = vec3( 0.0 );\n\n#endif\n\ntransformedNormal = normalize( transformedNormal );\n\n#if MAX_DIR_LIGHTS > 0\n\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );\n\n float dotProduct = dot( transformedNormal, dirVector );\n vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n #ifdef DOUBLE_SIDED\n\n vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n #ifdef WRAP_AROUND\n\n vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n #endif\n\n #endif\n\n #ifdef WRAP_AROUND\n\n vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n\n #ifdef DOUBLE_SIDED\n\n directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n\n #endif\n\n #endif\n\n vLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n\n #ifdef DOUBLE_SIDED\n\n vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n\n #endif\n\n}\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n vec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n float attenuation = calcLightAttenuation( length( lVector ), pointLightDistance[ i ], pointLightDecay[ i ] );\n\n lVector = normalize( lVector );\n float dotProduct = dot( transformedNormal, lVector );\n\n vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n #ifdef DOUBLE_SIDED\n\n vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n #ifdef WRAP_AROUND\n\n vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n #endif\n\n #endif\n\n #ifdef WRAP_AROUND\n\n vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n\n #ifdef DOUBLE_SIDED\n\n pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n\n #endif\n\n #endif\n\n vLightFront += pointLightColor[ i ] * pointLightWeighting * attenuation;\n\n #ifdef DOUBLE_SIDED\n\n vLightBack += pointLightColor[ i ] * pointLightWeightingBack * attenuation;\n\n #endif\n\n }\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n vec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );\n\n if ( spotEffect > spotLightAngleCos[ i ] ) {\n\n spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n float attenuation = calcLightAttenuation( length( lVector ), spotLightDistance[ i ], spotLightDecay[ i ] );\n\n lVector = normalize( lVector );\n\n float dotProduct = dot( transformedNormal, lVector );\n vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n #ifdef DOUBLE_SIDED\n\n vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n #ifdef WRAP_AROUND\n\n vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n #endif\n\n #endif\n\n #ifdef WRAP_AROUND\n\n vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n\n #ifdef DOUBLE_SIDED\n\n spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n\n #endif\n\n #endif\n\n vLightFront += spotLightColor[ i ] * spotLightWeighting * attenuation * spotEffect;\n\n #ifdef DOUBLE_SIDED\n\n vLightBack += spotLightColor[ i ] * spotLightWeightingBack * attenuation * spotEffect;\n\n #endif\n\n }\n\n }\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );\n\n float dotProduct = dot( transformedNormal, lVector );\n\n float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n float hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\n\n vLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n #ifdef DOUBLE_SIDED\n\n vLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n\n #endif\n\n }\n\n#endif\n\nvLightFront += ambientLightColor;\n\n#ifdef DOUBLE_SIDED\n\n vLightBack += ambientLightColor;\n\n#endif\n",THREE.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\n uniform vec4 offsetRepeat;\n uniform sampler2D map;\n\n#endif\n",THREE.ShaderChunk.default_vertex="#ifdef USE_SKINNING\n\n vec4 mvPosition = modelViewMatrix * skinned;\n\n#elif defined( USE_MORPHTARGETS )\n\n vec4 mvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n\n#else\n\n vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n#endif\n\ngl_Position = projectionMatrix * mvPosition;\n",THREE.ShaderChunk.map_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n varying vec2 vUv;\n\n#endif\n\n#ifdef USE_MAP\n\n uniform sampler2D map;\n\n#endif",THREE.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n #ifdef USE_MORPHNORMALS\n\n vec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n\n #else\n\n vec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n\n #endif\n\n#endif\n",THREE.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\n #ifdef USE_LOGDEPTHBUF_EXT\n\n varying float vFragDepth;\n\n #endif\n\n uniform float logDepthBufFC;\n\n#endif",THREE.ShaderChunk.lightmap_pars_vertex="#ifdef USE_LIGHTMAP\n\n varying vec2 vUv2;\n\n#endif",THREE.ShaderChunk.lights_phong_fragment="#ifndef FLAT_SHADED\n\n vec3 normal = normalize( vNormal );\n\n #ifdef DOUBLE_SIDED\n\n normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\n #endif\n\n#else\n\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n\n#endif\n\nvec3 viewPosition = normalize( vViewPosition );\n\n#ifdef USE_NORMALMAP\n\n normal = perturbNormal2Arb( -vViewPosition, normal );\n\n#elif defined( USE_BUMPMAP )\n\n normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n\nvec3 totalDiffuseLight = vec3( 0.0 );\nvec3 totalSpecularLight = vec3( 0.0 );\n\n#if MAX_POINT_LIGHTS > 0\n\n for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n vec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n float attenuation = calcLightAttenuation( length( lVector ), pointLightDistance[ i ], pointLightDecay[ i ] );\n\n lVector = normalize( lVector );\n\n // diffuse\n\n float dotProduct = dot( normal, lVector );\n\n #ifdef WRAP_AROUND\n\n float pointDiffuseWeightFull = max( dotProduct, 0.0 );\n float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n vec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\n #else\n\n float pointDiffuseWeight = max( dotProduct, 0.0 );\n\n #endif\n\n totalDiffuseLight += pointLightColor[ i ] * pointDiffuseWeight * attenuation;\n\n // specular\n\n vec3 pointHalfVector = normalize( lVector + viewPosition );\n float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\n float specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );\n totalSpecularLight += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * attenuation * specularNormalization;\n\n }\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n vec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n float attenuation = calcLightAttenuation( length( lVector ), spotLightDistance[ i ], spotLightDecay[ i ] );\n\n lVector = normalize( lVector );\n\n float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\n if ( spotEffect > spotLightAngleCos[ i ] ) {\n\n spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n // diffuse\n\n float dotProduct = dot( normal, lVector );\n\n #ifdef WRAP_AROUND\n\n float spotDiffuseWeightFull = max( dotProduct, 0.0 );\n float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n vec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\n #else\n\n float spotDiffuseWeight = max( dotProduct, 0.0 );\n\n #endif\n\n totalDiffuseLight += spotLightColor[ i ] * spotDiffuseWeight * attenuation * spotEffect;\n\n // specular\n\n vec3 spotHalfVector = normalize( lVector + viewPosition );\n float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\n float specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );\n totalSpecularLight += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * attenuation * specularNormalization * spotEffect;\n\n }\n\n }\n\n#endif\n\n#if MAX_DIR_LIGHTS > 0\n\n for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );\n\n // diffuse\n\n float dotProduct = dot( normal, dirVector );\n\n #ifdef WRAP_AROUND\n\n float dirDiffuseWeightFull = max( dotProduct, 0.0 );\n float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n\n #else\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n #endif\n\n totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;\n\n // specular\n\n vec3 dirHalfVector = normalize( dirVector + viewPosition );\n float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\n /*\n // fresnel term from skin shader\n const float F0 = 0.128;\n\n float base = 1.0 - dot( viewPosition, dirHalfVector );\n float exponential = pow( base, 5.0 );\n\n float fresnel = exponential + F0 * ( 1.0 - exponential );\n */\n\n /*\n // fresnel term from fresnel shader\n const float mFresnelBias = 0.08;\n const float mFresnelScale = 0.3;\n const float mFresnelPower = 5.0;\n\n float fresnel = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( -viewPosition ), normal ), mFresnelPower );\n */\n\n float specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n // dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization * fresnel;\n\n vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );\n totalSpecularLight += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\n\n }\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );\n\n // diffuse\n\n float dotProduct = dot( normal, lVector );\n float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\n vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n totalDiffuseLight += hemiColor;\n\n // specular (sky light)\n\n vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n float hemiSpecularWeightSky = specularStrength * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );\n\n // specular (ground light)\n\n vec3 lVectorGround = -lVector;\n\n vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n float hemiSpecularWeightGround = specularStrength * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );\n\n float dotProductGround = dot( normal, lVectorGround );\n\n float specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );\n vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );\n totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\n }\n\n#endif\n\n#ifdef METAL\n\n outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor ) * specular + totalSpecularLight + emissive;\n\n#else\n\n outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor ) + totalSpecularLight + emissive;\n\n#endif\n",THREE.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\n uniform vec3 fogColor;\n\n #ifdef FOG_EXP2\n\n uniform float fogDensity;\n\n #else\n\n uniform float fogNear;\n uniform float fogFar;\n #endif\n\n#endif", +THREE.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\n vec3 morphedNormal = vec3( 0.0 );\n\n morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n\n morphedNormal += normal;\n\n#endif",THREE.ShaderChunk.envmap_pars_fragment="#ifdef USE_ENVMAP\n\n uniform float reflectivity;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n uniform float flipEnvMap;\n\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n uniform float refractionRatio;\n\n #else\n\n varying vec3 vReflect;\n\n #endif\n\n#endif\n",THREE.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\n gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n\n#endif",THREE.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n\n // Per-Pixel Tangent Space Normal Mapping\n // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( vUv.st );\n vec2 st1 = dFdy( vUv.st );\n\n vec3 S = normalize( q0 * st1.t - q1 * st0.t );\n vec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n vec3 N = normalize( surf_norm );\n\n vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n mapN.xy = normalScale * mapN.xy;\n mat3 tsn = mat3( S, T, N );\n return normalize( tsn * mapN );\n\n }\n\n#endif\n",THREE.ShaderChunk.lights_phong_pars_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n",THREE.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\n varying vec2 vUv2;\n uniform sampler2D lightMap;\n\n#endif",THREE.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\n for( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n vShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\n }\n\n#endif",THREE.ShaderChunk.lights_phong_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n vWorldPosition = worldPosition.xyz;\n\n#endif",THREE.ShaderChunk.map_fragment="#ifdef USE_MAP\n\n vec4 texelColor = texture2D( map, vUv );\n\n texelColor.xyz = inputToLinear( texelColor.xyz );\n\n diffuseColor *= texelColor;\n\n#endif",THREE.ShaderChunk.lightmap_vertex="#ifdef USE_LIGHTMAP\n\n vUv2 = uv2;\n\n#endif",THREE.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\n diffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n\n#endif\n",THREE.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\n varying vec3 vColor;\n\n#endif\n",THREE.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\n vColor.xyz = inputToLinear( color.xyz );\n\n#endif",THREE.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\n #ifdef USE_MORPHTARGETS\n\n vec4 skinVertex = bindMatrix * vec4( morphed, 1.0 );\n\n #else\n\n vec4 skinVertex = bindMatrix * vec4( position, 1.0 );\n\n #endif\n\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n skinned = bindMatrixInverse * skinned;\n\n#endif\n",THREE.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n varying vec3 vReflect;\n\n uniform float refractionRatio;\n\n#endif\n",THREE.ShaderChunk.linear_to_gamma_fragment="\n outgoingLight = linearToOutput( outgoingLight );\n",THREE.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\n varying vec3 vColor;\n\n#endif",THREE.ShaderChunk.lights_lambert_pars_vertex="uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n uniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n uniform float pointLightDecay[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#ifdef WRAP_AROUND\n\n uniform vec3 wrapRGB;\n\n#endif\n",THREE.ShaderChunk.map_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n varying vec2 vUv;\n uniform vec4 offsetRepeat;\n\n#endif\n",THREE.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\n // Transforming Normal Vectors with the Inverse Transformation\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n #ifdef ENVMAP_MODE_REFLECTION\n\n vec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\n #else\n\n vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\n #endif\n\n #else\n\n vec3 reflectVec = vReflect;\n\n #endif\n\n #ifdef DOUBLE_SIDED\n float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n #else\n float flipNormal = 1.0;\n #endif\n\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n #elif defined( ENVMAP_TYPE_EQUIREC )\n vec2 sampleUV;\n sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n vec4 envColor = texture2D( envMap, sampleUV );\n\n #elif defined( ENVMAP_TYPE_SPHERE )\n vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n #endif\n\n envColor.xyz = inputToLinear( envColor.xyz );\n\n #ifdef ENVMAP_BLENDING_MULTIPLY\n\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n #elif defined( ENVMAP_BLENDING_MIX )\n\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n #elif defined( ENVMAP_BLENDING_ADD )\n\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n #endif\n\n#endif\n",THREE.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\n uniform sampler2D specularMap;\n\n#endif",THREE.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\n gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\n #ifdef USE_LOGDEPTHBUF_EXT\n\n vFragDepth = 1.0 + gl_Position.w;\n\n#else\n\n gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\n #endif\n\n#endif",THREE.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\n #ifndef USE_MORPHNORMALS\n\n uniform float morphTargetInfluences[ 8 ];\n\n #else\n\n uniform float morphTargetInfluences[ 4 ];\n\n #endif\n\n#endif",THREE.ShaderChunk.specularmap_fragment="float specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n vec4 texelSpecular = texture2D( specularMap, vUv );\n specularStrength = texelSpecular.r;\n\n#else\n\n specularStrength = 1.0;\n\n#endif",THREE.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\n #ifdef USE_LOGDEPTHBUF_EXT\n\n float depth = gl_FragDepthEXT / gl_FragCoord.w;\n\n #else\n\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n\n #endif\n\n #ifdef FOG_EXP2\n\n float fogFactor = exp2( - square( fogDensity ) * square( depth ) * LOG2 );\n fogFactor = whiteCompliment( fogFactor );\n\n #else\n\n float fogFactor = smoothstep( fogNear, fogFar, depth );\n\n #endif\n \n outgoingLight = mix( outgoingLight, fogColor, fogFactor );\n\n#endif",THREE.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n\n // Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen\n // http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\n\n // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n vec2 dHdxy_fwd() {\n\n vec2 dSTdx = dFdx( vUv );\n vec2 dSTdy = dFdy( vUv );\n\n float Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n return vec2( dBx, dBy );\n\n }\n\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n vec3 vSigmaX = dFdx( surf_pos );\n vec3 vSigmaY = dFdy( surf_pos );\n vec3 vN = surf_norm; // normalized\n\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n\n float fDet = dot( vSigmaX, R1 );\n\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n\n }\n\n#endif\n",THREE.ShaderChunk.defaultnormal_vertex="#ifdef USE_SKINNING\n\n vec3 objectNormal = skinnedNormal.xyz;\n\n#elif defined( USE_MORPHNORMALS )\n\n vec3 objectNormal = morphedNormal;\n\n#else\n\n vec3 objectNormal = normal;\n\n#endif\n\n#ifdef FLIP_SIDED\n\n objectNormal = -objectNormal;\n\n#endif\n\nvec3 transformedNormal = normalMatrix * objectNormal;\n",THREE.ShaderChunk.lights_phong_pars_fragment="uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\n uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n uniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n uniform float pointLightDecay[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n varying vec3 vWorldPosition;\n\n#endif\n\n#ifdef WRAP_AROUND\n\n uniform vec3 wrapRGB;\n\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n varying vec3 vNormal;\n\n#endif\n",THREE.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif",THREE.ShaderChunk.map_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n vUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n\n#endif",THREE.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\n outgoingLight *= diffuseColor.xyz * texture2D( lightMap, vUv2 ).xyz;\n\n#endif",THREE.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\n varying vec4 vShadowCoord[ MAX_SHADOWS ];\n uniform mat4 shadowMatrix[ MAX_SHADOWS ];\n\n#endif",THREE.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\n diffuseColor.rgb *= vColor;\n\n#endif",THREE.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\n vec3 morphed = vec3( 0.0 );\n morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\n #ifndef USE_MORPHNORMALS\n\n morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\n #endif\n\n morphed += position;\n\n#endif",THREE.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n vec3 worldNormal = transformDirection( objectNormal, modelMatrix );\n\n vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n #ifdef ENVMAP_MODE_REFLECTION\n\n vReflect = reflect( cameraToVertex, worldNormal );\n\n #else\n\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n #endif\n\n#endif\n",THREE.ShaderChunk.shadowmap_fragment="#ifdef USE_SHADOWMAP\n\n #ifdef SHADOWMAP_DEBUG\n\n vec3 frustumColors[3];\n frustumColors[0] = vec3( 1.0, 0.5, 0.0 );\n frustumColors[1] = vec3( 0.0, 1.0, 0.8 );\n frustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n\n #endif\n\n #ifdef SHADOWMAP_CASCADE\n\n int inFrustumCount = 0;\n\n #endif\n\n float fDepth;\n vec3 shadowColor = vec3( 1.0 );\n\n for( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\n\n // if ( something && something ) breaks ATI OpenGL shader compiler\n // if ( all( something, something ) ) using this instead\n\n bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n bool inFrustum = all( inFrustumVec );\n\n // don't shadow pixels outside of light frustum\n // use just first frustum (for cascades)\n // don't shadow pixels behind far plane of light frustum\n\n #ifdef SHADOWMAP_CASCADE\n\n inFrustumCount += int( inFrustum );\n bvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n\n #else\n\n bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n #endif\n\n bool frustumTest = all( frustumTestVec );\n\n if ( frustumTest ) {\n\n shadowCoord.z += shadowBias[ i ];\n\n #if defined( SHADOWMAP_TYPE_PCF )\n\n // Percentage-close filtering\n // (9 pixel kernel)\n // http://fabiensanglard.net/shadowmappingPCF/\n\n float shadow = 0.0;\n\n /*\n // nested loops breaks shader compiler / validator on some ATI cards when using OpenGL\n // must enroll loop manually\n\n for ( float y = -1.25; y <= 1.25; y += 1.25 )\n for ( float x = -1.25; x <= 1.25; x += 1.25 ) {\n\n vec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\n\n // doesn't seem to produce any noticeable visual difference compared to simple texture2D lookup\n //vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );\n\n float fDepth = unpackDepth( rgbaDepth );\n\n if ( fDepth < shadowCoord.z )\n shadow += 1.0;\n\n }\n\n shadow /= 9.0;\n\n */\n\n const float shadowDelta = 1.0 / 9.0;\n\n float xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n float yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n float dx0 = -1.25 * xPixelOffset;\n float dy0 = -1.25 * yPixelOffset;\n float dx1 = 1.25 * xPixelOffset;\n float dy1 = 1.25 * yPixelOffset;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n if ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n #elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n // Percentage-close filtering\n // (9 pixel kernel)\n // http://fabiensanglard.net/shadowmappingPCF/\n\n float shadow = 0.0;\n\n float xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n float yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n float dx0 = -1.0 * xPixelOffset;\n float dy0 = -1.0 * yPixelOffset;\n float dx1 = 1.0 * xPixelOffset;\n float dy1 = 1.0 * yPixelOffset;\n\n mat3 shadowKernel;\n mat3 depthKernel;\n\n depthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n depthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n depthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n depthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n depthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n depthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n depthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n depthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n depthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\n vec3 shadowZ = vec3( shadowCoord.z );\n shadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));\n shadowKernel[0] *= vec3(0.25);\n\n shadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));\n shadowKernel[1] *= vec3(0.25);\n\n shadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));\n shadowKernel[2] *= vec3(0.25);\n\n vec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );\n\n shadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );\n shadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );\n\n vec4 shadowValues;\n shadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );\n shadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );\n shadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );\n shadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );\n\n shadow = dot( shadowValues, vec4( 1.0 ) );\n\n shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n #else\n\n vec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\n float fDepth = unpackDepth( rgbaDepth );\n\n if ( fDepth < shadowCoord.z )\n\n // spot with multiple shadows is darker\n\n shadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n\n // spot with multiple shadows has the same color as single shadow spot\n\n // shadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );\n\n #endif\n\n }\n\n\n #ifdef SHADOWMAP_DEBUG\n\n #ifdef SHADOWMAP_CASCADE\n\n if ( inFrustum && inFrustumCount == 1 ) outgoingLight *= frustumColors[ i ];\n\n #else\n\n if ( inFrustum ) outgoingLight *= frustumColors[ i ];\n\n #endif\n\n #endif\n\n }\n\n // NOTE: I am unsure if this is correct in linear space. -bhouston, Dec 29, 2014\n shadowColor = inputToLinear( shadowColor );\n\n outgoingLight = outgoingLight * shadowColor;\n\n#endif\n",THREE.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\n #ifdef USE_SKINNING\n\n vec4 worldPosition = modelMatrix * skinned;\n\n #elif defined( USE_MORPHTARGETS )\n\n vec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );\n\n #else\n\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\n #endif\n\n#endif\n",THREE.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\n uniform sampler2D shadowMap[ MAX_SHADOWS ];\n uniform vec2 shadowMapSize[ MAX_SHADOWS ];\n\n uniform float shadowDarkness[ MAX_SHADOWS ];\n uniform float shadowBias[ MAX_SHADOWS ];\n\n varying vec4 vShadowCoord[ MAX_SHADOWS ];\n\n float unpackDepth( const in vec4 rgba_depth ) {\n\n const vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n float depth = dot( rgba_depth, bit_shift );\n return depth;\n\n }\n\n#endif",THREE.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n\n #ifdef BONE_TEXTURE\n\n uniform sampler2D boneTexture;\n uniform int boneTextureWidth;\n uniform int boneTextureHeight;\n\n mat4 getBoneMatrix( const in float i ) {\n\n float j = i * 4.0;\n float x = mod( j, float( boneTextureWidth ) );\n float y = floor( j / float( boneTextureWidth ) );\n\n float dx = 1.0 / float( boneTextureWidth );\n float dy = 1.0 / float( boneTextureHeight );\n\n y = dy * ( y + 0.5 );\n\n vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n mat4 bone = mat4( v1, v2, v3, v4 );\n\n return bone;\n\n }\n\n #else\n\n uniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\n mat4 getBoneMatrix( const in float i ) {\n\n mat4 bone = boneGlobalMatrices[ int(i) ];\n return bone;\n\n }\n\n #endif\n\n#endif\n",THREE.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\n uniform float logDepthBufFC;\n\n #ifdef USE_LOGDEPTHBUF_EXT\n\n #extension GL_EXT_frag_depth : enable\n varying float vFragDepth;\n\n #endif\n\n#endif",THREE.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\n diffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",THREE.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\n uniform sampler2D alphaMap;\n\n#endif\n",THREE.UniformsUtils={merge:function(e){for(var t={},r=0;r dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n vec4 diffuseColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.color_fragment," outgoingLight = diffuseColor.rgb;",THREE.ShaderChunk.fog_fragment," gl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;\nuniform float mFar;\nuniform float opacity;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment," #ifdef USE_LOGDEPTHBUF_EXT\n float depth = gl_FragDepthEXT / gl_FragCoord.w;\n #else\n float depth = gl_FragCoord.z / gl_FragCoord.w;\n #endif\n float color = 1.0 - smoothstep( mNear, mFar, depth );\n gl_FragColor = vec4( vec3( color ), opacity );\n}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n vNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vNormal;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n vWorldPosition = transformDirection( position, modelMatrix );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n vWorldPosition = transformDirection( position, modelMatrix );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\nvec3 direction = normalize( vWorldPosition );\nvec2 sampleUV;\nsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\nsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\ngl_FragColor = texture2D( tEquirect, sampleUV );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n vec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n res -= res.xxyz * bit_mask;\n return res;\n}\nvoid main() {",THREE.ShaderChunk.logdepthbuf_fragment," #ifdef USE_LOGDEPTHBUF_EXT\n gl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );\n #else\n gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n #endif\n}"].join("\n")}},THREE.WebGLRenderer=function(e){function t(e){var t=e.geometry;e=e.material;var r=t.vertices.length;if(e.attributes){void 0===t.__webglCustomAttributesList&&(t.__webglCustomAttributesList=[]);for(var i in e.attributes){var n=e.attributes[i];if(!n.__webglInitialized||n.createUniqueBuffers){n.__webglInitialized=!0;var o=1;"v2"===n.type?o=2:"v3"===n.type?o=3:"v4"===n.type?o=4:"c"===n.type&&(o=3),n.size=o,n.array=new Float32Array(r*o),n.buffer=Y.createBuffer(),n.buffer.belongsToAttribute=i,n.needsUpdate=!0}t.__webglCustomAttributesList.push(n)}}}function r(e,t){return e.material instanceof THREE.MeshFaceMaterial?e.material.materials[t.materialIndex]:e.material}function i(e,t,r,i){r=r.attributes;var n=t.attributes;t=t.attributesKeys;for(var o=0,a=t.length;a>o;o++){var s=t[o],h=n[s];if(h>=0){var l=r[s];void 0!==l?(s=l.itemSize,Y.bindBuffer(Y.ARRAY_BUFFER,l.buffer),Te.enableAttribute(h),Y.vertexAttribPointer(h,s,Y.FLOAT,!1,0,i*s*4)):void 0!==e.defaultAttributeValues&&(2===e.defaultAttributeValues[s].length?Y.vertexAttrib2fv(h,e.defaultAttributeValues[s]):3===e.defaultAttributeValues[s].length&&Y.vertexAttrib3fv(h,e.defaultAttributeValues[s]))}}Te.disableUnusedAttributes()}function n(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function o(e,t){return e.object.renderOrder!==t.object.renderOrder?e.object.renderOrder-t.object.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function a(e,t){return t[0]-e[0]}function s(e){if(!1!==e.visible){if(!(e instanceof THREE.Scene||e instanceof THREE.Group)){void 0===e.__webglInit&&(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrix=new THREE.Matrix3,e.addEventListener("removed",ze));var r=e.geometry;if(void 0!==r&&void 0===r.__webglInit)if(r.__webglInit=!0,r.addEventListener("dispose",ke),r instanceof THREE.BufferGeometry)K.info.memory.geometries++;else if(e instanceof THREE.Mesh)u(e,r);else if(e instanceof THREE.Line){if(void 0===r.__webglVertexBuffer){r.__webglVertexBuffer=Y.createBuffer(),r.__webglColorBuffer=Y.createBuffer(),r.__webglLineDistanceBuffer=Y.createBuffer(),K.info.memory.geometries++;var i=r.vertices.length;r.__vertexArray=new Float32Array(3*i),r.__colorArray=new Float32Array(3*i),r.__lineDistanceArray=new Float32Array(1*i),r.__webglLineCount=i,t(e),r.verticesNeedUpdate=!0,r.colorsNeedUpdate=!0,r.lineDistancesNeedUpdate=!0}}else e instanceof THREE.PointCloud&&void 0===r.__webglVertexBuffer&&(r.__webglVertexBuffer=Y.createBuffer(),r.__webglColorBuffer=Y.createBuffer(),K.info.memory.geometries++,i=r.vertices.length,r.__vertexArray=new Float32Array(3*i),r.__colorArray=new Float32Array(3*i),r.__webglParticleCount=i,t(e),r.verticesNeedUpdate=!0,r.colorsNeedUpdate=!0);if(void 0===e.__webglActive)if(e.__webglActive=!0,e instanceof THREE.Mesh){if(r instanceof THREE.BufferGeometry)E(G,r,e);else if(r instanceof THREE.Geometry)for(var r=je[r.id],i=0,n=r.length;n>i;i++)E(G,r[i],e)}else e instanceof THREE.Line||e instanceof THREE.PointCloud?E(G,r,e):(e instanceof THREE.ImmediateRenderObject||e.immediateRenderCallback)&&I.push({id:null,object:e,opaque:null,transparent:null,z:0});if(e instanceof THREE.Light)O.push(e);else if(e instanceof THREE.Sprite)X.push(e);else if(e instanceof THREE.LensFlare)q.push(e);else if((r=G[e.id])&&(!1===e.frustumCulled||!0===le.intersectsObject(e)))for(i=0,n=r.length;n>i;i++){var o=r[i],a=o,h=a.object,l=a.buffer,c=h.geometry,h=h.material;h instanceof THREE.MeshFaceMaterial?(h=h.materials[c instanceof THREE.BufferGeometry?0:l.materialIndex],a.material=h,h.transparent?j.push(a):W.push(a)):h&&(a.material=h,h.transparent?j.push(a):W.push(a)),o.render=!0,!0===K.sortObjects&&(ue.setFromMatrixPosition(e.matrixWorld),ue.applyProjection(ce),o.z=ue.z)}}for(i=0,n=e.children.length;n>i;i++)s(e.children[i])}}function h(e,t,r,i,n){for(var o,a=0,s=e.length;s>a;a++){o=e[a];var h=o.object,l=o.buffer;if(y(h,t),n)o=n;else{if(o=o.material,!o)continue;m(o)}K.setMaterialFaces(o),l instanceof THREE.BufferGeometry?K.renderBufferDirect(t,r,i,o,l,h):K.renderBuffer(t,r,i,o,l,h)}}function l(e,t,r,i,n,o){for(var a,s=0,h=e.length;h>s;s++){a=e[s];var l=a.object;if(l.visible){if(o)a=o;else{if(a=a[t],!a)continue;m(a)}K.renderImmediateObject(r,i,n,a,l)}}}function c(e){var t=e.object.material;t.transparent?(e.transparent=t,e.opaque=null):(e.opaque=t,e.transparent=null)}function u(e,t){var i=e.material,n=!1;if(void 0===je[t.id]||!0===t.groupsNeedUpdate){delete G[e.id];for(var o,a,s=je,h=t.id,i=i instanceof THREE.MeshFaceMaterial,l=ge.get("OES_element_index_uint")?4294967296:65535,n={},c=t.morphTargets.length,u=t.morphNormals.length,p={},d=[],f=0,m=t.faces.length;m>f;f++){o=t.faces[f];var T=i?o.materialIndex:0;T in n||(n[T]={hash:T,counter:0}),o=n[T].hash+"_"+n[T].counter,o in p||(a={id:Xe++,faces3:[],materialIndex:T,vertices:0,numMorphTargets:c,numMorphNormals:u},p[o]=a,d.push(a)),p[o].vertices+3>l&&(n[T].counter+=1,o=n[T].hash+"_"+n[T].counter,o in p||(a={id:Xe++,faces3:[],materialIndex:T,vertices:0,numMorphTargets:c,numMorphNormals:u},p[o]=a,d.push(a))),p[o].faces3.push(f),p[o].vertices+=3}s[h]=d,t.groupsNeedUpdate=!1}for(s=je[t.id],h=0,i=s.length;i>h;h++){if(l=s[h],void 0===l.__webglVertexBuffer){if(n=l,n.__webglVertexBuffer=Y.createBuffer(),n.__webglNormalBuffer=Y.createBuffer(),n.__webglTangentBuffer=Y.createBuffer(),n.__webglColorBuffer=Y.createBuffer(),n.__webglUVBuffer=Y.createBuffer(),n.__webglUV2Buffer=Y.createBuffer(),n.__webglSkinIndicesBuffer=Y.createBuffer(),n.__webglSkinWeightsBuffer=Y.createBuffer(),n.__webglFaceBuffer=Y.createBuffer(),n.__webglLineBuffer=Y.createBuffer(),u=n.numMorphTargets)for(n.__webglMorphTargetsBuffers=[],c=0;u>c;c++)n.__webglMorphTargetsBuffers.push(Y.createBuffer());if(u=n.numMorphNormals)for(n.__webglMorphNormalsBuffers=[],c=0;u>c;c++)n.__webglMorphNormalsBuffers.push(Y.createBuffer());if(K.info.memory.geometries++,n=l,f=e,m=f.geometry,u=n.faces3,c=3*u.length,p=1*u.length,d=3*u.length,u=r(f,n),n.__vertexArray=new Float32Array(3*c),n.__normalArray=new Float32Array(3*c),n.__colorArray=new Float32Array(3*c),n.__uvArray=new Float32Array(2*c),121845?Uint32Array:Uint16Array,n.__typeArray=f,n.__faceArray=new f(3*p),n.__lineArray=new f(2*d),m=n.numMorphTargets)for(n.__morphTargetsArrays=[],f=0;m>f;f++)n.__morphTargetsArrays.push(new Float32Array(3*c));if(m=n.numMorphNormals)for(n.__morphNormalsArrays=[],f=0;m>f;f++)n.__morphNormalsArrays.push(new Float32Array(3*c));if(n.__webglFaceCount=3*p,n.__webglLineCount=2*d,u.attributes)for(p in void 0===n.__webglCustomAttributesList&&(n.__webglCustomAttributesList=[]),p=void 0,u.attributes){var g,d=u.attributes[p],f={};for(g in d)f[g]=d[g];(!f.__webglInitialized||f.createUniqueBuffers)&&(f.__webglInitialized=!0,m=1,"v2"===f.type?m=2:"v3"===f.type?m=3:"v4"===f.type?m=4:"c"===f.type&&(m=3),f.size=m,f.array=new Float32Array(c*m),f.buffer=Y.createBuffer(),f.buffer.belongsToAttribute=p,d.needsUpdate=!0,f.__original=d),n.__webglCustomAttributesList.push(f)}n.__inittedArrays=!0,t.verticesNeedUpdate=!0,t.morphTargetsNeedUpdate=!0,t.elementsNeedUpdate=!0,t.uvsNeedUpdate=!0,t.normalsNeedUpdate=!0,t.tangentsNeedUpdate=!0,n=t.colorsNeedUpdate=!0}else n=!1;(n||void 0===e.__webglActive)&&E(G,l,e)}e.__webglActive=!0}function E(e,t,r){var i=r.id;e[i]=e[i]||[],e[i].push({id:i,buffer:t,object:r,material:null,z:0})}function p(e){var t=e.geometry;if(t instanceof THREE.BufferGeometry)for(var i=t.attributes,n=t.attributesKeys,o=0,a=n.length;a>o;o++){var s=n[o],h=i[s],l="index"===s?Y.ELEMENT_ARRAY_BUFFER:Y.ARRAY_BUFFER;void 0===h.buffer?(h.buffer=Y.createBuffer(),Y.bindBuffer(l,h.buffer),Y.bufferData(l,h.array,h instanceof THREE.DynamicBufferAttribute?Y.DYNAMIC_DRAW:Y.STATIC_DRAW),h.needsUpdate=!1):!0===h.needsUpdate&&(Y.bindBuffer(l,h.buffer),void 0===h.updateRange||-1===h.updateRange.count?Y.bufferSubData(l,0,h.array):0===h.updateRange.count?console.error("THREE.WebGLRenderer.updateObject: using updateRange for THREE.DynamicBufferAttribute and marked as needsUpdate but count is 0, ensure you are using set methods or updating manually."):(Y.bufferSubData(l,h.updateRange.offset*h.array.BYTES_PER_ELEMENT,h.array.subarray(h.updateRange.offset,h.updateRange.offset+h.updateRange.count)),h.updateRange.count=0),h.needsUpdate=!1)}else if(e instanceof THREE.Mesh){!0===t.groupsNeedUpdate&&u(e,t);for(var c=je[t.id],o=0,E=c.length;E>o;o++){var p=c[o],m=r(e,p),T=m.attributes&&d(m);if(t.verticesNeedUpdate||t.morphTargetsNeedUpdate||t.elementsNeedUpdate||t.uvsNeedUpdate||t.normalsNeedUpdate||t.colorsNeedUpdate||t.tangentsNeedUpdate||T){var g=p,R=e,y=Y.DYNAMIC_DRAW,v=!t.dynamic,H=m;if(g.__inittedArrays){var x=!1==H instanceof THREE.MeshPhongMaterial&&H.shading===THREE.FlatShading,b=void 0,w=void 0,_=void 0,M=void 0,S=void 0,C=void 0,A=void 0,L=void 0,P=void 0,F=void 0,B=void 0,U=void 0,D=void 0,V=void 0,z=void 0,k=void 0,N=void 0,O=void 0,G=void 0,I=void 0,W=void 0,j=void 0,X=void 0,q=void 0,K=void 0,Q=void 0,Z=void 0,J=void 0,$=void 0,ee=void 0,te=void 0,re=void 0,ie=void 0,ne=void 0,oe=void 0,ae=void 0,se=void 0,he=void 0,le=void 0,ce=void 0,ue=0,Ee=0,pe=0,de=0,fe=0,me=0,Te=0,ge=0,Re=0,ye=0,ve=0,He=0,xe=void 0,be=g.__vertexArray,we=g.__uvArray,_e=g.__uv2Array,Me=g.__normalArray,Se=g.__tangentArray,Ce=g.__colorArray,Ae=g.__skinIndexArray,Le=g.__skinWeightArray,Pe=g.__morphTargetsArrays,Fe=g.__morphNormalsArrays,Be=g.__webglCustomAttributesList,Ue=void 0,De=g.__faceArray,Ve=g.__lineArray,ze=R.geometry,ke=ze.elementsNeedUpdate,Ne=ze.uvsNeedUpdate,Oe=ze.normalsNeedUpdate,Ge=ze.tangentsNeedUpdate,Ie=ze.colorsNeedUpdate,We=ze.morphTargetsNeedUpdate,Xe=ze.vertices,qe=g.faces3,Ye=ze.faces,Ke=ze.faceVertexUvs[0],Qe=ze.faceVertexUvs[1],Ze=ze.skinIndices,Je=ze.skinWeights,$e=ze.morphTargets,et=ze.morphNormals;if(ze.verticesNeedUpdate){for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],U=Xe[M.a],D=Xe[M.b],V=Xe[M.c],be[Ee]=U.x,be[Ee+1]=U.y,be[Ee+2]=U.z,be[Ee+3]=D.x,be[Ee+4]=D.y,be[Ee+5]=D.z,be[Ee+6]=V.x,be[Ee+7]=V.y,be[Ee+8]=V.z,Ee+=9;Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglVertexBuffer),Y.bufferData(Y.ARRAY_BUFFER,be,y)}if(We)for(oe=0,ae=$e.length;ae>oe;oe++){for(b=ve=0,w=qe.length;w>b;b++)le=qe[b],M=Ye[le],U=$e[oe].vertices[M.a],D=$e[oe].vertices[M.b],V=$e[oe].vertices[M.c],se=Pe[oe],se[ve]=U.x,se[ve+1]=U.y,se[ve+2]=U.z,se[ve+3]=D.x,se[ve+4]=D.y,se[ve+5]=D.z,se[ve+6]=V.x,se[ve+7]=V.y,se[ve+8]=V.z,H.morphNormals&&(x?I=G=O=et[oe].faceNormals[le]:(ce=et[oe].vertexNormals[le],O=ce.a,G=ce.b,I=ce.c),he=Fe[oe],he[ve]=O.x,he[ve+1]=O.y,he[ve+2]=O.z,he[ve+3]=G.x,he[ve+4]=G.y,he[ve+5]=G.z,he[ve+6]=I.x,he[ve+7]=I.y,he[ve+8]=I.z),ve+=9;Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[oe]),Y.bufferData(Y.ARRAY_BUFFER,Pe[oe],y),H.morphNormals&&(Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglMorphNormalsBuffers[oe]),Y.bufferData(Y.ARRAY_BUFFER,Fe[oe],y))}if(Je.length){for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],q=Je[M.a],K=Je[M.b],Q=Je[M.c],Le[ye]=q.x,Le[ye+1]=q.y,Le[ye+2]=q.z,Le[ye+3]=q.w,Le[ye+4]=K.x,Le[ye+5]=K.y,Le[ye+6]=K.z,Le[ye+7]=K.w,Le[ye+8]=Q.x,Le[ye+9]=Q.y,Le[ye+10]=Q.z,Le[ye+11]=Q.w,Z=Ze[M.a],J=Ze[M.b],$=Ze[M.c],Ae[ye]=Z.x,Ae[ye+1]=Z.y,Ae[ye+2]=Z.z,Ae[ye+3]=Z.w,Ae[ye+4]=J.x,Ae[ye+5]=J.y,Ae[ye+6]=J.z,Ae[ye+7]=J.w,Ae[ye+8]=$.x,Ae[ye+9]=$.y,Ae[ye+10]=$.z,Ae[ye+11]=$.w,ye+=12;ye>0&&(Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),Y.bufferData(Y.ARRAY_BUFFER,Ae,y),Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),Y.bufferData(Y.ARRAY_BUFFER,Le,y))}if(Ie){for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],A=M.vertexColors,L=M.color,3===A.length&&H.vertexColors===THREE.VertexColors?(W=A[0],j=A[1],X=A[2]):X=j=W=L,Ce[Re]=W.r,Ce[Re+1]=W.g,Ce[Re+2]=W.b,Ce[Re+3]=j.r,Ce[Re+4]=j.g,Ce[Re+5]=j.b,Ce[Re+6]=X.r,Ce[Re+7]=X.g,Ce[Re+8]=X.b,Re+=9;Re>0&&(Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglColorBuffer),Y.bufferData(Y.ARRAY_BUFFER,Ce,y))}if(Ge&&ze.hasTangents){for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],P=M.vertexTangents,z=P[0],k=P[1],N=P[2],Se[Te]=z.x,Se[Te+1]=z.y,Se[Te+2]=z.z,Se[Te+3]=z.w,Se[Te+4]=k.x,Se[Te+5]=k.y,Se[Te+6]=k.z,Se[Te+7]=k.w,Se[Te+8]=N.x,Se[Te+9]=N.y,Se[Te+10]=N.z,Se[Te+11]=N.w,Te+=12;Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglTangentBuffer),Y.bufferData(Y.ARRAY_BUFFER,Se,y)}if(Oe){for(b=0,w=qe.length;w>b;b++)if(M=Ye[qe[b]],S=M.vertexNormals,C=M.normal,3===S.length&&!1===x)for(ee=0;3>ee;ee++)re=S[ee],Me[me]=re.x,Me[me+1]=re.y,Me[me+2]=re.z,me+=3;else for(ee=0;3>ee;ee++)Me[me]=C.x,Me[me+1]=C.y,Me[me+2]=C.z,me+=3;Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglNormalBuffer),Y.bufferData(Y.ARRAY_BUFFER,Me,y)}if(Ne&&Ke){for(b=0,w=qe.length;w>b;b++)if(_=qe[b],F=Ke[_],void 0!==F)for(ee=0;3>ee;ee++)ie=F[ee],we[pe]=ie.x,we[pe+1]=ie.y,pe+=2;pe>0&&(Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglUVBuffer),Y.bufferData(Y.ARRAY_BUFFER,we,y))}if(Ne&&Qe){for(b=0,w=qe.length;w>b;b++)if(_=qe[b],B=Qe[_],void 0!==B)for(ee=0;3>ee;ee++)ne=B[ee],_e[de]=ne.x,_e[de+1]=ne.y,de+=2;de>0&&(Y.bindBuffer(Y.ARRAY_BUFFER,g.__webglUV2Buffer),Y.bufferData(Y.ARRAY_BUFFER,_e,y))}if(ke){for(b=0,w=qe.length;w>b;b++)De[fe]=ue,De[fe+1]=ue+1,De[fe+2]=ue+2,fe+=3,Ve[ge]=ue,Ve[ge+1]=ue+1,Ve[ge+2]=ue,Ve[ge+3]=ue+2,Ve[ge+4]=ue+1,Ve[ge+5]=ue+2,ge+=6,ue+=3;Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),Y.bufferData(Y.ELEMENT_ARRAY_BUFFER,De,y),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),Y.bufferData(Y.ELEMENT_ARRAY_BUFFER,Ve,y)}if(Be)for(ee=0,te=Be.length;te>ee;ee++)if(Ue=Be[ee],Ue.__original.needsUpdate){if(He=0,1===Ue.size){if(void 0===Ue.boundTo||"vertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],Ue.array[He]=Ue.value[M.a],Ue.array[He+1]=Ue.value[M.b],Ue.array[He+2]=Ue.value[M.c],He+=3;else if("faces"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)xe=Ue.value[qe[b]],Ue.array[He]=xe,Ue.array[He+1]=xe,Ue.array[He+2]=xe,He+=3}else if(2===Ue.size){if(void 0===Ue.boundTo||"vertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],U=Ue.value[M.a],D=Ue.value[M.b],V=Ue.value[M.c],Ue.array[He]=U.x,Ue.array[He+1]=U.y,Ue.array[He+2]=D.x,Ue.array[He+3]=D.y,Ue.array[He+4]=V.x,Ue.array[He+5]=V.y,He+=6;else if("faces"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)V=D=U=xe=Ue.value[qe[b]],Ue.array[He]=U.x,Ue.array[He+1]=U.y,Ue.array[He+2]=D.x,Ue.array[He+3]=D.y,Ue.array[He+4]=V.x,Ue.array[He+5]=V.y,He+=6}else if(3===Ue.size){var tt;if(tt="c"===Ue.type?["r","g","b"]:["x","y","z"],void 0===Ue.boundTo||"vertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],U=Ue.value[M.a],D=Ue.value[M.b],V=Ue.value[M.c],Ue.array[He]=U[tt[0]],Ue.array[He+1]=U[tt[1]],Ue.array[He+2]=U[tt[2]],Ue.array[He+3]=D[tt[0]],Ue.array[He+4]=D[tt[1]],Ue.array[He+5]=D[tt[2]],Ue.array[He+6]=V[tt[0]],Ue.array[He+7]=V[tt[1]],Ue.array[He+8]=V[tt[2]],He+=9;else if("faces"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)V=D=U=xe=Ue.value[qe[b]],Ue.array[He]=U[tt[0]],Ue.array[He+1]=U[tt[1]],Ue.array[He+2]=U[tt[2]],Ue.array[He+3]=D[tt[0]],Ue.array[He+4]=D[tt[1]],Ue.array[He+5]=D[tt[2]],Ue.array[He+6]=V[tt[0]],Ue.array[He+7]=V[tt[1]],Ue.array[He+8]=V[tt[2]],He+=9;else if("faceVertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)xe=Ue.value[qe[b]],U=xe[0],D=xe[1],V=xe[2],Ue.array[He]=U[tt[0]],Ue.array[He+1]=U[tt[1]],Ue.array[He+2]=U[tt[2]],Ue.array[He+3]=D[tt[0]],Ue.array[He+4]=D[tt[1]],Ue.array[He+5]=D[tt[2]],Ue.array[He+6]=V[tt[0]],Ue.array[He+7]=V[tt[1]],Ue.array[He+8]=V[tt[2]],He+=9}else if(4===Ue.size)if(void 0===Ue.boundTo||"vertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)M=Ye[qe[b]],U=Ue.value[M.a],D=Ue.value[M.b],V=Ue.value[M.c],Ue.array[He]=U.x,Ue.array[He+1]=U.y,Ue.array[He+2]=U.z,Ue.array[He+3]=U.w,Ue.array[He+4]=D.x,Ue.array[He+5]=D.y,Ue.array[He+6]=D.z,Ue.array[He+7]=D.w,Ue.array[He+8]=V.x,Ue.array[He+9]=V.y,Ue.array[He+10]=V.z,Ue.array[He+11]=V.w,He+=12;else if("faces"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)V=D=U=xe=Ue.value[qe[b]],Ue.array[He]=U.x,Ue.array[He+1]=U.y,Ue.array[He+2]=U.z,Ue.array[He+3]=U.w,Ue.array[He+4]=D.x,Ue.array[He+5]=D.y,Ue.array[He+6]=D.z,Ue.array[He+7]=D.w,Ue.array[He+8]=V.x,Ue.array[He+9]=V.y,Ue.array[He+10]=V.z,Ue.array[He+11]=V.w,He+=12;else if("faceVertices"===Ue.boundTo)for(b=0,w=qe.length;w>b;b++)xe=Ue.value[qe[b]],U=xe[0],D=xe[1],V=xe[2],Ue.array[He]=U.x,Ue.array[He+1]=U.y,Ue.array[He+2]=U.z,Ue.array[He+3]=U.w,Ue.array[He+4]=D.x,Ue.array[He+5]=D.y,Ue.array[He+6]=D.z,Ue.array[He+7]=D.w,Ue.array[He+8]=V.x,Ue.array[He+9]=V.y,Ue.array[He+10]=V.z,Ue.array[He+11]=V.w,He+=12;Y.bindBuffer(Y.ARRAY_BUFFER,Ue.buffer),Y.bufferData(Y.ARRAY_BUFFER,Ue.array,y)}v&&(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}}t.verticesNeedUpdate=!1,t.morphTargetsNeedUpdate=!1,t.elementsNeedUpdate=!1,t.uvsNeedUpdate=!1,t.normalsNeedUpdate=!1,t.colorsNeedUpdate=!1,t.tangentsNeedUpdate=!1,m.attributes&&f(m)}else if(e instanceof THREE.Line){if(m=r(e,t),T=m.attributes&&d(m),t.verticesNeedUpdate||t.colorsNeedUpdate||t.lineDistancesNeedUpdate||T){var rt,it,nt,ot,at,st,ht,lt,ct,ut,Et,pt,dt=Y.DYNAMIC_DRAW,ft=t.vertices,mt=t.colors,Tt=t.lineDistances,gt=ft.length,Rt=mt.length,yt=Tt.length,vt=t.__vertexArray,Ht=t.__colorArray,xt=t.__lineDistanceArray,bt=t.colorsNeedUpdate,wt=t.lineDistancesNeedUpdate,_t=t.__webglCustomAttributesList;if(t.verticesNeedUpdate){for(rt=0;gt>rt;rt++)ot=ft[rt],at=3*rt,vt[at]=ot.x,vt[at+1]=ot.y,vt[at+2]=ot.z;Y.bindBuffer(Y.ARRAY_BUFFER,t.__webglVertexBuffer),Y.bufferData(Y.ARRAY_BUFFER,vt,dt)}if(bt){for(it=0;Rt>it;it++)st=mt[it],at=3*it,Ht[at]=st.r,Ht[at+1]=st.g,Ht[at+2]=st.b;Y.bindBuffer(Y.ARRAY_BUFFER,t.__webglColorBuffer),Y.bufferData(Y.ARRAY_BUFFER,Ht,dt)}if(wt){for(nt=0;yt>nt;nt++)xt[nt]=Tt[nt];Y.bindBuffer(Y.ARRAY_BUFFER,t.__webglLineDistanceBuffer),Y.bufferData(Y.ARRAY_BUFFER,xt,dt)}if(_t)for(ht=0,lt=_t.length;lt>ht;ht++)if(pt=_t[ht],pt.needsUpdate&&(void 0===pt.boundTo||"vertices"===pt.boundTo)){if(at=0,ut=pt.value.length,1===pt.size)for(ct=0;ut>ct;ct++)pt.array[ct]=pt.value[ct];else if(2===pt.size)for(ct=0;ut>ct;ct++)Et=pt.value[ct],pt.array[at]=Et.x,pt.array[at+1]=Et.y,at+=2;else if(3===pt.size)if("c"===pt.type)for(ct=0;ut>ct;ct++)Et=pt.value[ct],pt.array[at]=Et.r,pt.array[at+1]=Et.g,pt.array[at+2]=Et.b,at+=3;else for(ct=0;ut>ct;ct++)Et=pt.value[ct],pt.array[at]=Et.x,pt.array[at+1]=Et.y,pt.array[at+2]=Et.z,at+=3;else if(4===pt.size)for(ct=0;ut>ct;ct++)Et=pt.value[ct],pt.array[at]=Et.x,pt.array[at+1]=Et.y,pt.array[at+2]=Et.z,pt.array[at+3]=Et.w,at+=4;Y.bindBuffer(Y.ARRAY_BUFFER,pt.buffer),Y.bufferData(Y.ARRAY_BUFFER,pt.array,dt),pt.needsUpdate=!1}}t.verticesNeedUpdate=!1,t.colorsNeedUpdate=!1,t.lineDistancesNeedUpdate=!1,m.attributes&&f(m)}else if(e instanceof THREE.PointCloud){if(m=r(e,t),T=m.attributes&&d(m),t.verticesNeedUpdate||t.colorsNeedUpdate||T){var Mt,St,Ct,At,Lt,Pt,Ft,Bt,Ut,Dt,Vt,zt=Y.DYNAMIC_DRAW,kt=t.vertices,Nt=kt.length,Ot=t.colors,Gt=Ot.length,It=t.__vertexArray,Wt=t.__colorArray,jt=t.colorsNeedUpdate,Xt=t.__webglCustomAttributesList;if(t.verticesNeedUpdate){for(Mt=0;Nt>Mt;Mt++)Ct=kt[Mt],At=3*Mt,It[At]=Ct.x,It[At+1]=Ct.y,It[At+2]=Ct.z;Y.bindBuffer(Y.ARRAY_BUFFER,t.__webglVertexBuffer),Y.bufferData(Y.ARRAY_BUFFER,It,zt)}if(jt){for(St=0;Gt>St;St++)Lt=Ot[St],At=3*St,Wt[At]=Lt.r,Wt[At+1]=Lt.g,Wt[At+2]=Lt.b;Y.bindBuffer(Y.ARRAY_BUFFER,t.__webglColorBuffer),Y.bufferData(Y.ARRAY_BUFFER,Wt,zt)}if(Xt)for(Pt=0,Ft=Xt.length;Ft>Pt;Pt++){if(Vt=Xt[Pt],Vt.needsUpdate&&(void 0===Vt.boundTo||"vertices"===Vt.boundTo))if(Ut=Vt.value.length,At=0,1===Vt.size)for(Bt=0;Ut>Bt;Bt++)Vt.array[Bt]=Vt.value[Bt];else if(2===Vt.size)for(Bt=0;Ut>Bt;Bt++)Dt=Vt.value[Bt],Vt.array[At]=Dt.x,Vt.array[At+1]=Dt.y,At+=2;else if(3===Vt.size)if("c"===Vt.type)for(Bt=0;Ut>Bt;Bt++)Dt=Vt.value[Bt],Vt.array[At]=Dt.r,Vt.array[At+1]=Dt.g,Vt.array[At+2]=Dt.b,At+=3;else for(Bt=0;Ut>Bt;Bt++)Dt=Vt.value[Bt],Vt.array[At]=Dt.x,Vt.array[At+1]=Dt.y,Vt.array[At+2]=Dt.z,At+=3;else if(4===Vt.size)for(Bt=0;Ut>Bt;Bt++)Dt=Vt.value[Bt],Vt.array[At]=Dt.x,Vt.array[At+1]=Dt.y,Vt.array[At+2]=Dt.z,Vt.array[At+3]=Dt.w,At+=4;Y.bindBuffer(Y.ARRAY_BUFFER,Vt.buffer),Y.bufferData(Y.ARRAY_BUFFER,Vt.array,zt),Vt.needsUpdate=!1}}t.verticesNeedUpdate=!1,t.colorsNeedUpdate=!1,m.attributes&&f(m)}}function d(e){for(var t in e.attributes)if(e.attributes[t].needsUpdate)return!0;return!1}function f(e){for(var t in e.attributes)e.attributes[t].needsUpdate=!1}function m(e){!0===e.transparent?Te.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha):Te.setBlending(THREE.NoBlending),Te.setDepthTest(e.depthTest),Te.setDepthWrite(e.depthWrite),Te.setColorWrite(e.colorWrite),Te.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)}function T(e,t,r,i,n){var o,a,s,h;if(re=0,i.needsUpdate){i.program&&We(i),i.addEventListener("dispose",Ge);var l=qe[i.type];if(l){var c=THREE.ShaderLib[l];i.__webglShader={uniforms:THREE.UniformsUtils.clone(c.uniforms),vertexShader:c.vertexShader,fragmentShader:c.fragmentShader}}else i.__webglShader={uniforms:i.uniforms,vertexShader:i.vertexShader,fragmentShader:i.fragmentShader};for(var u=0,E=0,p=0,d=0,f=0,m=t.length;m>f;f++){var T=t[f];T.onlyShadow||!1===T.visible||(T instanceof THREE.DirectionalLight&&u++,T instanceof THREE.PointLight&&E++,T instanceof THREE.SpotLight&&p++,T instanceof THREE.HemisphereLight&&d++)}o=u,a=E,s=p,h=d;for(var y,b=0,w=0,_=t.length;_>w;w++){var C=t[w];C.castShadow&&(C instanceof THREE.SpotLight&&b++,C instanceof THREE.DirectionalLight&&!C.shadowCascade&&b++)}y=b;var A;if(Me&&n&&n.skeleton&&n.skeleton.useVertexTexture)A=1024;else{var P=Y.getParameter(Y.MAX_VERTEX_UNIFORM_VECTORS),F=Math.floor((P-20)/4);void 0!==n&&n instanceof THREE.SkinnedMesh&&(F=Math.min(n.skeleton.bones.length,F),F0,shadowMapType:K.shadowMapType,shadowMapDebug:K.shadowMapDebug,shadowMapCascade:K.shadowMapCascade,alphaTest:i.alphaTest,metal:i.metal,wrapAround:i.wrapAround,doubleSided:i.side===THREE.DoubleSide,flipSided:i.side===THREE.BackSide},U=[];if(l?U.push(l):(U.push(i.fragmentShader),U.push(i.vertexShader)),void 0!==i.defines)for(var D in i.defines)U.push(D),U.push(i.defines[D]);for(D in B)U.push(D),U.push(B[D]);for(var V,k=U.join(),N=0,O=Q.length;O>N;N++){var G=Q[N];if(G.code===k){V=G,V.usedTimes++;break}}void 0===V&&(V=new THREE.WebGLProgram(K,k,i,B),Q.push(V),K.info.memory.programs=Q.length),i.program=V;var I=V.attributes;if(i.morphTargets){i.numSupportedMorphTargets=0;for(var W,j="morphTarget",X=0;Xle;le++)fe=t[le],fe.onlyShadow||(me=fe.color,Re=fe.intensity,ye=fe.distance,fe instanceof THREE.AmbientLight?fe.visible&&(ve+=me.r,He+=me.g,xe+=me.b):fe instanceof THREE.DirectionalLight?($e+=1,fe.visible&&(Ee.setFromMatrixPosition(fe.matrixWorld),ue.setFromMatrixPosition(fe.target.matrixWorld),Ee.sub(ue),Ee.normalize(),it=3*Ke,Ce[it]=Ee.x,Ce[it+1]=Ee.y,Ce[it+2]=Ee.z,v(Se,it,me,Re),Ke+=1)):fe instanceof THREE.PointLight?(et+=1,fe.visible&&(nt=3*Qe,v(Ae,nt,me,Re),ue.setFromMatrixPosition(fe.matrixWorld),Le[nt]=ue.x,Le[nt+1]=ue.y,Le[nt+2]=ue.z,Fe[Qe]=ye,Be[Qe]=0===fe.distance?0:fe.decay,Qe+=1)):fe instanceof THREE.SpotLight?(tt+=1,fe.visible&&(ot=3*Ze,v(Ue,ot,me,Re),Ee.setFromMatrixPosition(fe.matrixWorld),De[ot]=Ee.x,De[ot+1]=Ee.y,De[ot+2]=Ee.z,Ve[Ze]=ye,ue.setFromMatrixPosition(fe.target.matrixWorld),Ee.sub(ue),Ee.normalize(),ze[ot]=Ee.x,ze[ot+1]=Ee.y,ze[ot+2]=Ee.z,ke[Ze]=Math.cos(fe.angle),Oe[Ze]=fe.exponent,Ie[Ze]=0===fe.distance?0:fe.decay,Ze+=1)):fe instanceof THREE.HemisphereLight&&(rt+=1,fe.visible&&(Ee.setFromMatrixPosition(fe.matrixWorld),Ee.normalize(),at=3*Je,Ye[at]=Ee.x,Ye[at+1]=Ee.y,Ye[at+2]=Ee.z,Te=fe.color,ge=fe.groundColor,v(je,at,Te,Re),v(Xe,at,ge,Re),Je+=1)));for(le=3*Ke,ce=Math.max(Se.length,3*$e);ce>le;le++)Se[le]=0;for(le=3*Qe,ce=Math.max(Ae.length,3*et);ce>le;le++)Ae[le]=0;for(le=3*Ze,ce=Math.max(Ue.length,3*tt);ce>le;le++)Ue[le]=0;for(le=3*Je,ce=Math.max(je.length,3*rt);ce>le;le++)je[le]=0;for(le=3*Je,ce=Math.max(Xe.length,3*rt);ce>le;le++)Xe[le]=0;be.directional.length=Ke,be.point.length=Qe,be.spot.length=Ze,be.hemi.length=Je,be.ambient[0]=ve,be.ambient[1]=He,be.ambient[2]=xe,pe=!1}if(ne){var st=de;se.ambientLightColor.value=st.ambient,se.directionalLightColor.value=st.directional.colors,se.directionalLightDirection.value=st.directional.positions,se.pointLightColor.value=st.point.colors,se.pointLightPosition.value=st.point.positions,se.pointLightDistance.value=st.point.distances,se.pointLightDecay.value=st.point.decays,se.spotLightColor.value=st.spot.colors,se.spotLightPosition.value=st.spot.positions,se.spotLightDistance.value=st.spot.distances,se.spotLightDirection.value=st.spot.directions,se.spotLightAngleCos.value=st.spot.anglesCos,se.spotLightExponent.value=st.spot.exponents,se.spotLightDecay.value=st.spot.decays,se.hemisphereLightSkyColor.value=st.hemi.skyColors,se.hemisphereLightGroundColor.value=st.hemi.groundColors,se.hemisphereLightDirection.value=st.hemi.positions,g(se,!0)}else g(se,!1)}if(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial){se.opacity.value=i.opacity,se.diffuse.value=i.color,se.map.value=i.map,se.lightMap.value=i.lightMap,se.specularMap.value=i.specularMap,se.alphaMap.value=i.alphaMap,i.bumpMap&&(se.bumpMap.value=i.bumpMap,se.bumpScale.value=i.bumpScale),i.normalMap&&(se.normalMap.value=i.normalMap,se.normalScale.value.copy(i.normalScale));var ht;if(i.map?ht=i.map:i.specularMap?ht=i.specularMap:i.normalMap?ht=i.normalMap:i.bumpMap?ht=i.bumpMap:i.alphaMap&&(ht=i.alphaMap),void 0!==ht){var lt=ht.offset,ct=ht.repeat;se.offsetRepeat.value.set(lt.x,lt.y,ct.x,ct.y)}se.envMap.value=i.envMap,se.flipEnvMap.value=i.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,se.reflectivity.value=i.reflectivity,se.refractionRatio.value=i.refractionRatio}if(i instanceof THREE.LineBasicMaterial)se.diffuse.value=i.color,se.opacity.value=i.opacity;else if(i instanceof THREE.LineDashedMaterial)se.diffuse.value=i.color,se.opacity.value=i.opacity,se.dashSize.value=i.dashSize,se.totalSize.value=i.dashSize+i.gapSize,se.scale.value=i.scale;else if(i instanceof THREE.PointCloudMaterial){if(se.psColor.value=i.color,se.opacity.value=i.opacity,se.size.value=i.size,se.scale.value=S.height/2,se.map.value=i.map,null!==i.map){var ut=i.map.offset,Et=i.map.repeat;se.offsetRepeat.value.set(ut.x,ut.y,Et.x,Et.y)}}else i instanceof THREE.MeshPhongMaterial?(se.shininess.value=i.shininess,se.emissive.value=i.emissive,se.specular.value=i.specular,i.wrapAround&&se.wrapRGB.value.copy(i.wrapRGB)):i instanceof THREE.MeshLambertMaterial?(se.emissive.value=i.emissive,i.wrapAround&&se.wrapRGB.value.copy(i.wrapRGB)):i instanceof THREE.MeshDepthMaterial?(se.mNear.value=e.near,se.mFar.value=e.far,se.opacity.value=i.opacity):i instanceof THREE.MeshNormalMaterial&&(se.opacity.value=i.opacity);if(n.receiveShadow&&!i._shadowPass&&se.shadowMatrix)for(var pt=0,dt=0,ft=t.length;ft>dt;dt++){var mt=t[dt];mt.castShadow&&(mt instanceof THREE.SpotLight||mt instanceof THREE.DirectionalLight&&!mt.shadowCascade)&&(se.shadowMap.value[pt]=mt.shadowMap,se.shadowMapSize.value[pt]=mt.shadowMapSize,se.shadowMatrix.value[pt]=mt.shadowMatrix,se.shadowDarkness.value[pt]=mt.shadowDarkness,se.shadowBias.value[pt]=mt.shadowBias,pt++)}for(var Tt,gt,Rt,yt=i.uniformsList,vt=0,Ht=yt.length;Ht>vt;vt++){var xt=yt[vt][0];if(!1!==xt.needsUpdate){var bt=xt.type,wt=xt.value,_t=yt[vt][1];switch(bt){case"1i":Y.uniform1i(_t,wt);break;case"1f":Y.uniform1f(_t,wt);break;case"2f":Y.uniform2f(_t,wt[0],wt[1]);break;case"3f":Y.uniform3f(_t,wt[0],wt[1],wt[2]);break;case"4f":Y.uniform4f(_t,wt[0],wt[1],wt[2],wt[3]);break;case"1iv":Y.uniform1iv(_t,wt);break;case"3iv":Y.uniform3iv(_t,wt);break;case"1fv":Y.uniform1fv(_t,wt);break;case"2fv":Y.uniform2fv(_t,wt);break;case"3fv":Y.uniform3fv(_t,wt);break;case"4fv":Y.uniform4fv(_t,wt);break;case"Matrix3fv":Y.uniformMatrix3fv(_t,!1,wt);break;case"Matrix4fv":Y.uniformMatrix4fv(_t,!1,wt);break;case"i":Y.uniform1i(_t,wt);break;case"f":Y.uniform1f(_t,wt);break;case"v2":Y.uniform2f(_t,wt.x,wt.y);break;case"v3":Y.uniform3f(_t,wt.x,wt.y,wt.z);break;case"v4":Y.uniform4f(_t,wt.x,wt.y,wt.z,wt.w);break;case"c":Y.uniform3f(_t,wt.r,wt.g,wt.b);break;case"iv1":Y.uniform1iv(_t,wt);break;case"iv":Y.uniform3iv(_t,wt);break;case"fv1":Y.uniform1fv(_t,wt);break;case"fv":Y.uniform3fv(_t,wt);break;case"v2v":void 0===xt._array&&(xt._array=new Float32Array(2*wt.length));for(var Mt=0,St=wt.length;St>Mt;Mt++)Rt=2*Mt,xt._array[Rt]=wt[Mt].x,xt._array[Rt+1]=wt[Mt].y;Y.uniform2fv(_t,xt._array);break;case"v3v":for(void 0===xt._array&&(xt._array=new Float32Array(3*wt.length)),Mt=0,St=wt.length;St>Mt;Mt++)Rt=3*Mt,xt._array[Rt]=wt[Mt].x,xt._array[Rt+1]=wt[Mt].y,xt._array[Rt+2]=wt[Mt].z;Y.uniform3fv(_t,xt._array);break;case"v4v":for(void 0===xt._array&&(xt._array=new Float32Array(4*wt.length)),Mt=0,St=wt.length;St>Mt;Mt++)Rt=4*Mt,xt._array[Rt]=wt[Mt].x,xt._array[Rt+1]=wt[Mt].y,xt._array[Rt+2]=wt[Mt].z,xt._array[Rt+3]=wt[Mt].w;Y.uniform4fv(_t,xt._array);break;case"m3":Y.uniformMatrix3fv(_t,!1,wt.elements);break;case"m3v":for(void 0===xt._array&&(xt._array=new Float32Array(9*wt.length)),Mt=0,St=wt.length;St>Mt;Mt++)wt[Mt].flattenToArrayOffset(xt._array,9*Mt);Y.uniformMatrix3fv(_t,!1,xt._array);break;case"m4":Y.uniformMatrix4fv(_t,!1,wt.elements);break;case"m4v":for(void 0===xt._array&&(xt._array=new Float32Array(16*wt.length)),Mt=0,St=wt.length;St>Mt;Mt++)wt[Mt].flattenToArrayOffset(xt._array,16*Mt);Y.uniformMatrix4fv(_t,!1,xt._array);break;case"t":if(Tt=wt,gt=R(),Y.uniform1i(_t,gt),!Tt)continue;if(Tt instanceof THREE.CubeTexture||Tt.image instanceof Array&&6===Tt.image.length){var Ct=Tt,At=gt;if(6===Ct.image.length)if(Ct.needsUpdate){Ct.image.__webglTextureCube||(Ct.addEventListener("dispose",Ne),Ct.image.__webglTextureCube=Y.createTexture(),K.info.memory.textures++),Y.activeTexture(Y.TEXTURE0+At),Y.bindTexture(Y.TEXTURE_CUBE_MAP,Ct.image.__webglTextureCube),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,Ct.flipY);for(var Lt=Ct instanceof THREE.CompressedTexture,Pt=Ct.image[0]instanceof THREE.DataTexture,Ft=[],Bt=0;6>Bt;Bt++)Ft[Bt]=!K.autoScaleCubemaps||Lt||Pt?Pt?Ct.image[Bt].image:Ct.image[Bt]:x(Ct.image[Bt],we);var Ut=Ft[0],Dt=THREE.Math.isPowerOfTwo(Ut.width)&&THREE.Math.isPowerOfTwo(Ut.height),Vt=M(Ct.format),zt=M(Ct.type);for(H(Y.TEXTURE_CUBE_MAP,Ct,Dt),Bt=0;6>Bt;Bt++)if(Lt)for(var kt,Nt=Ft[Bt].mipmaps,Ot=0,Gt=Nt.length;Gt>Ot;Ot++)kt=Nt[Ot],Ct.format!==THREE.RGBAFormat&&Ct.format!==THREE.RGBFormat?-1Mt;Mt++)xt._array[Mt]=R();for(Y.uniform1iv(_t,xt._array),Mt=0,St=xt.value.length;St>Mt;Mt++)Tt=xt.value[Mt],gt=xt._array[Mt],Tt&&K.setTexture(Tt,gt);break;default:THREE.warn("THREE.WebGLRenderer: Unknown uniform type: "+bt)}}}}return Y.uniformMatrix4fv(ae.modelViewMatrix,!1,n._modelViewMatrix.elements),ae.normalMatrix&&Y.uniformMatrix3fv(ae.normalMatrix,!1,n._normalMatrix.elements),null!==ae.modelMatrix&&Y.uniformMatrix4fv(ae.modelMatrix,!1,n.matrixWorld.elements),oe}function g(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLightColor.needsUpdate=t,e.directionalLightDirection.needsUpdate=t,e.pointLightColor.needsUpdate=t,e.pointLightPosition.needsUpdate=t,e.pointLightDistance.needsUpdate=t,e.pointLightDecay.needsUpdate=t,e.spotLightColor.needsUpdate=t,e.spotLightPosition.needsUpdate=t,e.spotLightDistance.needsUpdate=t,e.spotLightDirection.needsUpdate=t,e.spotLightAngleCos.needsUpdate=t,e.spotLightExponent.needsUpdate=t,e.spotLightDecay.needsUpdate=t,e.hemisphereLightSkyColor.needsUpdate=t,e.hemisphereLightGroundColor.needsUpdate=t,e.hemisphereLightDirection.needsUpdate=t}function R(){var e=re;return e>=He&&THREE.warn("WebGLRenderer: trying to use "+e+" texture units while this GPU supports only "+He),re+=1,e}function y(e,t){e._modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld),e._normalMatrix.getNormalMatrix(e._modelViewMatrix)}function v(e,t,r,i){e[t]=r.r*i,e[t+1]=r.g*i,e[t+2]=r.b*i}function H(e,t,r){r?(Y.texParameteri(e,Y.TEXTURE_WRAP_S,M(t.wrapS)),Y.texParameteri(e,Y.TEXTURE_WRAP_T,M(t.wrapT)),Y.texParameteri(e,Y.TEXTURE_MAG_FILTER,M(t.magFilter)),Y.texParameteri(e,Y.TEXTURE_MIN_FILTER,M(t.minFilter))):(Y.texParameteri(e,Y.TEXTURE_WRAP_S,Y.CLAMP_TO_EDGE),Y.texParameteri(e,Y.TEXTURE_WRAP_T,Y.CLAMP_TO_EDGE),t.wrapS===THREE.ClampToEdgeWrapping&&t.wrapT===THREE.ClampToEdgeWrapping||THREE.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping. ( "+t.sourceFile+" )"),Y.texParameteri(e,Y.TEXTURE_MAG_FILTER,_(t.magFilter)),Y.texParameteri(e,Y.TEXTURE_MIN_FILTER,_(t.minFilter)),t.minFilter!==THREE.NearestFilter&&t.minFilter!==THREE.LinearFilter&&THREE.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter. ( "+t.sourceFile+" )")),(r=ge.get("EXT_texture_filter_anisotropic"))&&t.type!==THREE.FloatType&&t.type!==THREE.HalfFloatType&&(1t||e.height>t){var r=t/Math.max(e.width,e.height),i=document.createElement("canvas");return i.width=Math.floor(e.width*r),i.height=Math.floor(e.height*r),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),THREE.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function b(e,t){Y.bindRenderbuffer(Y.RENDERBUFFER,e),t.depthBuffer&&!t.stencilBuffer?(Y.renderbufferStorage(Y.RENDERBUFFER,Y.DEPTH_COMPONENT16,t.width,t.height),Y.framebufferRenderbuffer(Y.FRAMEBUFFER,Y.DEPTH_ATTACHMENT,Y.RENDERBUFFER,e)):t.depthBuffer&&t.stencilBuffer?(Y.renderbufferStorage(Y.RENDERBUFFER,Y.DEPTH_STENCIL,t.width,t.height),Y.framebufferRenderbuffer(Y.FRAMEBUFFER,Y.DEPTH_STENCIL_ATTACHMENT,Y.RENDERBUFFER,e)):Y.renderbufferStorage(Y.RENDERBUFFER,Y.RGBA4,t.width,t.height)}function w(e){e instanceof THREE.WebGLRenderTargetCube?(Y.bindTexture(Y.TEXTURE_CUBE_MAP,e.__webglTexture),Y.generateMipmap(Y.TEXTURE_CUBE_MAP),Y.bindTexture(Y.TEXTURE_CUBE_MAP,null)):(Y.bindTexture(Y.TEXTURE_2D,e.__webglTexture),Y.generateMipmap(Y.TEXTURE_2D),Y.bindTexture(Y.TEXTURE_2D,null))}function _(e){return e===THREE.NearestFilter||e===THREE.NearestMipMapNearestFilter||e===THREE.NearestMipMapLinearFilter?Y.NEAREST:Y.LINEAR}function M(e){var t;if(e===THREE.RepeatWrapping)return Y.REPEAT;if(e===THREE.ClampToEdgeWrapping)return Y.CLAMP_TO_EDGE;if(e===THREE.MirroredRepeatWrapping)return Y.MIRRORED_REPEAT;if(e===THREE.NearestFilter)return Y.NEAREST;if(e===THREE.NearestMipMapNearestFilter)return Y.NEAREST_MIPMAP_NEAREST;if(e===THREE.NearestMipMapLinearFilter)return Y.NEAREST_MIPMAP_LINEAR;if(e===THREE.LinearFilter)return Y.LINEAR;if(e===THREE.LinearMipMapNearestFilter)return Y.LINEAR_MIPMAP_NEAREST;if(e===THREE.LinearMipMapLinearFilter)return Y.LINEAR_MIPMAP_LINEAR;if(e===THREE.UnsignedByteType)return Y.UNSIGNED_BYTE;if(e===THREE.UnsignedShort4444Type)return Y.UNSIGNED_SHORT_4_4_4_4;if(e===THREE.UnsignedShort5551Type)return Y.UNSIGNED_SHORT_5_5_5_1;if(e===THREE.UnsignedShort565Type)return Y.UNSIGNED_SHORT_5_6_5;if(e===THREE.ByteType)return Y.BYTE;if(e===THREE.ShortType)return Y.SHORT;if(e===THREE.UnsignedShortType)return Y.UNSIGNED_SHORT;if(e===THREE.IntType)return Y.INT;if(e===THREE.UnsignedIntType)return Y.UNSIGNED_INT;if(e===THREE.FloatType)return Y.FLOAT;if(t=ge.get("OES_texture_half_float"),null!==t&&e===THREE.HalfFloatType)return t.HALF_FLOAT_OES;if(e===THREE.AlphaFormat)return Y.ALPHA;if(e===THREE.RGBFormat)return Y.RGB;if(e===THREE.RGBAFormat)return Y.RGBA;if(e===THREE.LuminanceFormat)return Y.LUMINANCE;if(e===THREE.LuminanceAlphaFormat)return Y.LUMINANCE_ALPHA;if(e===THREE.AddEquation)return Y.FUNC_ADD;if(e===THREE.SubtractEquation)return Y.FUNC_SUBTRACT;if(e===THREE.ReverseSubtractEquation)return Y.FUNC_REVERSE_SUBTRACT;if(e===THREE.ZeroFactor)return Y.ZERO;if(e===THREE.OneFactor)return Y.ONE;if(e===THREE.SrcColorFactor)return Y.SRC_COLOR;if(e===THREE.OneMinusSrcColorFactor)return Y.ONE_MINUS_SRC_COLOR;if(e===THREE.SrcAlphaFactor)return Y.SRC_ALPHA;if(e===THREE.OneMinusSrcAlphaFactor)return Y.ONE_MINUS_SRC_ALPHA;if(e===THREE.DstAlphaFactor)return Y.DST_ALPHA;if(e===THREE.OneMinusDstAlphaFactor)return Y.ONE_MINUS_DST_ALPHA;if(e===THREE.DstColorFactor)return Y.DST_COLOR;if(e===THREE.OneMinusDstColorFactor)return Y.ONE_MINUS_DST_COLOR;if(e===THREE.SrcAlphaSaturateFactor)return Y.SRC_ALPHA_SATURATE;if(t=ge.get("WEBGL_compressed_texture_s3tc"),null!==t){if(e===THREE.RGB_S3TC_DXT1_Format)return t.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===THREE.RGBA_S3TC_DXT1_Format)return t.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===THREE.RGBA_S3TC_DXT3_Format)return t.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===THREE.RGBA_S3TC_DXT5_Format)return t.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(t=ge.get("WEBGL_compressed_texture_pvrtc"),null!==t){if(e===THREE.RGB_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===THREE.RGB_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===THREE.RGBA_PVRTC_4BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===THREE.RGBA_PVRTC_2BPPV1_Format)return t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(t=ge.get("EXT_blend_minmax"),null!==t){if(e===THREE.MinEquation)return t.MIN_EXT;if(e===THREE.MaxEquation)return t.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION),e=e||{};var S=void 0!==e.canvas?e.canvas:document.createElement("canvas"),C=void 0!==e.context?e.context:null,A=1,L=void 0!==e.precision?e.precision:"highp",P=void 0!==e.alpha?e.alpha:!1,F=void 0!==e.depth?e.depth:!0,B=void 0!==e.stencil?e.stencil:!0,U=void 0!==e.antialias?e.antialias:!1,D=void 0!==e.premultipliedAlpha?e.premultipliedAlpha:!0,V=void 0!==e.preserveDrawingBuffer?e.preserveDrawingBuffer:!1,z=void 0!==e.logarithmicDepthBuffer?e.logarithmicDepthBuffer:!1,k=new THREE.Color(0),N=0,O=[],G={},I=[],W=[],j=[],X=[],q=[];this.domElement=S,this.context=null,this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0,this.gammaFactor=2,this.shadowMapEnabled=this.gammaOutput=this.gammaInput=!1,this.shadowMapType=THREE.PCFShadowMap,this.shadowMapCullFace=THREE.CullFaceFront,this.shadowMapCascade=this.shadowMapDebug=!1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var Y,K=this,Q=[],Z=null,J=null,$=-1,ee="",te=null,re=0,ie=0,ne=0,oe=S.width,ae=S.height,se=0,he=0,le=new THREE.Frustum,ce=new THREE.Matrix4,ue=new THREE.Vector3,Ee=new THREE.Vector3,pe=!0,de={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[],decays:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[],decays:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}};try{var fe={alpha:P,depth:F,stencil:B,antialias:U,premultipliedAlpha:D,preserveDrawingBuffer:V};if(Y=C||S.getContext("webgl",fe)||S.getContext("experimental-webgl",fe),null===Y){if(null!==S.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context."}S.addEventListener("webglcontextlost",function(e){e.preventDefault(),ve(),ye(),G={}},!1)}catch(me){THREE.error("THREE.WebGLRenderer: "+me)}var Te=new THREE.WebGLState(Y,M);void 0===Y.getShaderPrecisionFormat&&(Y.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});var ge=new THREE.WebGLExtensions(Y);ge.get("OES_texture_float"),ge.get("OES_texture_float_linear"),ge.get("OES_texture_half_float"),ge.get("OES_texture_half_float_linear"),ge.get("OES_standard_derivatives"),z&&ge.get("EXT_frag_depth");var Re=function(e,t,r,i){!0===D&&(e*=i,t*=i,r*=i),Y.clearColor(e,t,r,i)},ye=function(){Y.clearColor(0,0,0,1),Y.clearDepth(1),Y.clearStencil(0),Y.enable(Y.DEPTH_TEST),Y.depthFunc(Y.LEQUAL),Y.frontFace(Y.CCW),Y.cullFace(Y.BACK),Y.enable(Y.CULL_FACE),Y.enable(Y.BLEND),Y.blendEquation(Y.FUNC_ADD),Y.blendFunc(Y.SRC_ALPHA,Y.ONE_MINUS_SRC_ALPHA),Y.viewport(ie,ne,oe,ae),Re(k.r,k.g,k.b,N)},ve=function(){te=Z=null,ee="",$=-1,pe=!0,Te.reset()};ye(),this.context=Y,this.state=Te;var He=Y.getParameter(Y.MAX_TEXTURE_IMAGE_UNITS),xe=Y.getParameter(Y.MAX_VERTEX_TEXTURE_IMAGE_UNITS),be=Y.getParameter(Y.MAX_TEXTURE_SIZE),we=Y.getParameter(Y.MAX_CUBE_MAP_TEXTURE_SIZE),_e=xe>0,Me=_e&&ge.get("OES_texture_float"),Se=Y.getShaderPrecisionFormat(Y.VERTEX_SHADER,Y.HIGH_FLOAT),Ce=Y.getShaderPrecisionFormat(Y.VERTEX_SHADER,Y.MEDIUM_FLOAT),Ae=Y.getShaderPrecisionFormat(Y.FRAGMENT_SHADER,Y.HIGH_FLOAT),Le=Y.getShaderPrecisionFormat(Y.FRAGMENT_SHADER,Y.MEDIUM_FLOAT),Pe=function(){var e;return function(){if(void 0!==e)return e;if(e=[],ge.get("WEBGL_compressed_texture_pvrtc")||ge.get("WEBGL_compressed_texture_s3tc"))for(var t=Y.getParameter(Y.COMPRESSED_TEXTURE_FORMATS),r=0;r=0;r--)t[r].object===e&&t.splice(r,1);delete e.__webglInit,delete e._modelViewMatrix,delete e._normalMatrix,delete e.__webglActive})},ke=function(e){if(e=e.target,e.removeEventListener("dispose",ke),delete e.__webglInit,e instanceof THREE.BufferGeometry){for(var t in e.attributes){var r=e.attributes[t];void 0!==r.buffer&&(Y.deleteBuffer(r.buffer),delete r.buffer)}K.info.memory.geometries--}else if(t=je[e.id],void 0!==t){for(var r=0,i=t.length;i>r;r++){var n=t[r];if(void 0!==n.numMorphTargets){for(var o=0,a=n.numMorphTargets;a>o;o++)Y.deleteBuffer(n.__webglMorphTargetsBuffers[o]);delete n.__webglMorphTargetsBuffers}if(void 0!==n.numMorphNormals){for(o=0,a=n.numMorphNormals;a>o;o++)Y.deleteBuffer(n.__webglMorphNormalsBuffers[o]);delete n.__webglMorphNormalsBuffers}Ie(n)}delete je[e.id]}else Ie(e);ee=""},Ne=function(e){e=e.target,e.removeEventListener("dispose",Ne),e.image&&e.image.__webglTextureCube?(Y.deleteTexture(e.image.__webglTextureCube),delete e.image.__webglTextureCube):void 0!==e.__webglInit&&(Y.deleteTexture(e.__webglTexture),delete e.__webglTexture,delete e.__webglInit),K.info.memory.textures--},Oe=function(e){if(e=e.target,e.removeEventListener("dispose",Oe),e&&void 0!==e.__webglTexture){if(Y.deleteTexture(e.__webglTexture),delete e.__webglTexture,e instanceof THREE.WebGLRenderTargetCube)for(var t=0;6>t;t++)Y.deleteFramebuffer(e.__webglFramebuffer[t]),Y.deleteRenderbuffer(e.__webglRenderbuffer[t]);else Y.deleteFramebuffer(e.__webglFramebuffer),Y.deleteRenderbuffer(e.__webglRenderbuffer);delete e.__webglFramebuffer,delete e.__webglRenderbuffer}K.info.memory.textures--},Ge=function(e){e=e.target,e.removeEventListener("dispose",Ge),We(e)},Ie=function(e){for(var t="__webglVertexBuffer __webglNormalBuffer __webglTangentBuffer __webglColorBuffer __webglUVBuffer __webglUV2Buffer __webglSkinIndicesBuffer __webglSkinWeightsBuffer __webglFaceBuffer __webglLineBuffer __webglLineDistanceBuffer".split(" "),r=0,i=t.length;i>r;r++){var n=t[r];void 0!==e[n]&&(Y.deleteBuffer(e[n]),delete e[n])}if(void 0!==e.__webglCustomAttributesList){for(n in e.__webglCustomAttributesList)Y.deleteBuffer(e.__webglCustomAttributesList[n].buffer);delete e.__webglCustomAttributesList}K.info.memory.geometries--},We=function(e){var t=e.program.program;if(void 0!==t){e.program=void 0;var r,i,n=!1;for(e=0,r=Q.length;r>e;e++)if(i=Q[e],i.program===t){i.usedTimes--,0===i.usedTimes&&(n=!0);break}if(!0===n){for(n=[],e=0,r=Q.length;r>e;e++)i=Q[e],i.program!==t&&n.push(i);Q=n,Y.deleteProgram(t),K.info.memory.programs--}}};this.renderBufferImmediate=function(e,t,r){if(Te.initAttributes(),e.hasPositions&&!e.__webglVertexBuffer&&(e.__webglVertexBuffer=Y.createBuffer()),e.hasNormals&&!e.__webglNormalBuffer&&(e.__webglNormalBuffer=Y.createBuffer()),e.hasUvs&&!e.__webglUvBuffer&&(e.__webglUvBuffer=Y.createBuffer()),e.hasColors&&!e.__webglColorBuffer&&(e.__webglColorBuffer=Y.createBuffer()),e.hasPositions&&(Y.bindBuffer(Y.ARRAY_BUFFER,e.__webglVertexBuffer),Y.bufferData(Y.ARRAY_BUFFER,e.positionArray,Y.DYNAMIC_DRAW),Te.enableAttribute(t.attributes.position),Y.vertexAttribPointer(t.attributes.position,3,Y.FLOAT,!1,0,0)),e.hasNormals){if(Y.bindBuffer(Y.ARRAY_BUFFER,e.__webglNormalBuffer),!1==r instanceof THREE.MeshPhongMaterial&&r.shading===THREE.FlatShading){var i,n,o,a,s,h,l,c,u,E,p,d=3*e.count;for(p=0;d>p;p+=9)E=e.normalArray,i=E[p],n=E[p+1],o=E[p+2],a=E[p+3],h=E[p+4],c=E[p+5],s=E[p+6],l=E[p+7],u=E[p+8],i=(i+a+s)/3,n=(n+h+l)/3,o=(o+c+u)/3,E[p]=i,E[p+1]=n,E[p+2]=o,E[p+3]=i,E[p+4]=n,E[p+5]=o,E[p+6]=i,E[p+7]=n,E[p+8]=o}Y.bufferData(Y.ARRAY_BUFFER,e.normalArray,Y.DYNAMIC_DRAW),Te.enableAttribute(t.attributes.normal),Y.vertexAttribPointer(t.attributes.normal,3,Y.FLOAT,!1,0,0)}e.hasUvs&&r.map&&(Y.bindBuffer(Y.ARRAY_BUFFER,e.__webglUvBuffer),Y.bufferData(Y.ARRAY_BUFFER,e.uvArray,Y.DYNAMIC_DRAW),Te.enableAttribute(t.attributes.uv),Y.vertexAttribPointer(t.attributes.uv,2,Y.FLOAT,!1,0,0)),e.hasColors&&r.vertexColors!==THREE.NoColors&&(Y.bindBuffer(Y.ARRAY_BUFFER,e.__webglColorBuffer),Y.bufferData(Y.ARRAY_BUFFER,e.colorArray,Y.DYNAMIC_DRAW),Te.enableAttribute(t.attributes.color),Y.vertexAttribPointer(t.attributes.color,3,Y.FLOAT,!1,0,0)),Te.disableUnusedAttributes(),Y.drawArrays(Y.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,t,r,n,o,a){if(!1!==n.visible)if(p(a),e=T(e,t,r,n,a),t=!1,r="direct_"+o.id+"_"+e.id+"_"+(n.wireframe?1:0),r!==ee&&(ee=r,t=!0),t&&Te.initAttributes(),a instanceof THREE.Mesh){a=!0===n.wireframe?Y.LINES:Y.TRIANGLES;var s=o.attributes.index;if(s){var h,l;if(s.array instanceof Uint32Array&&ge.get("OES_element_index_uint")?(h=Y.UNSIGNED_INT,l=4):(h=Y.UNSIGNED_SHORT,l=2),r=o.offsets,0===r.length)t&&(i(n,e,o,0),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,s.array.length,h,0),K.info.render.calls++,K.info.render.vertices+=s.array.length,K.info.render.faces+=s.array.length/3;else{t=!0;for(var c=0,u=r.length;u>c;c++){var E=r[c].index;t&&(i(n,e,o,E),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,r[c].count,h,r[c].start*l),K.info.render.calls++,K.info.render.vertices+=r[c].count,K.info.render.faces+=r[c].count/3}}}else t&&i(n,e,o,0),n=o.attributes.position,Y.drawArrays(a,0,n.array.length/n.itemSize),K.info.render.calls++,K.info.render.vertices+=n.array.length/n.itemSize,K.info.render.faces+=n.array.length/(3*n.itemSize)}else if(a instanceof THREE.PointCloud)if(a=Y.POINTS,s=o.attributes.index)if(s.array instanceof Uint32Array&&ge.get("OES_element_index_uint")?(h=Y.UNSIGNED_INT,l=4):(h=Y.UNSIGNED_SHORT,l=2),r=o.offsets,0===r.length)t&&(i(n,e,o,0),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,s.array.length,h,0),K.info.render.calls++,K.info.render.points+=s.array.length;else for(1c;c++)E=r[c].index,t&&(i(n,e,o,E),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,r[c].count,h,r[c].start*l),K.info.render.calls++,K.info.render.points+=r[c].count;else if(t&&i(n,e,o,0),n=o.attributes.position,r=o.offsets,0===r.length)Y.drawArrays(a,0,n.array.length/3),K.info.render.calls++,K.info.render.points+=n.array.length/3;else for(c=0,u=r.length;u>c;c++)Y.drawArrays(a,r[c].index,r[c].count),K.info.render.calls++,K.info.render.points+=r[c].count;else if(a instanceof THREE.Line)if(a=a.mode===THREE.LineStrip?Y.LINE_STRIP:Y.LINES,Te.setLineWidth(n.linewidth*A),s=o.attributes.index)if(s.array instanceof Uint32Array?(h=Y.UNSIGNED_INT,l=4):(h=Y.UNSIGNED_SHORT,l=2),r=o.offsets,0===r.length)t&&(i(n,e,o,0),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,s.array.length,h,0),K.info.render.calls++,K.info.render.vertices+=s.array.length;else for(1c;c++)E=r[c].index,t&&(i(n,e,o,E),Y.bindBuffer(Y.ELEMENT_ARRAY_BUFFER,s.buffer)),Y.drawElements(a,r[c].count,h,r[c].start*l),K.info.render.calls++,K.info.render.vertices+=r[c].count;else if(t&&i(n,e,o,0),n=o.attributes.position,r=o.offsets,0===r.length)Y.drawArrays(a,0,n.array.length/3),K.info.render.calls++,K.info.render.vertices+=n.array.length/3;else for(c=0,u=r.length;u>c;c++)Y.drawArrays(a,r[c].index,r[c].count),K.info.render.calls++,K.info.render.vertices+=r[c].count},this.renderBuffer=function(e,t,r,i,n,o){if(!1!==i.visible){if(p(o),r=T(e,t,r,i,o),t=r.attributes,e=!1,r=n.id+"_"+r.id+"_"+(i.wireframe?1:0),r!==ee&&(ee=r,e=!0),e&&Te.initAttributes(),!i.morphTargets&&0<=t.position)e&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglVertexBuffer), +Te.enableAttribute(t.position),Y.vertexAttribPointer(t.position,3,Y.FLOAT,!1,0,0));else if(o.morphTargetBase){if(r=i.program.attributes,-1!==o.morphTargetBase&&0<=r.position?(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[o.morphTargetBase]),Te.enableAttribute(r.position),Y.vertexAttribPointer(r.position,3,Y.FLOAT,!1,0,0)):0<=r.position&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglVertexBuffer),Te.enableAttribute(r.position),Y.vertexAttribPointer(r.position,3,Y.FLOAT,!1,0,0)),o.morphTargetForcedOrder.length)for(var s,h=0,l=o.morphTargetForcedOrder,c=o.morphTargetInfluences;h=0&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[l[h]]),Te.enableAttribute(s),Y.vertexAttribPointer(s,3,Y.FLOAT,!1,0,0)),s=r["morphNormal"+h],s>=0&&i.morphNormals&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglMorphNormalsBuffers[l[h]]),Te.enableAttribute(s),Y.vertexAttribPointer(s,3,Y.FLOAT,!1,0,0)),o.__webglMorphTargetInfluences[h]=c[l[h]],h++;else{for(l=[],c=o.morphTargetInfluences,h=o.geometry.morphTargets,c.length>h.length&&(console.warn("THREE.WebGLRenderer: Influences array is bigger than morphTargets array."),c.length=h.length),h=0,s=c.length;s>h;h++)l.push([c[h],h]);l.length>i.numSupportedMorphTargets?(l.sort(a),l.length=i.numSupportedMorphTargets):l.length>i.numSupportedMorphNormals?l.sort(a):0===l.length&&l.push([0,0]);for(var h=0,u=i.numSupportedMorphTargets;u>h;h++)if(l[h]){var E=l[h][1];s=r["morphTarget"+h],s>=0&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[E]),Te.enableAttribute(s),Y.vertexAttribPointer(s,3,Y.FLOAT,!1,0,0)),s=r["morphNormal"+h],s>=0&&i.morphNormals&&(Y.bindBuffer(Y.ARRAY_BUFFER,n.__webglMorphNormalsBuffers[E]),Te.enableAttribute(s),Y.vertexAttribPointer(s,3,Y.FLOAT,!1,0,0)),o.__webglMorphTargetInfluences[h]=c[E]}else o.__webglMorphTargetInfluences[h]=0}null!==i.program.uniforms.morphTargetInfluences&&Y.uniform1fv(i.program.uniforms.morphTargetInfluences,o.__webglMorphTargetInfluences)}if(e){if(n.__webglCustomAttributesList)for(r=0,c=n.__webglCustomAttributesList.length;c>r;r++)l=n.__webglCustomAttributesList[r],0<=t[l.buffer.belongsToAttribute]&&(Y.bindBuffer(Y.ARRAY_BUFFER,l.buffer),Te.enableAttribute(t[l.buffer.belongsToAttribute]),Y.vertexAttribPointer(t[l.buffer.belongsToAttribute],l.size,Y.FLOAT,!1,0,0));0<=t.color&&(0i;i++){var E=I[i],p=E.object;p.visible&&(y(p,t),c(E))}e.overrideMaterial?(i=e.overrideMaterial,m(i),h(W,t,O,a,i),h(j,t,O,a,i),l(I,"",t,O,a,i)):(Te.setBlending(THREE.NoBlending),h(W,t,O,a,null),l(I,"opaque",t,O,a,null),h(j,t,O,a,null),l(I,"transparent",t,O,a,null)),De.render(e,t),Ve.render(e,t,se,he),r&&r.generateMipmaps&&r.minFilter!==THREE.NearestFilter&&r.minFilter!==THREE.LinearFilter&&w(r),Te.setDepthTest(!0),Te.setDepthWrite(!0),Te.setColorWrite(!0)}},this.renderImmediateObject=function(e,t,r,i,n){var o=T(e,t,r,i,n);ee="",K.setMaterialFaces(i),n.immediateRenderCallback?n.immediateRenderCallback(o,Y,le):n.render(function(e){K.renderBufferImmediate(e,o,i)})};var je={},Xe=0,qe={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointCloudMaterial:"particle_basic"};this.setFaceCulling=function(e,t){e===THREE.CullFaceNone?Y.disable(Y.CULL_FACE):(t===THREE.FrontFaceDirectionCW?Y.frontFace(Y.CW):Y.frontFace(Y.CCW),e===THREE.CullFaceBack?Y.cullFace(Y.BACK):e===THREE.CullFaceFront?Y.cullFace(Y.FRONT):Y.cullFace(Y.FRONT_AND_BACK),Y.enable(Y.CULL_FACE))},this.setMaterialFaces=function(e){Te.setDoubleSided(e.side===THREE.DoubleSide),Te.setFlipSided(e.side===THREE.BackSide)},this.uploadTexture=function(e){void 0===e.__webglInit&&(e.__webglInit=!0,e.addEventListener("dispose",Ne),e.__webglTexture=Y.createTexture(),K.info.memory.textures++),Y.bindTexture(Y.TEXTURE_2D,e.__webglTexture),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,e.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,e.unpackAlignment),e.image=x(e.image,be);var t=e.image,r=THREE.Math.isPowerOfTwo(t.width)&&THREE.Math.isPowerOfTwo(t.height),i=M(e.format),n=M(e.type);H(Y.TEXTURE_2D,e,r);var o=e.mipmaps;if(e instanceof THREE.DataTexture)if(0a;a++)t=o[a],Y.texImage2D(Y.TEXTURE_2D,a,i,t.width,t.height,0,i,n,t.data);e.generateMipmaps=!1}else Y.texImage2D(Y.TEXTURE_2D,0,i,t.width,t.height,0,i,n,t.data);else if(e instanceof THREE.CompressedTexture)for(a=0,s=o.length;s>a;a++)t=o[a],e.format!==THREE.RGBAFormat&&e.format!==THREE.RGBFormat?-1a;a++)t=o[a],Y.texImage2D(Y.TEXTURE_2D,a,i,i,n,t);e.generateMipmaps=!1}else Y.texImage2D(Y.TEXTURE_2D,0,i,i,n,e.image);e.generateMipmaps&&r&&Y.generateMipmap(Y.TEXTURE_2D),e.needsUpdate=!1,e.onUpdate&&e.onUpdate()},this.setTexture=function(e,t){Y.activeTexture(Y.TEXTURE0+t),e.needsUpdate?K.uploadTexture(e):Y.bindTexture(Y.TEXTURE_2D,e.__webglTexture)},this.setRenderTarget=function(e){var t=e instanceof THREE.WebGLRenderTargetCube;if(e&&void 0===e.__webglFramebuffer){void 0===e.depthBuffer&&(e.depthBuffer=!0),void 0===e.stencilBuffer&&(e.stencilBuffer=!0),e.addEventListener("dispose",Oe),e.__webglTexture=Y.createTexture(),K.info.memory.textures++;var r=THREE.Math.isPowerOfTwo(e.width)&&THREE.Math.isPowerOfTwo(e.height),i=M(e.format),n=M(e.type);if(t){e.__webglFramebuffer=[],e.__webglRenderbuffer=[],Y.bindTexture(Y.TEXTURE_CUBE_MAP,e.__webglTexture),H(Y.TEXTURE_CUBE_MAP,e,r);for(var o=0;6>o;o++){e.__webglFramebuffer[o]=Y.createFramebuffer(),e.__webglRenderbuffer[o]=Y.createRenderbuffer(),Y.texImage2D(Y.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,i,e.width,e.height,0,i,n,null);var a=e,s=Y.TEXTURE_CUBE_MAP_POSITIVE_X+o;Y.bindFramebuffer(Y.FRAMEBUFFER,e.__webglFramebuffer[o]),Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,s,a.__webglTexture,0),b(e.__webglRenderbuffer[o],e)}r&&Y.generateMipmap(Y.TEXTURE_CUBE_MAP)}else e.__webglFramebuffer=Y.createFramebuffer(),e.__webglRenderbuffer=e.shareDepthFrom?e.shareDepthFrom.__webglRenderbuffer:Y.createRenderbuffer(),Y.bindTexture(Y.TEXTURE_2D,e.__webglTexture),H(Y.TEXTURE_2D,e,r),Y.texImage2D(Y.TEXTURE_2D,0,i,e.width,e.height,0,i,n,null),i=Y.TEXTURE_2D,Y.bindFramebuffer(Y.FRAMEBUFFER,e.__webglFramebuffer),Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,i,e.__webglTexture,0),e.shareDepthFrom?e.depthBuffer&&!e.stencilBuffer?Y.framebufferRenderbuffer(Y.FRAMEBUFFER,Y.DEPTH_ATTACHMENT,Y.RENDERBUFFER,e.__webglRenderbuffer):e.depthBuffer&&e.stencilBuffer&&Y.framebufferRenderbuffer(Y.FRAMEBUFFER,Y.DEPTH_STENCIL_ATTACHMENT,Y.RENDERBUFFER,e.__webglRenderbuffer):b(e.__webglRenderbuffer,e),r&&Y.generateMipmap(Y.TEXTURE_2D);t?Y.bindTexture(Y.TEXTURE_CUBE_MAP,null):Y.bindTexture(Y.TEXTURE_2D,null),Y.bindRenderbuffer(Y.RENDERBUFFER,null),Y.bindFramebuffer(Y.FRAMEBUFFER,null)}e?(t=t?e.__webglFramebuffer[e.activeCubeFace]:e.__webglFramebuffer,r=e.width,e=e.height,n=i=0):(t=null,r=oe,e=ae,i=ie,n=ne),t!==J&&(Y.bindFramebuffer(Y.FRAMEBUFFER,t),Y.viewport(i,n,r,e),J=t),se=r,he=e},this.readRenderTargetPixels=function(e,t,r,i,n,o){if(e instanceof THREE.WebGLRenderTarget){if(e.__webglFramebuffer)if(e.format!==THREE.RGBAFormat)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA format. readPixels can read only RGBA format.");else{var a=!1;e.__webglFramebuffer!==J&&(Y.bindFramebuffer(Y.FRAMEBUFFER,e.__webglFramebuffer),a=!0),Y.checkFramebufferStatus(Y.FRAMEBUFFER)===Y.FRAMEBUFFER_COMPLETE?Y.readPixels(t,r,i,n,Y.RGBA,Y.UNSIGNED_BYTE,o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."),a&&Y.bindFramebuffer(Y.FRAMEBUFFER,J)}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.initMaterial=function(){THREE.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},this.addPrePlugin=function(){THREE.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},this.addPostPlugin=function(){THREE.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},this.updateShadowMap=function(){THREE.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},THREE.WebGLRenderTarget=function(e,t,r){this.width=e,this.height=t,r=r||{},this.wrapS=void 0!==r.wrapS?r.wrapS:THREE.ClampToEdgeWrapping,this.wrapT=void 0!==r.wrapT?r.wrapT:THREE.ClampToEdgeWrapping,this.magFilter=void 0!==r.magFilter?r.magFilter:THREE.LinearFilter,this.minFilter=void 0!==r.minFilter?r.minFilter:THREE.LinearMipMapLinearFilter,this.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,this.offset=new THREE.Vector2(0,0),this.repeat=new THREE.Vector2(1,1),this.format=void 0!==r.format?r.format:THREE.RGBAFormat,this.type=void 0!==r.type?r.type:THREE.UnsignedByteType,this.depthBuffer=void 0!==r.depthBuffer?r.depthBuffer:!0,this.stencilBuffer=void 0!==r.stencilBuffer?r.stencilBuffer:!0,this.generateMipmaps=!0,this.shareDepthFrom=void 0!==r.shareDepthFrom?r.shareDepthFrom:null},THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(e,t){this.width=e,this.height=t},clone:function(){var e=new THREE.WebGLRenderTarget(this.width,this.height);return e.wrapS=this.wrapS,e.wrapT=this.wrapT,e.magFilter=this.magFilter,e.minFilter=this.minFilter,e.anisotropy=this.anisotropy,e.offset.copy(this.offset),e.repeat.copy(this.repeat),e.format=this.format,e.type=this.type,e.depthBuffer=this.depthBuffer,e.stencilBuffer=this.stencilBuffer,e.generateMipmaps=this.generateMipmaps,e.shareDepthFrom=this.shareDepthFrom,e},dispose:function(){this.dispatchEvent({type:"dispose"})}},THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype),THREE.WebGLRenderTargetCube=function(e,t,r){THREE.WebGLRenderTarget.call(this,e,t,r),this.activeCubeFace=0},THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype),THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube,THREE.WebGLExtensions=function(e){var t={};this.get=function(r){if(void 0!==t[r])return t[r];var i;switch(r){case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(r)}return null===i&&THREE.warn("THREE.WebGLRenderer: "+r+" extension not supported."),t[r]=i}},THREE.WebGLProgram=function(){var e=0;return function(t,r,i,n){var o=t.context,a=i.defines,s=i.__webglShader.uniforms,h=i.attributes,l=i.__webglShader.vertexShader,c=i.__webglShader.fragmentShader,u=i.index0AttributeName;void 0===u&&!0===n.morphTargets&&(u="position");var E="SHADOWMAP_TYPE_BASIC";n.shadowMapType===THREE.PCFShadowMap?E="SHADOWMAP_TYPE_PCF":n.shadowMapType===THREE.PCFSoftShadowMap&&(E="SHADOWMAP_TYPE_PCF_SOFT");var p="ENVMAP_TYPE_CUBE",d="ENVMAP_MODE_REFLECTION",f="ENVMAP_BLENDING_MULTIPLY";if(n.envMap){switch(i.envMap.mapping){case THREE.CubeReflectionMapping:case THREE.CubeRefractionMapping:p="ENVMAP_TYPE_CUBE";break;case THREE.EquirectangularReflectionMapping:case THREE.EquirectangularRefractionMapping:p="ENVMAP_TYPE_EQUIREC";break;case THREE.SphericalReflectionMapping:p="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case THREE.CubeRefractionMapping:case THREE.EquirectangularRefractionMapping:d="ENVMAP_MODE_REFRACTION"}switch(i.combine){case THREE.MultiplyOperation:f="ENVMAP_BLENDING_MULTIPLY";break;case THREE.MixOperation:f="ENVMAP_BLENDING_MIX";break;case THREE.AddOperation:f="ENVMAP_BLENDING_ADD"}}var m,T,g=0u;u++)E=s[u],y[E]=o.getUniformLocation(a,E);for(this.uniforms=y,u="position normal uv uv2 tangent color skinIndex skinWeight lineDistance".split(" "),s=0;sv;v++)y=n[v],h[y]=o.getAttribLocation(a,y);return this.attributes=h,this.attributesKeys=Object.keys(this.attributes),this.id=e++,this.code=r,this.usedTimes=1,this.program=a,this.vertexShader=l,this.fragmentShader=c,this}}(),THREE.WebGLShader=function(){var e=function(e){e=e.split("\n");for(var t=0;te;e++)r[e]=0},this.enableAttribute=function(t){r[t]=1,0===i[t]&&(e.enableVertexAttribArray(t),i[t]=1)},this.disableUnusedAttributes=function(){for(var t=0,n=i.length;n>t;t++)i[t]!==r[t]&&(e.disableVertexAttribArray(t),i[t]=0)},this.setBlending=function(r,i,u,E,p,d,f){r!==n&&(r===THREE.NoBlending?e.disable(e.BLEND):r===THREE.AdditiveBlending?(e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.SRC_ALPHA,e.ONE)):r===THREE.SubtractiveBlending?(e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR)):r===THREE.MultiplyBlending?(e.enable(e.BLEND),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.SRC_COLOR)):r===THREE.CustomBlending?e.enable(e.BLEND):(e.enable(e.BLEND),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)),n=r),r===THREE.CustomBlending?(p=p||i,d=d||u,f=f||E,(i!==o||p!==h)&&(e.blendEquationSeparate(t(i),t(p)),o=i,h=p),(u!==a||E!==s||d!==l||f!==c)&&(e.blendFuncSeparate(t(u),t(E),t(d),t(f)),a=u,s=E,l=d,c=f)):c=l=h=s=a=o=null},this.setDepthTest=function(t){u!==t&&(t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),u=t)},this.setDepthWrite=function(t){E!==t&&(e.depthMask(t),E=t)},this.setColorWrite=function(t){p!==t&&(e.colorMask(t,t,t,t),p=t)},this.setDoubleSided=function(t){d!==t&&(t?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),d=t)},this.setFlipSided=function(t){f!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),f=t)},this.setLineWidth=function(t){t!==m&&(e.lineWidth(t),m=t)},this.setPolygonOffset=function(t,r,i){T!==t&&(t?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),T=t),!t||g===r&&R===i||(e.polygonOffset(r,i),g=r,R=i)},this.reset=function(){for(var e=0;eA;A++)if(_=16/H,M.set(_*x,_),P=t[A],R.set(P.matrixWorld.elements[12],P.matrixWorld.elements[13],P.matrixWorld.elements[14]),R.applyMatrix4(y.matrixWorldInverse),R.applyProjection(y.projectionMatrix),S.copy(R),C.x=S.x*b+b,C.y=S.y*w+w,f||0F;F++){var U=P.lensFlares[F];.001a;a++){var h=o[a];t._modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,t.matrixWorld),f.push(h)}for(a=0,s=t.children.length;s>a;a++)n(e,t.children[a],i)}}var o,a,s,h,l=e.context,c=new THREE.Frustum,u=new THREE.Matrix4,E=new THREE.Vector3,p=new THREE.Vector3,d=new THREE.Vector3,f=[],m=THREE.ShaderLib.depthRGBA,T=THREE.UniformsUtils.clone(m.uniforms);o=new THREE.ShaderMaterial({uniforms:T,vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}),a=new THREE.ShaderMaterial({uniforms:T,vertexShader:m.vertexShader,fragmentShader:m.fragmentShader,morphTargets:!0}),s=new THREE.ShaderMaterial({uniforms:T,vertexShader:m.vertexShader,fragmentShader:m.fragmentShader,skinning:!0}),h=new THREE.ShaderMaterial({uniforms:T,vertexShader:m.vertexShader,fragmentShader:m.fragmentShader,morphTargets:!0,skinning:!0}),o._shadowPass=!0,a._shadowPass=!0,s._shadowPass=!0,h._shadowPass=!0,this.render=function(r,m){if(!1!==e.shadowMapEnabled){var T,g,R,y,v,H,x,b,w=[];for(y=0,l.clearColor(1,1,1,1),l.disable(l.BLEND),l.enable(l.CULL_FACE),l.frontFace(l.CCW),e.shadowMapCullFace===THREE.CullFaceFront?l.cullFace(l.FRONT):l.cullFace(l.BACK),e.state.setDepthTest(!0),T=0,g=t.length;g>T;T++)if(R=t[T],R.castShadow)if(R instanceof THREE.DirectionalLight&&R.shadowCascade)for(v=0;vS;S++)b[S]=new THREE.Vector3,H[S]=new THREE.Vector3;b=x.shadowCascadeNearZ[M],x=x.shadowCascadeFarZ[M],H[0].set(-1,-1,b),H[1].set(1,-1,b),H[2].set(-1,1,b),H[3].set(1,1,b),H[4].set(-1,-1,x),H[5].set(1,-1,x),H[6].set(-1,1,x),H[7].set(1,1,x),_.originalCamera=m,H=new THREE.Gyroscope,H.position.copy(R.shadowCascadeOffset),H.add(_),H.add(_.target),m.add(H),R.shadowCascadeArray[v]=_}M=R,b=v,x=M.shadowCascadeArray[b],x.position.copy(M.position),x.target.position.copy(M.target.position),x.lookAt(x.target),x.shadowCameraVisible=M.shadowCameraVisible,x.shadowDarkness=M.shadowDarkness,x.shadowBias=M.shadowCascadeBias[b],H=M.shadowCascadeNearZ[b],M=M.shadowCascadeFarZ[b],x=x.pointsFrustum,x[0].z=H,x[1].z=H,x[2].z=H,x[3].z=H,x[4].z=M,x[5].z=M,x[6].z=M,x[7].z=M,w[y]=_,y++}else w[y]=R,y++;for(T=0,g=w.length;g>T;T++){if(R=w[T],R.shadowMap||(v=THREE.LinearFilter,e.shadowMapType===THREE.PCFSoftShadowMap&&(v=THREE.NearestFilter),R.shadowMap=new THREE.WebGLRenderTarget(R.shadowMapWidth,R.shadowMapHeight,{minFilter:v,magFilter:v,format:THREE.RGBAFormat}),R.shadowMapSize=new THREE.Vector2(R.shadowMapWidth,R.shadowMapHeight),R.shadowMatrix=new THREE.Matrix4),!R.shadowCamera){if(R instanceof THREE.SpotLight)R.shadowCamera=new THREE.PerspectiveCamera(R.shadowCameraFov,R.shadowMapWidth/R.shadowMapHeight,R.shadowCameraNear,R.shadowCameraFar);else{if(!(R instanceof THREE.DirectionalLight)){THREE.error("THREE.ShadowMapPlugin: Unsupported light type for shadow",R);continue}R.shadowCamera=new THREE.OrthographicCamera(R.shadowCameraLeft,R.shadowCameraRight,R.shadowCameraTop,R.shadowCameraBottom,R.shadowCameraNear,R.shadowCameraFar)}r.add(R.shadowCamera),!0===r.autoUpdate&&r.updateMatrixWorld()}if(R.shadowCameraVisible&&!R.cameraHelper&&(R.cameraHelper=new THREE.CameraHelper(R.shadowCamera),r.add(R.cameraHelper)),R.isVirtual&&_.originalCamera==m){for(v=m,y=R.shadowCamera,H=R.pointsFrustum,x=R.pointsWorld,E.set(1/0,1/0,1/0),p.set(-(1/0),-(1/0),-(1/0)),M=0;8>M;M++)b=x[M],b.copy(H[M]),b.unproject(v),b.applyMatrix4(y.matrixWorldInverse),b.xp.x&&(p.x=b.x),b.yp.y&&(p.y=b.y),b.zp.z&&(p.z=b.z);y.left=E.x,y.right=p.x,y.top=p.y,y.bottom=E.y,y.updateProjectionMatrix()}for(y=R.shadowMap,H=R.shadowMatrix,v=R.shadowCamera,v.position.setFromMatrixPosition(R.matrixWorld),d.setFromMatrixPosition(R.target.matrixWorld),v.lookAt(d),v.updateMatrixWorld(),v.matrixWorldInverse.getInverse(v.matrixWorld),R.cameraHelper&&(R.cameraHelper.visible=R.shadowCameraVisible),R.shadowCameraVisible&&R.cameraHelper.update(),H.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),H.multiply(v.projectionMatrix),H.multiply(v.matrixWorldInverse),u.multiplyMatrices(v.projectionMatrix,v.matrixWorldInverse),c.setFromMatrix(u),e.setRenderTarget(y),e.clear(),f.length=0,n(r,r,v),R=0,y=f.length;y>R;R++)x=f[R],H=x.object,x=x.buffer,M=H.material instanceof THREE.MeshFaceMaterial?H.material.materials[0]:H.material,b=void 0!==H.geometry.morphTargets&&0R;R++)x=i[R],H=x.object,H.visible&&H.castShadow&&(H._modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,H.matrixWorld),e.renderImmediateObject(v,t,null,o,H))}T=e.getClearColor(),g=e.getClearAlpha(),l.clearColor(T.r,T.g,T.b,g),l.enable(l.BLEND),e.shadowMapCullFace===THREE.CullFaceFront&&l.cullFace(l.BACK),e.resetGLState()}}},THREE.SpritePlugin=function(e,t){function r(e,t){return e.z!==t.z?t.z-e.z:t.id-e.id}var i,n,o,a,s,h,l,c,u,E,p,d,f,m,T,g,R,y,v,H,x,b=e.context,w=new THREE.Vector3,_=new THREE.Quaternion,M=new THREE.Vector3;this.render=function(S,C){if(0!==t.length){if(void 0===H){var A=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),L=new Uint16Array([0,1,2,0,2,3]);y=b.createBuffer(),v=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,y),b.bufferData(b.ARRAY_BUFFER,A,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v),b.bufferData(b.ELEMENT_ARRAY_BUFFER,L,b.STATIC_DRAW);var A=b.createProgram(),L=b.createShader(b.VERTEX_SHADER),P=b.createShader(b.FRAGMENT_SHADER);b.shaderSource(L,["precision "+e.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n")),b.shaderSource(P,["precision "+e.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")),b.compileShader(L),b.compileShader(P),b.attachShader(A,L),b.attachShader(A,P),b.linkProgram(A),H=A,g=b.getAttribLocation(H,"position"),R=b.getAttribLocation(H,"uv"),i=b.getUniformLocation(H,"uvOffset"),n=b.getUniformLocation(H,"uvScale"),o=b.getUniformLocation(H,"rotation"),a=b.getUniformLocation(H,"scale"),s=b.getUniformLocation(H,"color"),h=b.getUniformLocation(H,"map"),l=b.getUniformLocation(H,"opacity"),c=b.getUniformLocation(H,"modelViewMatrix"),u=b.getUniformLocation(H,"projectionMatrix"),E=b.getUniformLocation(H,"fogType"),p=b.getUniformLocation(H,"fogDensity"),d=b.getUniformLocation(H,"fogNear"),f=b.getUniformLocation(H,"fogFar"),m=b.getUniformLocation(H,"fogColor"),T=b.getUniformLocation(H,"alphaTest"),A=document.createElement("canvas"),A.width=8,A.height=8,L=A.getContext("2d"),L.fillStyle="white",L.fillRect(0,0,8,8),x=new THREE.Texture(A),x.needsUpdate=!0}b.useProgram(H),b.enableVertexAttribArray(g),b.enableVertexAttribArray(R),b.disable(b.CULL_FACE),b.enable(b.BLEND),b.bindBuffer(b.ARRAY_BUFFER,y),b.vertexAttribPointer(g,2,b.FLOAT,!1,16,0),b.vertexAttribPointer(R,2,b.FLOAT,!1,16,8),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v),b.uniformMatrix4fv(u,!1,C.projectionMatrix.elements),b.activeTexture(b.TEXTURE0),b.uniform1i(h,0),L=A=0,(P=S.fog)?(b.uniform3f(m,P.color.r,P.color.g,P.color.b),P instanceof THREE.Fog?(b.uniform1f(d,P.near),b.uniform1f(f,P.far),b.uniform1i(E,1),L=A=1):P instanceof THREE.FogExp2&&(b.uniform1f(p,P.density),b.uniform1i(E,2),L=A=2)):(b.uniform1i(E,0),L=A=0);for(var P=0,F=t.length;F>P;P++){var B=t[P];B._modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,B.matrixWorld),B.z=-B._modelViewMatrix.elements[14]}t.sort(r);for(var U=[],P=0,F=t.length;F>P;P++){var B=t[P],D=B.material;b.uniform1f(T,D.alphaTest),b.uniformMatrix4fv(c,!1,B._modelViewMatrix.elements),B.matrixWorld.decompose(w,_,M),U[0]=M.x,U[1]=M.y,B=0,S.fog&&D.fog&&(B=L),A!==B&&(b.uniform1i(E,B),A=B),null!==D.map?(b.uniform2f(i,D.map.offset.x,D.map.offset.y),b.uniform2f(n,D.map.repeat.x,D.map.repeat.y)):(b.uniform2f(i,0,0),b.uniform2f(n,1,1)),b.uniform1f(l,D.opacity),b.uniform3f(s,D.color.r,D.color.g,D.color.b),b.uniform1f(o,D.rotation),b.uniform2fv(a,U),e.state.setBlending(D.blending,D.blendEquation,D.blendSrc,D.blendDst),e.state.setDepthTest(D.depthTest),e.state.setDepthWrite(D.depthWrite),D.map&&D.map.image&&D.map.image.width?e.setTexture(D.map,0):e.setTexture(x,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE),e.resetGLState()}}},THREE.GeometryUtils={merge:function(e,t,r){THREE.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var i;t instanceof THREE.Mesh&&(t.matrixAutoUpdate&&t.updateMatrix(),i=t.matrix,t=t.geometry),e.merge(t,i,r)},center:function(e){return THREE.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),e.center()}},THREE.ImageUtils={crossOrigin:void 0,loadTexture:function(e,t,r,i){var n=new THREE.ImageLoader;n.crossOrigin=this.crossOrigin;var o=new THREE.Texture(void 0,t);return n.load(e,function(e){o.image=e,o.needsUpdate=!0,r&&r(o)},void 0,function(e){i&&i(e)}),o.sourceFile=e,o},loadTextureCube:function(e,t,r,i){var n=new THREE.ImageLoader;n.crossOrigin=this.crossOrigin;var o=new THREE.CubeTexture([],t);o.flipY=!1;var a=0;t=function(t){n.load(e[t],function(e){o.images[t]=e,a+=1,6===a&&(o.needsUpdate=!0,r&&r(o))},void 0,i)};for(var s=0,h=e.length;h>s;++s)t(s);return o},loadCompressedTexture:function(){THREE.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){THREE.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},getNormalMap:function(e,t){var r=function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return[e[0]/t,e[1]/t,e[2]/t]};t|=1;var i=e.width,n=e.height,o=document.createElement("canvas");o.width=i,o.height=n;var a=o.getContext("2d");a.drawImage(e,0,0);for(var s=a.getImageData(0,0,i,n).data,h=a.createImageData(i,n),l=h.data,c=0;i>c;c++)for(var u=0;n>u;u++){var E=0>u-1?0:u-1,p=u+1>n-1?n-1:u+1,d=0>c-1?0:c-1,f=c+1>i-1?i-1:c+1,m=[],T=[0,0,s[4*(u*i+c)]/255*t];for(m.push([-1,0,s[4*(u*i+d)]/255*t]),m.push([-1,-1,s[4*(E*i+d)]/255*t]),m.push([0,-1,s[4*(E*i+c)]/255*t]),m.push([1,-1,s[4*(E*i+f)]/255*t]),m.push([1,0,s[4*(u*i+f)]/255*t]),m.push([1,1,s[4*(p*i+f)]/255*t]),m.push([0,1,s[4*(p*i+c)]/255*t]),m.push([-1,1,s[4*(p*i+d)]/255*t]),E=[],d=m.length,p=0;d>p;p++){var f=m[p],g=m[(p+1)%d],f=[f[0]-T[0],f[1]-T[1],f[2]-T[2]],g=[g[0]-T[0],g[1]-T[1],g[2]-T[2]];E.push(r([f[1]*g[2]-f[2]*g[1],f[2]*g[0]-f[0]*g[2],f[0]*g[1]-f[1]*g[0]]))}for(m=[0,0,0],p=0;ps;s++)n[3*s]=o,n[3*s+1]=a,n[3*s+2]=r;return e=new THREE.DataTexture(n,e,t,THREE.RGBFormat),e.needsUpdate=!0,e}},THREE.SceneUtils={createMultiMaterialObject:function(e,t){for(var r=new THREE.Object3D,i=0,n=t.length;n>i;i++)r.add(new THREE.Mesh(e,t[i]));return r},detach:function(e,t,r){e.applyMatrix(t.matrixWorld),t.remove(e),r.add(e)},attach:function(e,t,r){var i=new THREE.Matrix4;i.getInverse(r.matrixWorld),e.applyMatrix(i),t.remove(e),r.add(e)}},THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){try{return this.faces[this.face][this.weight][this.style]}catch(e){throw"The font "+this.face+" with "+this.weight+" weight and "+this.style+" style is missing."}},loadFace:function(e){var t=e.familyName.toLowerCase();return this.faces[t]=this.faces[t]||{},this.faces[t][e.cssFontWeight]=this.faces[t][e.cssFontWeight]||{},this.faces[t][e.cssFontWeight][e.cssFontStyle]=e,this.faces[t][e.cssFontWeight][e.cssFontStyle]=e},drawText:function(e){var t=this.getFace(),r=this.size/t.resolution,i=0,n=String(e).split(""),o=n.length,a=[];for(e=0;o>e;e++){var s=new THREE.Path,s=this.extractGlyphPoints(n[e],t,r,i,s),i=i+s.offset;a.push(s.path)}return{paths:a,offset:i/2}},extractGlyphPoints:function(e,t,r,i,n){var o,a,s,h,l,c,u,E,p,d,f,m=[],T=t.glyphs[e]||t.glyphs["?"];if(T){if(T.o)for(t=T._cachedOutline||(T._cachedOutline=T.o.split(" ")),h=t.length,e=0;h>e;)switch(s=t[e++]){case"m":s=t[e++]*r+i,l=t[e++]*r,n.moveTo(s,l);break;case"l":s=t[e++]*r+i,l=t[e++]*r,n.lineTo(s,l);break;case"q":if(s=t[e++]*r+i,l=t[e++]*r,E=t[e++]*r+i,p=t[e++]*r,n.quadraticCurveTo(E,p,s,l),o=m[m.length-1])for(c=o.x,u=o.y,o=1,a=this.divisions;a>=o;o++){var g=o/a;THREE.Shape.Utils.b2(g,c,E,s),THREE.Shape.Utils.b2(g,u,p,l)}break;case"b":if(s=t[e++]*r+i,l=t[e++]*r,E=t[e++]*r+i,p=t[e++]*r,d=t[e++]*r+i,f=t[e++]*r,n.bezierCurveTo(E,p,d,f,s,l),o=m[m.length-1])for(c=o.x,u=o.y,o=1,a=this.divisions;a>=o;o++)g=o/a,THREE.Shape.Utils.b3(g,c,E,d,s),THREE.Shape.Utils.b3(g,u,p,f,l)}return{offset:T.ha*r,path:n}}}},THREE.FontUtils.generateShapes=function(e,t){t=t||{};var r=void 0!==t.curveSegments?t.curveSegments:4,i=void 0!==t.font?t.font:"helvetiker",n=void 0!==t.weight?t.weight:"normal",o=void 0!==t.style?t.style:"normal";for(THREE.FontUtils.size=void 0!==t.size?t.size:100,THREE.FontUtils.divisions=r,THREE.FontUtils.face=i,THREE.FontUtils.weight=n,THREE.FontUtils.style=o,r=THREE.FontUtils.drawText(e).paths,i=[],n=0,o=r.length;o>n;n++)Array.prototype.push.apply(i,r[n].toShapes());return i},function(e){var t=function(e){for(var t=e.length,r=0,i=t-1,n=0;t>n;i=n++)r+=e[i].x*e[n].y-e[n].x*e[i].y;return.5*r};return e.Triangulate=function(e,r){var i=e.length;if(3>i)return null;var n,o,a,s=[],h=[],l=[];if(0o;o++)h[o]=o;else for(o=0;i>o;o++)h[o]=i-1-o;var c=2*i;for(o=i-1;i>2;){if(0>=c--){THREE.warn("THREE.FontUtils: Warning, unable to triangulate polygon! in Triangulate.process()");break}n=o,n>=i&&(n=0),o=n+1,o>=i&&(o=0),a=o+1,a>=i&&(a=0);var u;e:{var E=u=void 0,p=void 0,d=void 0,f=void 0,m=void 0,T=void 0,g=void 0,R=void 0,E=e[h[n]].x,p=e[h[n]].y,d=e[h[o]].x,f=e[h[o]].y,m=e[h[a]].x,T=e[h[a]].y;if(1e-10>(d-E)*(T-p)-(f-p)*(m-E))u=!1;else{var y=void 0,v=void 0,H=void 0,x=void 0,b=void 0,w=void 0,_=void 0,M=void 0,S=void 0,C=void 0,S=M=_=R=g=void 0,y=m-d,v=T-f,H=E-m,x=p-T,b=d-E,w=f-p;for(u=0;i>u;u++)if(g=e[h[u]].x,R=e[h[u]].y,!(g===E&&R===p||g===d&&R===f||g===m&&R===T)&&(_=g-E,M=R-p,S=g-d,C=R-f,g-=m,R-=T,S=y*C-v*S,_=b*M-w*_,M=H*R-x*g,S>=-1e-10&&M>=-1e-10&&_>=-1e-10)){u=!1;break e}u=!0}}if(u){for(s.push([e[h[n]],e[h[o]],e[h[a]]]),l.push([h[n],h[o],h[a]]),n=o,a=o+1;i>a;n++,a++)h[n]=h[a];i--,c=2*i}}return r?l:s},e.Triangulate.area=t,e}(THREE.FontUtils),self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace},THREE.typeface_js=self._typeface_js,THREE.Audio=function(e){THREE.Object3D.call(this),this.type="Audio",this.context=e.context,this.source=this.context.createBufferSource(),this.source.onended=this.onEnded.bind(this),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.panner=this.context.createPanner(),this.panner.connect(this.gain),this.autoplay=!1,this.startTime=0,this.isPlaying=!1},THREE.Audio.prototype=Object.create(THREE.Object3D.prototype),THREE.Audio.prototype.constructor=THREE.Audio,THREE.Audio.prototype.load=function(e){var t=this,r=new XMLHttpRequest;return r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(e){t.context.decodeAudioData(this.response,function(e){t.source.buffer=e,t.autoplay&&t.play()})},r.send(),this},THREE.Audio.prototype.play=function(){if(!0===this.isPlaying)THREE.warn("THREE.Audio: Audio is already playing.");else{var e=this.context.createBufferSource();e.buffer=this.source.buffer,e.loop=this.source.loop,e.onended=this.source.onended,e.connect(this.panner),e.start(0,this.startTime),this.isPlaying=!0,this.source=e}},THREE.Audio.prototype.pause=function(){this.source.stop(),this.startTime=this.context.currentTime},THREE.Audio.prototype.stop=function(){this.source.stop(),this.startTime=0},THREE.Audio.prototype.onEnded=function(){this.isPlaying=!1},THREE.Audio.prototype.setLoop=function(e){this.source.loop=e},THREE.Audio.prototype.setRefDistance=function(e){this.panner.refDistance=e},THREE.Audio.prototype.setRolloffFactor=function(e){this.panner.rolloffFactor=e},THREE.Audio.prototype.setVolume=function(e){this.gain.gain.value=e},THREE.Audio.prototype.updateMatrixWorld=function(){var e=new THREE.Vector3;return function(t){THREE.Object3D.prototype.updateMatrixWorld.call(this,t),e.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(e.x,e.y,e.z)}}(),THREE.AudioListener=function(){THREE.Object3D.call(this),this.type="AudioListener",this.context=new(window.AudioContext||window.webkitAudioContext)},THREE.AudioListener.prototype=Object.create(THREE.Object3D.prototype),THREE.AudioListener.prototype.constructor=THREE.AudioListener,THREE.AudioListener.prototype.updateMatrixWorld=function(){var e=new THREE.Vector3,t=new THREE.Quaternion,r=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Vector3,o=new THREE.Vector3;return function(a){THREE.Object3D.prototype.updateMatrixWorld.call(this,a),a=this.context.listener;var s=this.up;this.matrixWorld.decompose(e,t,r),i.set(0,0,-1).applyQuaternion(t),n.subVectors(e,o),a.setPosition(e.x,e.y,e.z),a.setOrientation(i.x,i.y,i.z,s.x,s.y,s.z),a.setVelocity(n.x,n.y,n.z),o.copy(e)}}(),THREE.Curve=function(){},THREE.Curve.prototype.getPoint=function(e){return THREE.warn("THREE.Curve: Warning, getPoint() not implemented!"),null},THREE.Curve.prototype.getPointAt=function(e){return e=this.getUtoTmapping(e),this.getPoint(e)},THREE.Curve.prototype.getPoints=function(e){e||(e=5);var t,r=[];for(t=0;e>=t;t++)r.push(this.getPoint(t/e));return r},THREE.Curve.prototype.getSpacedPoints=function(e){e||(e=5);var t,r=[];for(t=0;e>=t;t++)r.push(this.getPointAt(t/e));return r},THREE.Curve.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},THREE.Curve.prototype.getLengths=function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length==e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,r,i=[],n=this.getPoint(0),o=0;for(i.push(0),r=1;e>=r;r++)t=this.getPoint(r/e),o+=t.distanceTo(n),i.push(o),n=t;return this.cacheArcLengths=i},THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0,this.getLengths()},THREE.Curve.prototype.getUtoTmapping=function(e,t){var r,i=this.getLengths(),n=0,o=i.length;r=t?t:e*i[o-1];for(var a,s=0,h=o-1;h>=s;)if(n=Math.floor(s+(h-s)/2),a=i[n]-r,0>a)s=n+1;else{if(!(a>0)){h=n;break}h=n-1}return n=h,i[n]==r?n/(o-1):(s=i[n],i=(n+(r-s)/(i[n+1]-s))/(o-1))},THREE.Curve.prototype.getTangent=function(e){var t=e-1e-4;return e+=1e-4,0>t&&(t=0),e>1&&(e=1),t=this.getPoint(t),this.getPoint(e).clone().sub(t).normalize()},THREE.Curve.prototype.getTangentAt=function(e){return e=this.getUtoTmapping(e),this.getTangent(e)},THREE.Curve.Utils={tangentQuadraticBezier:function(e,t,r,i){return 2*(1-e)*(r-t)+2*e*(i-r)},tangentCubicBezier:function(e,t,r,i,n){return-3*t*(1-e)*(1-e)+3*r*(1-e)*(1-e)-6*e*r*(1-e)+6*e*i*(1-e)-3*e*e*i+3*e*e*n},tangentSpline:function(e,t,r,i,n){return 6*e*e-6*e+(3*e*e-4*e+1)+(-6*e*e+6*e)+(3*e*e-2*e)},interpolate:function(e,t,r,i,n){e=.5*(r-e),i=.5*(i-t);var o=n*n;return(2*t-2*r+e+i)*n*o+(-3*t+3*r-2*e-i)*o+e*n+t}},THREE.Curve.create=function(e,t){return e.prototype=Object.create(THREE.Curve.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},THREE.CurvePath=function(){this.curves=[],this.bends=[],this.autoClose=!1},THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype),THREE.CurvePath.prototype.constructor=THREE.CurvePath,THREE.CurvePath.prototype.add=function(e){this.curves.push(e)},THREE.CurvePath.prototype.checkConnection=function(){},THREE.CurvePath.prototype.closePath=function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new THREE.LineCurve(t,e))},THREE.CurvePath.prototype.getPoint=function(e){var t=e*this.getLength(),r=this.getCurveLengths();for(e=0;e=t)return t=r[e]-t,e=this.curves[e],t=1-t/e.getLength(),e.getPointAt(t);e++}return null},THREE.CurvePath.prototype.getLength=function(){var e=this.getCurveLengths();return e[e.length-1]},THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var e,t=[],r=0,i=this.curves.length;for(e=0;i>e;e++)r+=this.curves[e].getLength(),t.push(r);return this.cacheLengths=t},THREE.CurvePath.prototype.getBoundingBox=function(){var e,t,r,i,n,o,a=this.getPoints();e=t=Number.NEGATIVE_INFINITY,i=n=Number.POSITIVE_INFINITY;var s,h,l,c,u=a[0]instanceof THREE.Vector3;for(c=u?new THREE.Vector3:new THREE.Vector2,h=0,l=a.length;l>h;h++)s=a[h],s.x>e?e=s.x:s.xt?t=s.y:s.yr?r=s.z:s.zr;r++)n=this.getWrapPoints(n,t[r]);return n},THREE.CurvePath.prototype.getTransformedSpacedPoints=function(e,t){var r,i,n=this.getSpacedPoints(e);for(t||(t=this.bends),r=0,i=t.length;i>r;r++)n=this.getWrapPoints(n,t[r]);return n},THREE.CurvePath.prototype.getWrapPoints=function(e,t){var r,i,n,o,a,s,h=this.getBoundingBox();for(r=0,i=e.length;i>r;r++)n=e[r],o=n.x,a=n.y,s=o/h.maxX,s=t.getUtoTmapping(s,o),o=t.getPoint(s),s=t.getTangent(s),s.set(-s.y,s.x).multiplyScalar(a),n.x=o.x+s.x,n.y=o.y+s.y;return e},THREE.Gyroscope=function(){THREE.Object3D.call(this)},THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype),THREE.Gyroscope.prototype.constructor=THREE.Gyroscope,THREE.Gyroscope.prototype.updateMatrixWorld=function(){var e=new THREE.Vector3,t=new THREE.Quaternion,r=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Quaternion,o=new THREE.Vector3;return function(a){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||a)&&(this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(i,n,o),this.matrix.decompose(e,t,r),this.matrixWorld.compose(i,t,o)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0);for(var s=0,h=this.children.length;h>s;s++)this.children[s].updateMatrixWorld(a)}}(),THREE.Path=function(e){THREE.CurvePath.call(this),this.actions=[],e&&this.fromPoints(e)},THREE.Path.prototype=Object.create(THREE.CurvePath.prototype),THREE.Path.prototype.constructor=THREE.Path,THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"},THREE.Path.prototype.fromPoints=function(e){this.moveTo(e[0].x,e[0].y);for(var t=1,r=e.length;r>t;t++)this.lineTo(e[t].x,e[t].y)},THREE.Path.prototype.moveTo=function(e,t){var r=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:r})},THREE.Path.prototype.lineTo=function(e,t){var r=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args,i=new THREE.LineCurve(new THREE.Vector2(i[i.length-2],i[i.length-1]),new THREE.Vector2(e,t));this.curves.push(i),this.actions.push({action:THREE.PathActions.LINE_TO,args:r})},THREE.Path.prototype.quadraticCurveTo=function(e,t,r,i){var n=Array.prototype.slice.call(arguments),o=this.actions[this.actions.length-1].args,o=new THREE.QuadraticBezierCurve(new THREE.Vector2(o[o.length-2],o[o.length-1]),new THREE.Vector2(e,t),new THREE.Vector2(r,i));this.curves.push(o),this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:n})},THREE.Path.prototype.bezierCurveTo=function(e,t,r,i,n,o){var a=Array.prototype.slice.call(arguments),s=this.actions[this.actions.length-1].args,s=new THREE.CubicBezierCurve(new THREE.Vector2(s[s.length-2],s[s.length-1]),new THREE.Vector2(e,t),new THREE.Vector2(r,i),new THREE.Vector2(n,o));this.curves.push(s),this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:a})},THREE.Path.prototype.splineThru=function(e){var t=Array.prototype.slice.call(arguments),r=this.actions[this.actions.length-1].args,r=[new THREE.Vector2(r[r.length-2],r[r.length-1])];Array.prototype.push.apply(r,e),r=new THREE.SplineCurve(r),this.curves.push(r),this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:t})},THREE.Path.prototype.arc=function(e,t,r,i,n,o){var a=this.actions[this.actions.length-1].args;this.absarc(e+a[a.length-2],t+a[a.length-1],r,i,n,o)},THREE.Path.prototype.absarc=function(e,t,r,i,n,o){this.absellipse(e,t,r,r,i,n,o)},THREE.Path.prototype.ellipse=function(e,t,r,i,n,o,a){var s=this.actions[this.actions.length-1].args;this.absellipse(e+s[s.length-2],t+s[s.length-1],r,i,n,o,a)},THREE.Path.prototype.absellipse=function(e,t,r,i,n,o,a){var s=Array.prototype.slice.call(arguments),h=new THREE.EllipseCurve(e,t,r,i,n,o,a);this.curves.push(h),h=h.getPoint(1),s.push(h.x),s.push(h.y),this.actions.push({action:THREE.PathActions.ELLIPSE,args:s})},THREE.Path.prototype.getSpacedPoints=function(e,t){e||(e=40);for(var r=[],i=0;e>i;i++)r.push(this.getPoint(i/e));return r},THREE.Path.prototype.getPoints=function(e,t){if(this.useSpacedPoints)return console.log("tata"),this.getSpacedPoints(e,t);e=e||12;var r,i,n,o,a,s,h,l,c,u,E,p,d,f=[];for(r=0,i=this.actions.length;i>r;r++)switch(n=this.actions[r],o=n.action,n=n.args,o){case THREE.PathActions.MOVE_TO:f.push(new THREE.Vector2(n[0],n[1]));break;case THREE.PathActions.LINE_TO:f.push(new THREE.Vector2(n[0],n[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:for(a=n[2],s=n[3],c=n[0],u=n[1],0=n;n++)d=n/e,o=THREE.Shape.Utils.b2(d,E,c,a),d=THREE.Shape.Utils.b2(d,p,u,s),f.push(new THREE.Vector2(o,d));break;case THREE.PathActions.BEZIER_CURVE_TO:for(a=n[4],s=n[5],c=n[0],u=n[1],h=n[2],l=n[3],0=n;n++)d=n/e,o=THREE.Shape.Utils.b3(d,E,c,h,a),d=THREE.Shape.Utils.b3(d,p,u,l,s),f.push(new THREE.Vector2(o,d));break;case THREE.PathActions.CSPLINE_THRU:for(o=this.actions[r-1].args,d=[new THREE.Vector2(o[o.length-2],o[o.length-1])],o=e*n[0].length,d=d.concat(n[0]),d=new THREE.SplineCurve(d),n=1;o>=n;n++)f.push(d.getPointAt(n/o));break;case THREE.PathActions.ARC:for(a=n[0],s=n[1],u=n[2],h=n[3],o=n[4],c=!!n[5],E=o-h,p=2*e,n=1;p>=n;n++)d=n/p,c||(d=1-d),d=h+d*E,o=a+u*Math.cos(d),d=s+u*Math.sin(d),f.push(new THREE.Vector2(o,d));break;case THREE.PathActions.ELLIPSE:for(a=n[0],s=n[1],u=n[2],l=n[3],h=n[4],o=n[5],c=!!n[6],E=o-h,p=2*e,n=1;p>=n;n++)d=n/p,c||(d=1-d),d=h+d*E,o=a+u*Math.cos(d),d=s+l*Math.sin(d),f.push(new THREE.Vector2(o,d))}return r=f[f.length-1],1e-10>Math.abs(r.x-f[0].x)&&1e-10>Math.abs(r.y-f[0].y)&&f.splice(f.length-1,1),t&&f.push(f[0]),f},THREE.Path.prototype.toShapes=function(e,t){function r(e){for(var t=[],r=0,i=e.length;i>r;r++){var n=e[r],o=new THREE.Shape;o.actions=n.actions,o.curves=n.curves,t.push(o)}return t}function i(e,t){for(var r=t.length,i=!1,n=r-1,o=0;r>o;n=o++){var a=t[n],s=t[o],h=s.x-a.x,l=s.y-a.y;if(1e-10l&&(a=t[o],h=-h,s=t[n],l=-l),!(e.ys.y))if(e.y==a.y){if(e.x==a.x)return!0}else{if(n=l*(e.x-a.x)-h*(e.y-a.y),0==n)return!0;0>n||(i=!i)}}else if(e.y==a.y&&(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x))return!0}return i}var n=function(e){var t,r,i,n,o=[],a=new THREE.Path;for(t=0,r=e.length;r>t;t++)i=e[t],n=i.args,i=i.action,i==THREE.PathActions.MOVE_TO&&0!=a.actions.length&&(o.push(a),a=new THREE.Path),a[i].apply(a,n);return 0!=a.actions.length&&o.push(a),o}(this.actions);if(0==n.length)return[];if(!0===t)return r(n);var o,a,s,h=[];if(1==n.length)return a=n[0],s=new THREE.Shape,s.actions=a.actions,s.curves=a.curves,h.push(s),h;var l=!THREE.Shape.Utils.isClockWise(n[0].getPoints()),l=e?!l:l;s=[];var c,u=[],E=[],p=0;u[p]=void 0,E[p]=[];var d,f;for(d=0,f=n.length;f>d;d++)a=n[d],c=a.getPoints(),o=THREE.Shape.Utils.isClockWise(c),(o=e?!o:o)?(!l&&u[p]&&p++,u[p]={s:new THREE.Shape,p:c},u[p].s.actions=a.actions,u[p].s.curves=a.curves,l&&p++,E[p]=[]):E[p].push({h:a,p:c[0]});if(!u[0])return r(n);if(1a;a++)s[a]=[];for(a=0,n=u.length;n>a;a++)for(o=E[a],l=0;ld;d++)for(s=u[d].s,h.push(s),a=E[d],n=0,o=a.length;o>n;n++)s.holes.push(a[n].h);return h},THREE.Shape=function(){THREE.Path.apply(this,arguments),this.holes=[]},THREE.Shape.prototype=Object.create(THREE.Path.prototype),THREE.Shape.prototype.constructor=THREE.Shape,THREE.Shape.prototype.extrude=function(e){return new THREE.ExtrudeGeometry(this,e)},THREE.Shape.prototype.makeGeometry=function(e){return new THREE.ShapeGeometry(this,e)},THREE.Shape.prototype.getPointsHoles=function(e){var t,r=this.holes.length,i=[];for(t=0;r>t;t++)i[t]=this.holes[t].getTransformedPoints(e,this.bends);return i},THREE.Shape.prototype.getSpacedPointsHoles=function(e){var t,r=this.holes.length,i=[];for(t=0;r>t;t++)i[t]=this.holes[t].getTransformedSpacedPoints(e,this.bends);return i},THREE.Shape.prototype.extractAllPoints=function(e){return{shape:this.getTransformedPoints(e),holes:this.getPointsHoles(e)}},THREE.Shape.prototype.extractPoints=function(e){return this.useSpacedPoints?this.extractAllSpacedPoints(e):this.extractAllPoints(e)},THREE.Shape.prototype.extractAllSpacedPoints=function(e){return{shape:this.getTransformedSpacedPoints(e),holes:this.getSpacedPointsHoles(e)}},THREE.Shape.Utils={triangulateShape:function(e,t){function r(e,t,r){return e.x!=t.x?e.x0){if(0>p||p>E)return[];if(h=l*c-h*u,0>h||h>E)return[]}else{if(p>0||E>p)return[];if(h=l*c-h*u,h>0||E>h)return[]}return 0==h?!o||0!=p&&p!=E?[e]:[]:h==E?!o||0!=p&&p!=E?[t]:[]:0==p?[i]:p==E?[n]:(o=h/E,[{x:e.x+o*a,y:e.y+o*s}])}return 0!=p||l*c!=h*u?[]:(s=0==a&&0==s,h=0==h&&0==l,s&&h?e.x!=i.x||e.y!=i.y?[]:[e]:s?r(i,n,e)?[e]:[]:h?r(e,t,i)?[i]:[]:(0!=a?(e.x=h?E>e?[]:e==E?o?[]:[t]:i>=e?[t,s]:[t,l]:h>i?[]:h==i?o?[]:[a]:i>=e?[a,s]:[a,l]))}function n(e,t,r,i){var n=t.x-e.x,o=t.y-e.y;t=r.x-e.x,r=r.y-e.y;var a=i.x-e.x;return i=i.y-e.y,e=n*r-o*t,n=n*i-o*a,1e-100?n>=0&&t>=0:n>=0||t>=0):n>0}var o,a,s,h,l,c={};for(s=e.concat(),o=0,a=t.length;a>o;o++)Array.prototype.push.apply(s,t[o]);for(o=0,a=s.length;a>o;o++)l=s[o].x+":"+s[o].y,void 0!==c[l]&&THREE.warn("THREE.Shape: Duplicate point",l),c[l]=o;o=function(e,t){function r(e,t){var r=m.length-1,i=e-1;0>i&&(i=r);var o=e+1;return o>r&&(o=0),(r=n(m[e],m[i],m[o],s[t]))?(r=s.length-1,i=t-1,0>i&&(i=r),o=t+1,o>r&&(o=0),(r=n(s[t],s[i],s[o],m[e]))?!0:!1):!1; +}function o(e,t){var r,n;for(r=0;rR;R++)T.push(R);p=0;for(var y=2*T.length;0y){console.log("Infinite Loop! Holes left:"+T.length+", Probably Hole outside Shape!");break}for(l=p;l=0)break;g[E]=!0}if(h>=0)break}}return m}(e,t);var u=THREE.FontUtils.Triangulate(o,!1);for(o=0,a=u.length;a>o;o++)for(h=u[o],s=0;3>s;s++)l=h[s].x+":"+h[s].y,l=c[l],void 0!==l&&(h[s]=l);return u.concat()},isClockWise:function(e){return 0>THREE.FontUtils.Triangulate.area(e)},b2p0:function(e,t){var r=1-e;return r*r*t},b2p1:function(e,t){return 2*(1-e)*e*t},b2p2:function(e,t){return e*e*t},b2:function(e,t,r,i){return this.b2p0(e,t)+this.b2p1(e,r)+this.b2p2(e,i)},b3p0:function(e,t){var r=1-e;return r*r*r*t},b3p1:function(e,t){var r=1-e;return 3*r*r*e*t},b3p2:function(e,t){return 3*(1-e)*e*e*t},b3p3:function(e,t){return e*e*e*t},b3:function(e,t,r,i,n){return this.b3p0(e,t)+this.b3p1(e,r)+this.b3p2(e,i)+this.b3p3(e,n)}},THREE.LineCurve=function(e,t){this.v1=e,this.v2=t},THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype),THREE.LineCurve.prototype.constructor=THREE.LineCurve,THREE.LineCurve.prototype.getPoint=function(e){var t=this.v2.clone().sub(this.v1);return t.multiplyScalar(e).add(this.v1),t},THREE.LineCurve.prototype.getPointAt=function(e){return this.getPoint(e)},THREE.LineCurve.prototype.getTangent=function(e){return this.v2.clone().sub(this.v1).normalize()},THREE.QuadraticBezierCurve=function(e,t,r){this.v0=e,this.v1=t,this.v2=r},THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype),THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve,THREE.QuadraticBezierCurve.prototype.getPoint=function(e){var t=new THREE.Vector2;return t.x=THREE.Shape.Utils.b2(e,this.v0.x,this.v1.x,this.v2.x),t.y=THREE.Shape.Utils.b2(e,this.v0.y,this.v1.y,this.v2.y),t},THREE.QuadraticBezierCurve.prototype.getTangent=function(e){var t=new THREE.Vector2;return t.x=THREE.Curve.Utils.tangentQuadraticBezier(e,this.v0.x,this.v1.x,this.v2.x),t.y=THREE.Curve.Utils.tangentQuadraticBezier(e,this.v0.y,this.v1.y,this.v2.y),t.normalize()},THREE.CubicBezierCurve=function(e,t,r,i){this.v0=e,this.v1=t,this.v2=r,this.v3=i},THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype),THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve,THREE.CubicBezierCurve.prototype.getPoint=function(e){var t;return t=THREE.Shape.Utils.b3(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e=THREE.Shape.Utils.b3(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),new THREE.Vector2(t,e)},THREE.CubicBezierCurve.prototype.getTangent=function(e){var t;return t=THREE.Curve.Utils.tangentCubicBezier(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e=THREE.Curve.Utils.tangentCubicBezier(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),t=new THREE.Vector2(t,e),t.normalize(),t},THREE.SplineCurve=function(e){this.points=void 0==e?[]:e},THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype),THREE.SplineCurve.prototype.constructor=THREE.SplineCurve,THREE.SplineCurve.prototype.getPoint=function(e){var t=this.points;e*=t.length-1;var r=Math.floor(e);e-=r;var i=t[0==r?r:r-1],n=t[r],o=t[r>t.length-2?t.length-1:r+1],t=t[r>t.length-3?t.length-1:r+2],r=new THREE.Vector2;return r.x=THREE.Curve.Utils.interpolate(i.x,n.x,o.x,t.x,e),r.y=THREE.Curve.Utils.interpolate(i.y,n.y,o.y,t.y,e),r},THREE.EllipseCurve=function(e,t,r,i,n,o,a){this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a},THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype),THREE.EllipseCurve.prototype.constructor=THREE.EllipseCurve,THREE.EllipseCurve.prototype.getPoint=function(e){var t=this.aEndAngle-this.aStartAngle;return 0>t&&(t+=2*Math.PI),t>2*Math.PI&&(t-=2*Math.PI),e=!0===this.aClockwise?this.aEndAngle+(1-e)*(2*Math.PI-t):this.aStartAngle+e*t,t=new THREE.Vector2,t.x=this.aX+this.xRadius*Math.cos(e),t.y=this.aY+this.yRadius*Math.sin(e),t},THREE.ArcCurve=function(e,t,r,i,n,o){THREE.EllipseCurve.call(this,e,t,r,r,i,n,o)},THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype),THREE.ArcCurve.prototype.constructor=THREE.ArcCurve,THREE.LineCurve3=THREE.Curve.create(function(e,t){this.v1=e,this.v2=t},function(e){var t=new THREE.Vector3;return t.subVectors(this.v2,this.v1),t.multiplyScalar(e),t.add(this.v1),t}),THREE.QuadraticBezierCurve3=THREE.Curve.create(function(e,t,r){this.v0=e,this.v1=t,this.v2=r},function(e){var t=new THREE.Vector3;return t.x=THREE.Shape.Utils.b2(e,this.v0.x,this.v1.x,this.v2.x),t.y=THREE.Shape.Utils.b2(e,this.v0.y,this.v1.y,this.v2.y),t.z=THREE.Shape.Utils.b2(e,this.v0.z,this.v1.z,this.v2.z),t}),THREE.CubicBezierCurve3=THREE.Curve.create(function(e,t,r,i){this.v0=e,this.v1=t,this.v2=r,this.v3=i},function(e){var t=new THREE.Vector3;return t.x=THREE.Shape.Utils.b3(e,this.v0.x,this.v1.x,this.v2.x,this.v3.x),t.y=THREE.Shape.Utils.b3(e,this.v0.y,this.v1.y,this.v2.y,this.v3.y),t.z=THREE.Shape.Utils.b3(e,this.v0.z,this.v1.z,this.v2.z,this.v3.z),t}),THREE.SplineCurve3=THREE.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t=this.points;e*=t.length-1;var r=Math.floor(e);e-=r;var i=t[0==r?r:r-1],n=t[r],o=t[r>t.length-2?t.length-1:r+1],t=t[r>t.length-3?t.length-1:r+2],r=new THREE.Vector3;return r.x=THREE.Curve.Utils.interpolate(i.x,n.x,o.x,t.x,e),r.y=THREE.Curve.Utils.interpolate(i.y,n.y,o.y,t.y,e),r.z=THREE.Curve.Utils.interpolate(i.z,n.z,o.z,t.z,e),r}),THREE.ClosedSplineCurve3=THREE.Curve.create(function(e){this.points=void 0==e?[]:e},function(e){var t=this.points;e*=t.length-0;var r=Math.floor(e);e-=r;var r=r+(r>0?0:(Math.floor(Math.abs(r)/t.length)+1)*t.length),i=t[(r-1)%t.length],n=t[r%t.length],o=t[(r+1)%t.length],t=t[(r+2)%t.length],r=new THREE.Vector3;return r.x=THREE.Curve.Utils.interpolate(i.x,n.x,o.x,t.x,e),r.y=THREE.Curve.Utils.interpolate(i.y,n.y,o.y,t.y,e),r.z=THREE.Curve.Utils.interpolate(i.z,n.z,o.z,t.z,e),r}),THREE.AnimationHandler={LINEAR:0,CATMULLROM:1,CATMULLROM_FORWARD:2,add:function(){THREE.warn("THREE.AnimationHandler.add() has been deprecated.")},get:function(){THREE.warn("THREE.AnimationHandler.get() has been deprecated.")},remove:function(){THREE.warn("THREE.AnimationHandler.remove() has been deprecated.")},animations:[],init:function(e){if(!0===e.initialized)return e;for(var t=0;te.hierarchy[t].keys[r].time&&(e.hierarchy[t].keys[r].time=0),void 0!==e.hierarchy[t].keys[r].rot&&!(e.hierarchy[t].keys[r].rot instanceof THREE.Quaternion)){var i=e.hierarchy[t].keys[r].rot;e.hierarchy[t].keys[r].rot=(new THREE.Quaternion).fromArray(i)}if(e.hierarchy[t].keys.length&&void 0!==e.hierarchy[t].keys[0].morphTargets){for(i={},r=0;re;e++){var r=this.hierarchy[e];void 0===r.animationCache&&(r.animationCache={animations:{},blending:{positionWeight:0,quaternionWeight:0,scaleWeight:0}});var i=this.data.name,n=r.animationCache.animations,o=n[i];for(void 0===o&&(o={prevKey:{pos:0,rot:0,scl:0},nextKey:{pos:0,rot:0,scl:0},originalMatrix:r.matrix},n[i]=o),r=0;3>r;r++){for(var i=this.keyTypes[r],n=this.data.hierarchy[e].keys[0],a=this.getNextKeyWith(i,e,1);a.timen.index;)n=a,a=this.getNextKeyWith(i,e,a.index+1);o.prevKey[i]=n,o.nextKey[i]=a}}},resetBlendWeights:function(){for(var e=0,t=this.hierarchy.length;t>e;e++){var r=this.hierarchy[e].animationCache;void 0!==r&&(r=r.blending,r.positionWeight=0,r.quaternionWeight=0,r.scaleWeight=0)}},update:function(){var e=[],t=new THREE.Vector3,r=new THREE.Vector3,i=new THREE.Quaternion,n=function(e,t){var r,i,n,a,s,h,l=[],c=[];return r=(e.length-1)*t,i=Math.floor(r),r-=i,l[0]=0===i?i:i-1,l[1]=i,l[2]=i>e.length-2?i:i+1,l[3]=i>e.length-3?i:i+2,i=e[l[0]],a=e[l[1]],s=e[l[2]],h=e[l[3]],l=r*r,n=r*l,c[0]=o(i[0],a[0],s[0],h[0],r,l,n),c[1]=o(i[1],a[1],s[1],h[1],r,l,n),c[2]=o(i[2],a[2],s[2],h[2],r,l,n),c},o=function(e,t,r,i,n,o,a){return e=.5*(r-e),i=.5*(i-t),(2*(t-r)+e+i)*a+(-3*(t-r)-2*e-i)*o+e*n+t};return function(o){if(!1!==this.isPlaying&&(this.currentTime+=o*this.timeScale,0!==this.weight)){o=this.data.length,(this.currentTime>o||0>this.currentTime)&&(this.loop?(this.currentTime%=o,0>this.currentTime&&(this.currentTime+=o),this.reset()):this.stop()),o=0;for(var a=this.hierarchy.length;a>o;o++)for(var s=this.hierarchy[o],h=s.animationCache.animations[this.data.name],l=s.animationCache.blending,c=0;3>c;c++){var u=this.keyTypes[c],E=h.prevKey[u],p=h.nextKey[u];if(0this.timeScale&&E.time>=this.currentTime){for(E=this.data.hierarchy[o].keys[0],p=this.getNextKeyWith(u,o,1);p.timeE.index;)E=p,p=this.getNextKeyWith(u,o,p.index+1);h.prevKey[u]=E,h.nextKey[u]=p}var d=(this.currentTime-E.time)/(p.time-E.time),f=E[u],m=p[u];0>d&&(d=0),d>1&&(d=1),"pos"===u?this.interpolationType===THREE.AnimationHandler.LINEAR?(r.x=f[0]+(m[0]-f[0])*d,r.y=f[1]+(m[1]-f[1])*d,r.z=f[2]+(m[2]-f[2])*d,E=this.weight/(this.weight+l.positionWeight),s.position.lerp(r,E),l.positionWeight+=this.weight):(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)&&(e[0]=this.getPrevKeyWith("pos",o,E.index-1).pos,e[1]=f,e[2]=m,e[3]=this.getNextKeyWith("pos",o,p.index+1).pos,d=.33*d+.33,p=n(e,d),E=this.weight/(this.weight+l.positionWeight),l.positionWeight+=this.weight,u=s.position,u.x+=(p[0]-u.x)*E,u.y+=(p[1]-u.y)*E,u.z+=(p[2]-u.z)*E,this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD&&(d=n(e,1.01*d),t.set(d[0],d[1],d[2]),t.sub(u),t.y=0,t.normalize(),d=Math.atan2(t.x,t.z),s.rotation.set(0,d,0))):"rot"===u?(THREE.Quaternion.slerp(f,m,i,d),0===l.quaternionWeight?(s.quaternion.copy(i),l.quaternionWeight=this.weight):(E=this.weight/(this.weight+l.quaternionWeight),THREE.Quaternion.slerp(s.quaternion,i,s.quaternion,E),l.quaternionWeight+=this.weight)):"scl"===u&&(r.x=f[0]+(m[0]-f[0])*d,r.y=f[1]+(m[1]-f[1])*d,r.z=f[2]+(m[2]-f[2])*d,E=this.weight/(this.weight+l.scaleWeight),s.scale.lerp(r,E),l.scaleWeight+=this.weight)}return!0}}}(),getNextKeyWith:function(e,t,r){var i=this.data.hierarchy[t].keys;for(r=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?r0?r:0:r>=0?r:r+i.length;r>=0;r--)if(void 0!==i[r][e])return i[r];return this.data.hierarchy[t].keys[i.length-1]}},THREE.KeyFrameAnimation=function(e){this.root=e.node,this.data=THREE.AnimationHandler.init(e),this.hierarchy=THREE.AnimationHandler.parse(this.root),this.currentTime=0,this.timeScale=.001,this.isPlaying=!1,this.loop=this.isPaused=!0,e=0;for(var t=this.hierarchy.length;t>e;e++){var r=this.data.hierarchy[e].sids,i=this.hierarchy[e];if(this.data.hierarchy[e].keys.length&&r){for(var n=0;ne;e++)t=this.hierarchy[e],r=this.data.hierarchy[e],void 0===r.animationCache&&(r.animationCache={},r.animationCache.prevKey=null,r.animationCache.nextKey=null,r.animationCache.originalMatrix=t.matrix),t=this.data.hierarchy[e].keys,t.length&&(r.animationCache.prevKey=t[0],r.animationCache.nextKey=t[1],this.startTime=Math.min(t[0].time,this.startTime),this.endTime=Math.max(t[t.length-1].time,this.endTime));this.update(0)}this.isPaused=!1,THREE.AnimationHandler.play(this)},stop:function(){this.isPaused=this.isPlaying=!1,THREE.AnimationHandler.stop(this);for(var e=0;ee&&(this.currentTime%=e),this.currentTime=Math.min(this.currentTime,e),e=0;for(var t=this.hierarchy.length;t>e;e++){var r=this.hierarchy[e],i=this.data.hierarchy[e],n=i.keys,i=i.animationCache;if(n.length){var o=i.prevKey,a=i.nextKey;if(a.time<=this.currentTime){for(;a.timeo.index;)o=a,a=n[o.index+1];i.prevKey=o,i.nextKey=a}a.time>=this.currentTime?o.interpolate(a,this.currentTime):o.interpolate(a,a.time),this.data.hierarchy[e].node.updateMatrix(),r.matrixWorldNeedsUpdate=!0}}}},getNextKeyWith:function(e,t,r){for(t=this.data.hierarchy[t].keys,r%=t.length;r=0?r:r+t.length;r>=0;r--)if(t[r].hasTarget(e))return t[r];return t[t.length-1]}},THREE.MorphAnimation=function(e){this.mesh=e,this.frames=e.morphTargetInfluences.length,this.currentTime=0,this.duration=1e3,this.loop=!0,this.currentFrame=this.lastFrame=0,this.isPlaying=!1},THREE.MorphAnimation.prototype={constructor:THREE.MorphAnimation,play:function(){this.isPlaying=!0},pause:function(){this.isPlaying=!1},update:function(e){if(!1!==this.isPlaying){this.currentTime+=e,!0===this.loop&&this.currentTime>this.duration&&(this.currentTime%=this.duration),this.currentTime=Math.min(this.currentTime,this.duration),e=this.duration/this.frames;var t=Math.floor(this.currentTime/e),r=this.mesh.morphTargetInfluences;t!=this.currentFrame&&(r[this.lastFrame]=0,r[this.currentFrame]=1,r[t]=0,this.lastFrame=this.currentFrame,this.currentFrame=t),r[t]=this.currentTime%e/e,r[this.lastFrame]=1-r[t]}}},THREE.BoxGeometry=function(e,t,r,i,n,o){function a(e,t,r,i,n,o,a,h){var l,c=s.widthSegments,u=s.heightSegments,E=n/2,p=o/2,d=s.vertices.length;"x"===e&&"y"===t||"y"===e&&"x"===t?l="z":"x"===e&&"z"===t||"z"===e&&"x"===t?(l="y",u=s.depthSegments):("z"===e&&"y"===t||"y"===e&&"z"===t)&&(l="x",c=s.depthSegments);var f=c+1,m=u+1,T=n/c,g=o/u,R=new THREE.Vector3;for(R[l]=a>0?1:-1,n=0;m>n;n++)for(o=0;f>o;o++){var y=new THREE.Vector3;y[e]=(o*T-E)*r,y[t]=(n*g-p)*i,y[l]=a,s.vertices.push(y)}for(n=0;u>n;n++)for(o=0;c>o;o++)p=o+f*n,e=o+f*(n+1),t=o+1+f*(n+1),r=o+1+f*n,i=new THREE.Vector2(o/c,1-n/u),a=new THREE.Vector2(o/c,1-(n+1)/u),l=new THREE.Vector2((o+1)/c,1-(n+1)/u),E=new THREE.Vector2((o+1)/c,1-n/u),p=new THREE.Face3(p+d,e+d,r+d),p.normal.copy(R),p.vertexNormals.push(R.clone(),R.clone(),R.clone()),p.materialIndex=h,s.faces.push(p),s.faceVertexUvs[0].push([i,a,E]),p=new THREE.Face3(e+d,t+d,r+d),p.normal.copy(R),p.vertexNormals.push(R.clone(),R.clone(),R.clone()),p.materialIndex=h,s.faces.push(p),s.faceVertexUvs[0].push([a.clone(),l,E.clone()])}THREE.Geometry.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:o},this.widthSegments=i||1,this.heightSegments=n||1,this.depthSegments=o||1;var s=this;i=e/2,n=t/2,o=r/2,a("z","y",-1,-1,r,t,i,0),a("z","y",1,-1,r,t,-i,1),a("x","z",1,1,e,r,n,2),a("x","z",1,-1,e,r,-n,3),a("x","y",1,-1,e,t,o,4),a("x","y",-1,-1,e,t,-o,5),this.mergeVertices()},THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.BoxGeometry.prototype.constructor=THREE.BoxGeometry,THREE.CircleGeometry=function(e,t,r,i){THREE.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:r,thetaLength:i},e=e||50,t=void 0!==t?Math.max(3,t):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var n,o=[];n=new THREE.Vector3;var a=new THREE.Vector2(.5,.5);for(this.vertices.push(n),o.push(a),n=0;t>=n;n++){var s=new THREE.Vector3,h=r+n/t*i;s.x=e*Math.cos(h),s.y=e*Math.sin(h),this.vertices.push(s),o.push(new THREE.Vector2((s.x/e+1)/2,(s.y/e+1)/2))}for(r=new THREE.Vector3(0,0,1),n=1;t>=n;n++)this.faces.push(new THREE.Face3(n,n+1,0,[r.clone(),r.clone(),r.clone()])),this.faceVertexUvs[0].push([o[n].clone(),o[n+1].clone(),a.clone()]);this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,e)},THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CircleGeometry.prototype.constructor=THREE.CircleGeometry,THREE.CubeGeometry=function(e,t,r,i,n,o){return THREE.warn("THREE.CubeGeometry has been renamed to THREE.BoxGeometry."),new THREE.BoxGeometry(e,t,r,i,n,o)},THREE.CylinderGeometry=function(e,t,r,i,n,o,a,s){THREE.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:n,openEnded:o,thetaStart:a,thetaLength:s},e=void 0!==e?e:20,t=void 0!==t?t:20,r=void 0!==r?r:100,i=i||8,n=n||1,o=void 0!==o?o:!1,a=void 0!==a?a:0,s=void 0!==s?s:2*Math.PI;var h,l,c=r/2,u=[],E=[];for(l=0;n>=l;l++){var p=[],d=[],f=l/n,m=f*(t-e)+e;for(h=0;i>=h;h++){var T=h/i,g=new THREE.Vector3;g.x=m*Math.sin(T*s+a),g.y=-f*r+c,g.z=m*Math.cos(T*s+a),this.vertices.push(g),p.push(this.vertices.length-1),d.push(new THREE.Vector2(T,1-f))}u.push(p),E.push(d)}for(r=(t-e)/r,h=0;i>h;h++)for(0!==e?(a=this.vertices[u[0][h]].clone(),s=this.vertices[u[0][h+1]].clone()):(a=this.vertices[u[1][h]].clone(),s=this.vertices[u[1][h+1]].clone()),a.setY(Math.sqrt(a.x*a.x+a.z*a.z)*r).normalize(),s.setY(Math.sqrt(s.x*s.x+s.z*s.z)*r).normalize(),l=0;n>l;l++){var p=u[l][h],d=u[l+1][h],f=u[l+1][h+1],m=u[l][h+1],T=a.clone(),g=a.clone(),R=s.clone(),y=s.clone(),v=E[l][h].clone(),H=E[l+1][h].clone(),x=E[l+1][h+1].clone(),b=E[l][h+1].clone();this.faces.push(new THREE.Face3(p,d,m,[T,g,y])),this.faceVertexUvs[0].push([v,H,b]),this.faces.push(new THREE.Face3(d,f,m,[g.clone(),R,y.clone()])),this.faceVertexUvs[0].push([H.clone(),x,b.clone()])}if(!1===o&&e>0)for(this.vertices.push(new THREE.Vector3(0,c,0)),h=0;i>h;h++)p=u[0][h],d=u[0][h+1],f=this.vertices.length-1,T=new THREE.Vector3(0,1,0),g=new THREE.Vector3(0,1,0),R=new THREE.Vector3(0,1,0),v=E[0][h].clone(),H=E[0][h+1].clone(),x=new THREE.Vector2(H.x,0),this.faces.push(new THREE.Face3(p,d,f,[T,g,R])),this.faceVertexUvs[0].push([v,H,x]);if(!1===o&&t>0)for(this.vertices.push(new THREE.Vector3(0,-c,0)),h=0;i>h;h++)p=u[n][h+1],d=u[n][h],f=this.vertices.length-1,T=new THREE.Vector3(0,-1,0),g=new THREE.Vector3(0,-1,0),R=new THREE.Vector3(0,-1,0),v=E[n][h+1].clone(),H=E[n][h].clone(),x=new THREE.Vector2(H.x,1),this.faces.push(new THREE.Face3(p,d,f,[T,g,R])),this.faceVertexUvs[0].push([v,H,x]);this.computeFaceNormals()},THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry,THREE.ExtrudeGeometry=function(e,t){"undefined"!=typeof e&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",e=e instanceof Array?e:[e],this.addShapeList(e,t),this.computeFaceNormals())},THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry,THREE.ExtrudeGeometry.prototype.addShapeList=function(e,t){for(var r=e.length,i=0;r>i;i++)this.addShape(e[i],t)},THREE.ExtrudeGeometry.prototype.addShape=function(e,t){function r(e,t,r){return t||THREE.error("THREE.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(r).add(e)}function i(e,t,r){var i=1,i=e.x-t.x,n=e.y-t.y,o=r.x-e.x,a=r.y-e.y,s=i*i+n*n;if(1e-10=i)return new THREE.Vector2(r,e);i=Math.sqrt(i/2)}else e=!1,i>1e-10?o>1e-10&&(e=!0):-1e-10>i?-1e-10>o&&(e=!0):Math.sign(n)==Math.sign(a)&&(e=!0),e?(r=-n,e=i,i=Math.sqrt(s)):(r=i,e=n,i=Math.sqrt(s/2));return new THREE.Vector2(r/i,e/i)}function n(e,t){var r,i;for(N=e.length;0<=--N;){r=N,i=N-1,0>i&&(i=e.length-1);for(var n=0,o=g+2*f,n=0;o>n;n++){var a=z*n,s=z*(n+1),h=t+r+a,a=t+i+a,l=t+i+s,s=t+r+s,h=h+S,a=a+S,l=l+S,s=s+S;M.faces.push(new THREE.Face3(h,a,s,null,null,H)),M.faces.push(new THREE.Face3(a,l,s,null,null,H)),h=x.generateSideWallUV(M,h,a,l,s),M.faceVertexUvs[0].push([h[0],h[1],h[3]]),M.faceVertexUvs[0].push([h[1],h[2],h[3]])}}}function o(e,t,r){M.vertices.push(new THREE.Vector3(e,t,r))}function a(e,t,r){e+=S,t+=S,r+=S,M.faces.push(new THREE.Face3(e,t,r,null,null,v)),e=x.generateTopUV(M,e,t,r),M.faceVertexUvs[0].push(e)}var s,h,l,c,u,E=void 0!==t.amount?t.amount:100,p=void 0!==t.bevelThickness?t.bevelThickness:6,d=void 0!==t.bevelSize?t.bevelSize:p-2,f=void 0!==t.bevelSegments?t.bevelSegments:3,m=void 0!==t.bevelEnabled?t.bevelEnabled:!0,T=void 0!==t.curveSegments?t.curveSegments:12,g=void 0!==t.steps?t.steps:1,R=t.extrudePath,y=!1,v=t.material,H=t.extrudeMaterial,x=void 0!==t.UVGenerator?t.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator;R&&(s=R.getSpacedPoints(g),y=!0,m=!1,h=void 0!==t.frames?t.frames:new THREE.TubeGeometry.FrenetFrames(R,g,!1),l=new THREE.Vector3,c=new THREE.Vector3,u=new THREE.Vector3),m||(d=p=f=0);var b,w,_,M=this,S=this.vertices.length,R=e.extractPoints(T),T=R.shape,C=R.holes;if(R=!THREE.Shape.Utils.isClockWise(T)){for(T=T.reverse(),w=0,_=C.length;_>w;w++)b=C[w],THREE.Shape.Utils.isClockWise(b)&&(C[w]=b.reverse());R=!1}var A=THREE.Shape.Utils.triangulateShape(T,C),L=T;for(w=0,_=C.length;_>w;w++)b=C[w],T=T.concat(b);var P,F,B,U,D,V,z=T.length,k=A.length,R=[],N=0;for(B=L.length,P=B-1,F=N+1;B>N;N++,P++,F++)P===B&&(P=0),F===B&&(F=0),R[N]=i(L[N],L[P],L[F]);var O,G=[],I=R.concat();for(w=0,_=C.length;_>w;w++){for(b=C[w],O=[],N=0,B=b.length,P=B-1,F=N+1;B>N;N++,P++,F++)P===B&&(P=0),F===B&&(F=0),O[N]=i(b[N],b[P],b[F]);G.push(O),I=I.concat(O)}for(P=0;f>P;P++){for(B=P/f,U=p*(1-B),F=d*Math.sin(B*Math.PI/2),N=0,B=L.length;B>N;N++)D=r(L[N],R[N],F),o(D.x,D.y,-U);for(w=0,_=C.length;_>w;w++)for(b=C[w],O=G[w],N=0,B=b.length;B>N;N++)D=r(b[N],O[N],F),o(D.x,D.y,-U)}for(F=d,N=0;z>N;N++)D=m?r(T[N],I[N],F):T[N],y?(c.copy(h.normals[0]).multiplyScalar(D.x),l.copy(h.binormals[0]).multiplyScalar(D.y),u.copy(s[0]).add(c).add(l),o(u.x,u.y,u.z)):o(D.x,D.y,0);for(B=1;g>=B;B++)for(N=0;z>N;N++)D=m?r(T[N],I[N],F):T[N],y?(c.copy(h.normals[B]).multiplyScalar(D.x),l.copy(h.binormals[B]).multiplyScalar(D.y),u.copy(s[B]).add(c).add(l),o(u.x,u.y,u.z)):o(D.x,D.y,E/g*B);for(P=f-1;P>=0;P--){for(B=P/f,U=p*(1-B),F=d*Math.sin(B*Math.PI/2),N=0,B=L.length;B>N;N++)D=r(L[N],R[N],F),o(D.x,D.y,E+U);for(w=0,_=C.length;_>w;w++)for(b=C[w],O=G[w],N=0,B=b.length;B>N;N++)D=r(b[N],O[N],F),y?o(D.x,D.y+s[g-1].y,s[g-1].x+U):o(D.x,D.y,E+U)}!function(){if(m){var e;for(e=0*z,N=0;k>N;N++)V=A[N],a(V[2]+e,V[1]+e,V[0]+e);for(e=g+2*f,e*=z,N=0;k>N;N++)V=A[N],a(V[0]+e,V[1]+e,V[2]+e)}else{for(N=0;k>N;N++)V=A[N],a(V[2],V[1],V[0]);for(N=0;k>N;N++)V=A[N],a(V[0]+z*g,V[1]+z*g,V[2]+z*g)}}(),function(){var e=0;for(n(L,e),e+=L.length,w=0,_=C.length;_>w;w++)b=C[w],n(b,e),e+=b.length}()},THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(e,t,r,i){return e=e.vertices,t=e[t],r=e[r],i=e[i],[new THREE.Vector2(t.x,t.y),new THREE.Vector2(r.x,r.y),new THREE.Vector2(i.x,i.y)]},generateSideWallUV:function(e,t,r,i,n){return e=e.vertices,t=e[t],r=e[r],i=e[i],n=e[n],.01>Math.abs(t.y-r.y)?[new THREE.Vector2(t.x,1-t.z),new THREE.Vector2(r.x,1-r.z),new THREE.Vector2(i.x,1-i.z),new THREE.Vector2(n.x,1-n.z)]:[new THREE.Vector2(t.y,1-t.z),new THREE.Vector2(r.y,1-r.z),new THREE.Vector2(i.y,1-i.z),new THREE.Vector2(n.y,1-n.z)]}},THREE.ShapeGeometry=function(e,t){THREE.Geometry.call(this),this.type="ShapeGeometry",!1==e instanceof Array&&(e=[e]),this.addShapeList(e,t),this.computeFaceNormals()},THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry,THREE.ShapeGeometry.prototype.addShapeList=function(e,t){for(var r=0,i=e.length;i>r;r++)this.addShape(e[r],t);return this},THREE.ShapeGeometry.prototype.addShape=function(e,t){void 0===t&&(t={});var r,i,n,o=t.material,a=void 0===t.UVGenerator?THREE.ExtrudeGeometry.WorldUVGenerator:t.UVGenerator,s=this.vertices.length;r=e.extractPoints(void 0!==t.curveSegments?t.curveSegments:12);var h=r.shape,l=r.holes;if(!THREE.Shape.Utils.isClockWise(h))for(h=h.reverse(),r=0,i=l.length;i>r;r++)n=l[r],THREE.Shape.Utils.isClockWise(n)&&(l[r]=n.reverse());var c=THREE.Shape.Utils.triangulateShape(h,l);for(r=0,i=l.length;i>r;r++)n=l[r],h=h.concat(n);for(l=h.length,i=c.length,r=0;l>r;r++)n=h[r],this.vertices.push(new THREE.Vector3(n.x,n.y,0));for(r=0;i>r;r++)l=c[r],h=l[0]+s,n=l[1]+s,l=l[2]+s,this.faces.push(new THREE.Face3(h,n,l,null,null,o)),this.faceVertexUvs[0].push(a.generateTopUV(this,h,n,l))},THREE.LatheGeometry=function(e,t,r,i){THREE.Geometry.call(this),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:i},t=t||12,r=r||0,i=i||2*Math.PI;for(var n=1/(e.length-1),o=1/t,a=0,s=t;s>=a;a++)for(var h=r+a*o*i,l=Math.cos(h),c=Math.sin(h),h=0,u=e.length;u>h;h++){var E=e[h],p=new THREE.Vector3;p.x=l*E.x-c*E.y,p.y=c*E.x+l*E.y,p.z=E.z,this.vertices.push(p)}for(r=e.length,a=0,s=t;s>a;a++)for(h=0,u=e.length-1;u>h;h++){t=c=h+r*a,i=c+r;var l=c+1+r,c=c+1,E=a*o,p=h*n,d=E+o,f=p+n;this.faces.push(new THREE.Face3(t,i,c)),this.faceVertexUvs[0].push([new THREE.Vector2(E,p),new THREE.Vector2(d,p),new THREE.Vector2(E,f)]),this.faces.push(new THREE.Face3(i,l,c)),this.faceVertexUvs[0].push([new THREE.Vector2(d,p),new THREE.Vector2(d,f),new THREE.Vector2(E,f)])}this.mergeVertices(),this.computeFaceNormals(),this.computeVertexNormals()},THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry,THREE.PlaneGeometry=function(e,t,r,i){console.info("THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint."),THREE.Geometry.call(this),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i},this.fromBufferGeometry(new THREE.PlaneBufferGeometry(e,t,r,i))},THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry,THREE.PlaneBufferGeometry=function(e,t,r,i){THREE.BufferGeometry.call(this),this.type="PlaneBufferGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};var n=e/2,o=t/2;r=r||1,i=i||1;var a=r+1,s=i+1,h=e/r,l=t/i;t=new Float32Array(a*s*3),e=new Float32Array(a*s*3);for(var c=new Float32Array(a*s*2),u=0,E=0,p=0;s>p;p++)for(var d=p*l-o,f=0;a>f;f++)t[u]=f*h-n,t[u+1]=-d,e[u+2]=1,c[E]=f/r,c[E+1]=1-p/i,u+=3,E+=2;for(u=0,n=new(65535p;p++)for(f=0;r>f;f++)o=f+a*(p+1),s=f+1+a*(p+1),h=f+1+a*p,n[u]=f+a*p,n[u+1]=o,n[u+2]=h,n[u+3]=o,n[u+4]=s,n[u+5]=h,u+=6;this.addAttribute("index",new THREE.BufferAttribute(n,1)),this.addAttribute("position",new THREE.BufferAttribute(t,3)),this.addAttribute("normal",new THREE.BufferAttribute(e,3)),this.addAttribute("uv",new THREE.BufferAttribute(c,2))},THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype),THREE.PlaneBufferGeometry.prototype.constructor=THREE.PlaneBufferGeometry,THREE.RingGeometry=function(e,t,r,i,n,o){THREE.Geometry.call(this),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:r,phiSegments:i,thetaStart:n,thetaLength:o},e=e||0,t=t||50,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8,i=void 0!==i?Math.max(1,i):8;var a,s=[],h=e,l=(t-e)/i;for(e=0;i+1>e;e++){for(a=0;r+1>a;a++){var c=new THREE.Vector3,u=n+a/r*o;c.x=h*Math.cos(u),c.y=h*Math.sin(u),this.vertices.push(c),s.push(new THREE.Vector2((c.x/t+1)/2,(c.y/t+1)/2))}h+=l}for(t=new THREE.Vector3(0,0,1),e=0;i>e;e++)for(n=e*(r+1),a=0;r>a;a++)o=u=a+n,l=u+r+1,c=u+r+2,this.faces.push(new THREE.Face3(o,l,c,[t.clone(),t.clone(),t.clone()])),this.faceVertexUvs[0].push([s[o].clone(),s[l].clone(),s[c].clone()]),o=u,l=u+r+2,c=u+1,this.faces.push(new THREE.Face3(o,l,c,[t.clone(),t.clone(),t.clone()])),this.faceVertexUvs[0].push([s[o].clone(),s[l].clone(),s[c].clone()]);this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,h)},THREE.RingGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.RingGeometry.prototype.constructor=THREE.RingGeometry,THREE.SphereGeometry=function(e,t,r,i,n,o,a){THREE.Geometry.call(this),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:n,thetaStart:o,thetaLength:a},e=e||50,t=Math.max(3,Math.floor(t)||8),r=Math.max(2,Math.floor(r)||6),i=void 0!==i?i:0,n=void 0!==n?n:2*Math.PI,o=void 0!==o?o:0,a=void 0!==a?a:Math.PI;var s,h,l=[],c=[];for(h=0;r>=h;h++){var u=[],E=[];for(s=0;t>=s;s++){var p=s/t,d=h/r,f=new THREE.Vector3;f.x=-e*Math.cos(i+p*n)*Math.sin(o+d*a),f.y=e*Math.cos(o+d*a),f.z=e*Math.sin(i+p*n)*Math.sin(o+d*a),this.vertices.push(f),u.push(this.vertices.length-1),E.push(new THREE.Vector2(p,1-d))}l.push(u),c.push(E)}for(h=0;r>h;h++)for(s=0;t>s;s++){i=l[h][s+1],n=l[h][s],o=l[h+1][s],a=l[h+1][s+1];var u=this.vertices[i].clone().normalize(),E=this.vertices[n].clone().normalize(),p=this.vertices[o].clone().normalize(),d=this.vertices[a].clone().normalize(),f=c[h][s+1].clone(),m=c[h][s].clone(),T=c[h+1][s].clone(),g=c[h+1][s+1].clone();Math.abs(this.vertices[i].y)===e?(f.x=(f.x+m.x)/2,this.faces.push(new THREE.Face3(i,o,a,[u,p,d])),this.faceVertexUvs[0].push([f,T,g])):Math.abs(this.vertices[o].y)===e?(T.x=(T.x+g.x)/2,this.faces.push(new THREE.Face3(i,n,o,[u,E,p])),this.faceVertexUvs[0].push([f,m,T])):(this.faces.push(new THREE.Face3(i,n,a,[u,E,d])), +this.faceVertexUvs[0].push([f,m,g]),this.faces.push(new THREE.Face3(n,o,a,[E.clone(),p,d.clone()])),this.faceVertexUvs[0].push([m.clone(),T,g.clone()]))}this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,e)},THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry,THREE.TextGeometry=function(e,t){t=t||{};var r=THREE.FontUtils.generateShapes(e,t);t.amount=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),THREE.ExtrudeGeometry.call(this,r,t),this.type="TextGeometry"},THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype),THREE.TextGeometry.prototype.constructor=THREE.TextGeometry,THREE.TorusGeometry=function(e,t,r,i,n){THREE.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,arc:n},e=e||100,t=t||40,r=r||8,i=i||6,n=n||2*Math.PI;for(var o=new THREE.Vector3,a=[],s=[],h=0;r>=h;h++)for(var l=0;i>=l;l++){var c=l/i*n,u=h/r*Math.PI*2;o.x=e*Math.cos(c),o.y=e*Math.sin(c);var E=new THREE.Vector3;E.x=(e+t*Math.cos(u))*Math.cos(c),E.y=(e+t*Math.cos(u))*Math.sin(c),E.z=t*Math.sin(u),this.vertices.push(E),a.push(new THREE.Vector2(l/i,h/r)),s.push(E.clone().sub(o).normalize())}for(h=1;r>=h;h++)for(l=1;i>=l;l++)e=(i+1)*h+l-1,t=(i+1)*(h-1)+l-1,n=(i+1)*(h-1)+l,o=(i+1)*h+l,c=new THREE.Face3(e,t,o,[s[e].clone(),s[t].clone(),s[o].clone()]),this.faces.push(c),this.faceVertexUvs[0].push([a[e].clone(),a[t].clone(),a[o].clone()]),c=new THREE.Face3(t,n,o,[s[t].clone(),s[n].clone(),s[o].clone()]),this.faces.push(c),this.faceVertexUvs[0].push([a[t].clone(),a[n].clone(),a[o].clone()]);this.computeFaceNormals()},THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry,THREE.TorusKnotGeometry=function(e,t,r,i,n,o,a){function s(e,t,r,i,n){var o=Math.cos(e),a=Math.sin(e);return e*=t/r,t=Math.cos(e),o*=i*(2+t)*.5,a=i*(2+t)*a*.5,i=n*i*Math.sin(e)*.5,new THREE.Vector3(o,a,i)}THREE.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,radialSegments:r,tubularSegments:i,p:n,q:o,heightScale:a},e=e||100,t=t||40,r=r||64,i=i||8,n=n||2,o=o||3,a=a||1;for(var h=Array(r),l=new THREE.Vector3,c=new THREE.Vector3,u=new THREE.Vector3,E=0;r>E;++E){h[E]=Array(i);var p=E/r*2*n*Math.PI,d=s(p,o,n,e,a),p=s(p+.01,o,n,e,a);for(l.subVectors(p,d),c.addVectors(p,d),u.crossVectors(l,c),c.crossVectors(u,l),u.normalize(),c.normalize(),p=0;i>p;++p){var f=p/i*2*Math.PI,m=-t*Math.cos(f),f=t*Math.sin(f),T=new THREE.Vector3;T.x=d.x+m*c.x+f*u.x,T.y=d.y+m*c.y+f*u.y,T.z=d.z+m*c.z+f*u.z,h[E][p]=this.vertices.push(T)-1}}for(E=0;r>E;++E)for(p=0;i>p;++p)n=(E+1)%r,o=(p+1)%i,e=h[E][p],t=h[n][p],n=h[n][o],o=h[E][o],a=new THREE.Vector2(E/r,p/i),l=new THREE.Vector2((E+1)/r,p/i),c=new THREE.Vector2((E+1)/r,(p+1)/i),u=new THREE.Vector2(E/r,(p+1)/i),this.faces.push(new THREE.Face3(e,t,o)),this.faceVertexUvs[0].push([a,l,u]),this.faces.push(new THREE.Face3(t,n,o)),this.faceVertexUvs[0].push([l.clone(),c,u.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry,THREE.TubeGeometry=function(e,t,r,i,n,o){THREE.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:e,segments:t,radius:r,radialSegments:i,closed:n},t=t||64,r=r||1,i=i||8,n=n||!1,o=o||THREE.TubeGeometry.NoTaper;var a,s,h,l,c,u,E,p,d,f,m=[],T=t+1,g=new THREE.Vector3;for(p=new THREE.TubeGeometry.FrenetFrames(e,t,n),d=p.normals,f=p.binormals,this.tangents=p.tangents,this.normals=d,this.binormals=f,p=0;T>p;p++)for(m[p]=[],h=p/(T-1),E=e.getPointAt(h),a=d[p],s=f[p],c=r*o(h),h=0;i>h;h++)l=h/i*2*Math.PI,u=-c*Math.cos(l),l=c*Math.sin(l),g.copy(E),g.x+=u*a.x+l*s.x,g.y+=u*a.y+l*s.y,g.z+=u*a.z+l*s.z,m[p][h]=this.vertices.push(new THREE.Vector3(g.x,g.y,g.z))-1;for(p=0;t>p;p++)for(h=0;i>h;h++)o=n?(p+1)%t:p+1,T=(h+1)%i,e=m[p][h],r=m[o][h],o=m[o][T],T=m[p][T],g=new THREE.Vector2(p/t,h/i),d=new THREE.Vector2((p+1)/t,h/i),f=new THREE.Vector2((p+1)/t,(h+1)/i),a=new THREE.Vector2(p/t,(h+1)/i),this.faces.push(new THREE.Face3(e,r,T)),this.faceVertexUvs[0].push([g,d,a]),this.faces.push(new THREE.Face3(r,o,T)),this.faceVertexUvs[0].push([d.clone(),f,a.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry,THREE.TubeGeometry.NoTaper=function(e){return 1},THREE.TubeGeometry.SinusoidalTaper=function(e){return Math.sin(Math.PI*e)},THREE.TubeGeometry.FrenetFrames=function(e,t,r){var i=new THREE.Vector3,n=[],o=[],a=[],s=new THREE.Vector3,h=new THREE.Matrix4;t+=1;var l,c,u;for(this.tangents=n,this.normals=o,this.binormals=a,l=0;t>l;l++)c=l/(t-1),n[l]=e.getTangentAt(c),n[l].normalize();for(o[0]=new THREE.Vector3,a[0]=new THREE.Vector3,e=Number.MAX_VALUE,l=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z),e>=l&&(e=l,i.set(1,0,0)),e>=c&&(e=c,i.set(0,1,0)),e>=u&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),o[0].crossVectors(n[0],s),a[0].crossVectors(n[0],o[0]),l=1;t>l;l++)o[l]=o[l-1].clone(),a[l]=a[l-1].clone(),s.crossVectors(n[l-1],n[l]),1e-4l;l++)o[l].applyMatrix4(h.makeRotationAxis(n[l],i*l)),a[l].crossVectors(n[l],o[l])},THREE.PolyhedronGeometry=function(e,t,r,i){function n(e){var t=e.normalize().clone();t.index=h.vertices.push(t)-1;var r=Math.atan2(e.z,-e.x)/2/Math.PI+.5;return e=Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))/Math.PI+.5,t.uv=new THREE.Vector2(r,1-e),t}function o(e,t,r){var i=new THREE.Face3(e.index,t.index,r.index,[e.clone(),t.clone(),r.clone()]);h.faces.push(i),m.copy(e).add(t).add(r).divideScalar(3),i=Math.atan2(m.z,-m.x),h.faceVertexUvs[0].push([s(e.uv,e,i),s(t.uv,t,i),s(r.uv,r,i)])}function a(e,t){for(var r=Math.pow(2,t),i=n(h.vertices[e.a]),a=n(h.vertices[e.b]),s=n(h.vertices[e.c]),l=[],c=0;r>=c;c++){l[c]=[];for(var u=n(i.clone().lerp(s,c/r)),E=n(a.clone().lerp(s,c/r)),p=r-c,d=0;p>=d;d++)l[c][d]=0==d&&c==r?u:n(u.clone().lerp(E,d/p))}for(c=0;r>c;c++)for(d=0;2*(r-c)-1>d;d++)i=Math.floor(d/2),0==d%2?o(l[c][i+1],l[c+1][i],l[c][i]):o(l[c][i+1],l[c+1][i+1],l[c+1][i])}function s(e,t,r){return 0>r&&1===e.x&&(e=new THREE.Vector2(e.x-1,e.y)),0===t.x&&0===t.z&&(e=new THREE.Vector2(r/2/Math.PI+.5,e.y)),e.clone()}THREE.Geometry.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:r,detail:i},r=r||1,i=i||0;for(var h=this,l=0,c=e.length;c>l;l+=3)n(new THREE.Vector3(e[l],e[l+1],e[l+2]));e=this.vertices;for(var u=[],E=l=0,c=t.length;c>l;l+=3,E++){var p=e[t[l]],d=e[t[l+1]],f=e[t[l+2]];u[E]=new THREE.Face3(p.index,d.index,f.index,[p.clone(),d.clone(),f.clone()])}for(var m=new THREE.Vector3,l=0,c=u.length;c>l;l++)a(u[l],i);for(l=0,c=this.faceVertexUvs[0].length;c>l;l++)t=this.faceVertexUvs[0][l],i=t[0].x,e=t[1].x,u=t[2].x,E=Math.max(i,Math.max(e,u)),p=Math.min(i,Math.min(e,u)),E>.9&&.1>p&&(.2>i&&(t[0].x+=1),.2>e&&(t[1].x+=1),.2>u&&(t[2].x+=1));for(l=0,c=this.vertices.length;c>l;l++)this.vertices[l].multiplyScalar(r);this.mergeVertices(),this.computeFaceNormals(),this.boundingSphere=new THREE.Sphere(new THREE.Vector3,r)},THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.PolyhedronGeometry.prototype.constructor=THREE.PolyhedronGeometry,THREE.DodecahedronGeometry=function(e,t){this.parameters={radius:e,detail:t};var r=(1+Math.sqrt(5))/2,i=1/r;THREE.PolyhedronGeometry.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t)},THREE.DodecahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.DodecahedronGeometry.prototype.constructor=THREE.DodecahedronGeometry,THREE.IcosahedronGeometry=function(e,t){var r=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}},THREE.IcosahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry,THREE.OctahedronGeometry=function(e,t){this.parameters={radius:e,detail:t},THREE.PolyhedronGeometry.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}},THREE.OctahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry,THREE.TetrahedronGeometry=function(e,t){THREE.PolyhedronGeometry.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}},THREE.TetrahedronGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.TetrahedronGeometry.prototype.constructor=THREE.TetrahedronGeometry,THREE.ParametricGeometry=function(e,t,r){THREE.Geometry.call(this),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:r};var i,n,o,a,s=this.vertices,h=this.faces,l=this.faceVertexUvs[0],c=t+1;for(i=0;r>=i;i++)for(a=i/r,n=0;t>=n;n++)o=n/t,o=e(o,a),s.push(o);var u,E,p,d;for(i=0;r>i;i++)for(n=0;t>n;n++)e=i*c+n,s=i*c+n+1,a=(i+1)*c+n+1,o=(i+1)*c+n,u=new THREE.Vector2(n/t,i/r),E=new THREE.Vector2((n+1)/t,i/r),p=new THREE.Vector2((n+1)/t,(i+1)/r),d=new THREE.Vector2(n/t,(i+1)/r),h.push(new THREE.Face3(e,s,o)),l.push([u,E,d]),h.push(new THREE.Face3(s,a,o)),l.push([E.clone(),p,d.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype),THREE.ParametricGeometry.prototype.constructor=THREE.ParametricGeometry,THREE.AxisHelper=function(e){e=e||1;var t=new Float32Array([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e]),r=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);e=new THREE.BufferGeometry,e.addAttribute("position",new THREE.BufferAttribute(t,3)),e.addAttribute("color",new THREE.BufferAttribute(r,3)),t=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors}),THREE.Line.call(this,e,t,THREE.LinePieces)},THREE.AxisHelper.prototype=Object.create(THREE.Line.prototype),THREE.AxisHelper.prototype.constructor=THREE.AxisHelper,THREE.ArrowHelper=function(){var e=new THREE.Geometry;e.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));var t=new THREE.CylinderGeometry(0,.5,1,5,1);return t.applyMatrix((new THREE.Matrix4).makeTranslation(0,-.5,0)),function(r,i,n,o,a,s){THREE.Object3D.call(this),void 0===o&&(o=16776960),void 0===n&&(n=1),void 0===a&&(a=.2*n),void 0===s&&(s=.2*a),this.position.copy(i),this.line=new THREE.Line(e,new THREE.LineBasicMaterial({color:o})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new THREE.Mesh(t,new THREE.MeshBasicMaterial({color:o})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(r),this.setLength(n,a,s)}}(),THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.ArrowHelper.prototype.constructor=THREE.ArrowHelper,THREE.ArrowHelper.prototype.setDirection=function(){var e,t=new THREE.Vector3;return function(r){.99999r.y?this.quaternion.set(1,0,0,0):(t.set(r.z,0,-r.x).normalize(),e=Math.acos(r.y),this.quaternion.setFromAxisAngle(t,e))}}(),THREE.ArrowHelper.prototype.setLength=function(e,t,r){void 0===t&&(t=.2*e),void 0===r&&(r=.2*t),this.line.scale.set(1,e-t,1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()},THREE.ArrowHelper.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},THREE.BoxHelper=function(e){var t=new THREE.BufferGeometry;t.addAttribute("position",new THREE.BufferAttribute(new Float32Array(72),3)),THREE.Line.call(this,t,new THREE.LineBasicMaterial({color:16776960}),THREE.LinePieces),void 0!==e&&this.update(e)},THREE.BoxHelper.prototype=Object.create(THREE.Line.prototype),THREE.BoxHelper.prototype.constructor=THREE.BoxHelper,THREE.BoxHelper.prototype.update=function(e){var t=e.geometry;null===t.boundingBox&&t.computeBoundingBox();var r=t.boundingBox.min,t=t.boundingBox.max,i=this.geometry.attributes.position.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=r.x,i[4]=t.y,i[5]=t.z,i[6]=r.x,i[7]=t.y,i[8]=t.z,i[9]=r.x,i[10]=r.y,i[11]=t.z,i[12]=r.x,i[13]=r.y,i[14]=t.z,i[15]=t.x,i[16]=r.y,i[17]=t.z,i[18]=t.x,i[19]=r.y,i[20]=t.z,i[21]=t.x,i[22]=t.y,i[23]=t.z,i[24]=t.x,i[25]=t.y,i[26]=r.z,i[27]=r.x,i[28]=t.y,i[29]=r.z,i[30]=r.x,i[31]=t.y,i[32]=r.z,i[33]=r.x,i[34]=r.y,i[35]=r.z,i[36]=r.x,i[37]=r.y,i[38]=r.z,i[39]=t.x,i[40]=r.y,i[41]=r.z,i[42]=t.x,i[43]=r.y,i[44]=r.z,i[45]=t.x,i[46]=t.y,i[47]=r.z,i[48]=t.x,i[49]=t.y,i[50]=t.z,i[51]=t.x,i[52]=t.y,i[53]=r.z,i[54]=r.x,i[55]=t.y,i[56]=t.z,i[57]=r.x,i[58]=t.y,i[59]=r.z,i[60]=r.x,i[61]=r.y,i[62]=t.z,i[63]=r.x,i[64]=r.y,i[65]=r.z,i[66]=t.x,i[67]=r.y,i[68]=t.z,i[69]=t.x,i[70]=r.y,i[71]=r.z,this.geometry.attributes.position.needsUpdate=!0,this.geometry.computeBoundingSphere(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},THREE.BoundingBoxHelper=function(e,t){var r=void 0!==t?t:8947848;this.object=e,this.box=new THREE.Box3,THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:r,wireframe:!0}))},THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype),THREE.BoundingBoxHelper.prototype.constructor=THREE.BoundingBoxHelper,THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},THREE.CameraHelper=function(e){function t(e,t,i){r(e,i),r(t,i)}function r(e,t){i.vertices.push(new THREE.Vector3),i.colors.push(new THREE.Color(t)),void 0===o[e]&&(o[e]=[]),o[e].push(i.vertices.length-1)}var i=new THREE.Geometry,n=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),o={};t("n1","n2",16755200),t("n2","n4",16755200),t("n4","n3",16755200),t("n3","n1",16755200),t("f1","f2",16755200),t("f2","f4",16755200),t("f4","f3",16755200),t("f3","f1",16755200),t("n1","f1",16755200),t("n2","f2",16755200),t("n3","f3",16755200),t("n4","f4",16755200),t("p","n1",16711680),t("p","n2",16711680),t("p","n3",16711680),t("p","n4",16711680),t("u1","u2",43775),t("u2","u3",43775),t("u3","u1",43775),t("c","t",16777215),t("p","c",3355443),t("cn1","cn2",3355443),t("cn3","cn4",3355443),t("cf1","cf2",3355443),t("cf3","cf4",3355443),THREE.Line.call(this,i,n,THREE.LinePieces),this.camera=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()},THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype),THREE.CameraHelper.prototype.constructor=THREE.CameraHelper,THREE.CameraHelper.prototype.update=function(){var e,t,r=new THREE.Vector3,i=new THREE.Camera,n=function(n,o,a,s){if(r.set(o,a,s).unproject(i),n=t[n],void 0!==n)for(o=0,a=n.length;a>o;o++)e.vertices[n[o]].copy(r)};return function(){e=this.geometry,t=this.pointMap,i.projectionMatrix.copy(this.camera.projectionMatrix),n("c",0,0,-1),n("t",0,0,1),n("n1",-1,-1,-1),n("n2",1,-1,-1),n("n3",-1,1,-1),n("n4",1,1,-1),n("f1",-1,-1,1),n("f2",1,-1,1),n("f3",-1,1,1),n("f4",1,1,1),n("u1",.7,1.1,-1),n("u2",-.7,1.1,-1),n("u3",0,2,-1),n("cf1",-1,0,1),n("cf2",1,0,1),n("cf3",0,-1,1),n("cf4",0,1,1),n("cn1",-1,0,-1),n("cn2",1,0,-1),n("cn3",0,-1,-1),n("cn4",0,1,-1),e.verticesNeedUpdate=!0}}(),THREE.DirectionalLightHelper=function(e,t){THREE.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,t=t||1;var r=new THREE.Geometry;r.vertices.push(new THREE.Vector3(-t,t,0),new THREE.Vector3(t,t,0),new THREE.Vector3(t,-t,0),new THREE.Vector3(-t,-t,0),new THREE.Vector3(-t,t,0));var i=new THREE.LineBasicMaterial({fog:!1});i.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.lightPlane=new THREE.Line(r,i),this.add(this.lightPlane),r=new THREE.Geometry,r.vertices.push(new THREE.Vector3,new THREE.Vector3),i=new THREE.LineBasicMaterial({fog:!1}),i.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine=new THREE.Line(r,i),this.add(this.targetLine),this.update()},THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.DirectionalLightHelper.prototype.constructor=THREE.DirectionalLightHelper,THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},THREE.DirectionalLightHelper.prototype.update=function(){var e=new THREE.Vector3,t=new THREE.Vector3,r=new THREE.Vector3;return function(){e.setFromMatrixPosition(this.light.matrixWorld),t.setFromMatrixPosition(this.light.target.matrixWorld),r.subVectors(t,e),this.lightPlane.lookAt(r),this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine.geometry.vertices[1].copy(r),this.targetLine.geometry.verticesNeedUpdate=!0,this.targetLine.material.color.copy(this.lightPlane.material.color)}}(),THREE.EdgesHelper=function(e,t,r){t=void 0!==t?t:16777215,r=Math.cos(THREE.Math.degToRad(void 0!==r?r:1));var i,n=[0,0],o={},a=function(e,t){return e-t},s=["a","b","c"],h=new THREE.BufferGeometry;e.geometry instanceof THREE.BufferGeometry?(i=new THREE.Geometry,i.fromBufferGeometry(e.geometry)):i=e.geometry.clone(),i.mergeVertices(),i.computeFaceNormals();var l=i.vertices;i=i.faces;for(var c=0,u=0,E=i.length;E>u;u++)for(var p=i[u],d=0;3>d;d++){n[0]=p[s[d]],n[1]=p[s[(d+1)%3]],n.sort(a);var f=n.toString();void 0===o[f]?(o[f]={vert1:n[0],vert2:n[1],face1:u,face2:void 0},c++):o[f].face2=u}n=new Float32Array(6*c),a=0;for(f in o)s=o[f],(void 0===s.face2||i[s.face1].normal.dot(i[s.face2].normal)<=r)&&(c=l[s.vert1],n[a++]=c.x,n[a++]=c.y,n[a++]=c.z,c=l[s.vert2],n[a++]=c.x,n[a++]=c.y,n[a++]=c.z);h.addAttribute("position",new THREE.BufferAttribute(n,3)),THREE.Line.call(this,h,new THREE.LineBasicMaterial({color:t}),THREE.LinePieces),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},THREE.EdgesHelper.prototype=Object.create(THREE.Line.prototype),THREE.EdgesHelper.prototype.constructor=THREE.EdgesHelper,THREE.FaceNormalsHelper=function(e,t,r,i){this.object=e,this.size=void 0!==t?t:1,e=void 0!==r?r:16776960,i=void 0!==i?i:1,t=new THREE.Geometry,r=0;for(var n=this.object.geometry.faces.length;n>r;r++)t.vertices.push(new THREE.Vector3,new THREE.Vector3);THREE.Line.call(this,t,new THREE.LineBasicMaterial({color:e,linewidth:i}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new THREE.Matrix3,this.update()},THREE.FaceNormalsHelper.prototype=Object.create(THREE.Line.prototype),THREE.FaceNormalsHelper.prototype.constructor=THREE.FaceNormalsHelper,THREE.FaceNormalsHelper.prototype.update=function(){var e=this.geometry.vertices,t=this.object,r=t.geometry.vertices,i=t.geometry.faces,n=t.matrixWorld;t.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(n);for(var o=t=0,a=i.length;a>t;t++,o+=2){var s=i[t];e[o].copy(r[s.a]).add(r[s.b]).add(r[s.c]).divideScalar(3).applyMatrix4(n),e[o+1].copy(s.normal).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size).add(e[o])}return this.geometry.verticesNeedUpdate=!0,this},THREE.GridHelper=function(e,t){var r=new THREE.Geometry,i=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});this.color1=new THREE.Color(4473924),this.color2=new THREE.Color(8947848);for(var n=-e;e>=n;n+=t){r.vertices.push(new THREE.Vector3(-e,0,n),new THREE.Vector3(e,0,n),new THREE.Vector3(n,0,-e),new THREE.Vector3(n,0,e));var o=0===n?this.color1:this.color2;r.colors.push(o,o,o,o)}THREE.Line.call(this,r,i,THREE.LinePieces)},THREE.GridHelper.prototype=Object.create(THREE.Line.prototype),THREE.GridHelper.prototype.constructor=THREE.GridHelper,THREE.GridHelper.prototype.setColors=function(e,t){this.color1.set(e),this.color2.set(t),this.geometry.colorsNeedUpdate=!0},THREE.HemisphereLightHelper=function(e,t){THREE.Object3D.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new THREE.Color,new THREE.Color];var r=new THREE.SphereGeometry(t,4,2);r.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI/2));for(var i=0;8>i;i++)r.faces[i].color=this.colors[4>i?0:1];i=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0}),this.lightSphere=new THREE.Mesh(r,i),this.add(this.lightSphere),this.update()},THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype),THREE.HemisphereLightHelper.prototype.constructor=THREE.HemisphereLightHelper,THREE.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose(),this.lightSphere.material.dispose()},THREE.HemisphereLightHelper.prototype.update=function(){var e=new THREE.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity),this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity),this.lightSphere.lookAt(e.setFromMatrixPosition(this.light.matrixWorld).negate()),this.lightSphere.geometry.colorsNeedUpdate=!0}}(),THREE.PointLightHelper=function(e,t){this.light=e,this.light.updateMatrixWorld();var r=new THREE.SphereGeometry(t,4,2),i=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});i.color.copy(this.light.color).multiplyScalar(this.light.intensity),THREE.Mesh.call(this,r,i),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1},THREE.PointLightHelper.prototype=Object.create(THREE.Mesh.prototype),THREE.PointLightHelper.prototype.constructor=THREE.PointLightHelper,THREE.PointLightHelper.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)},THREE.SkeletonHelper=function(e){this.bones=this.getBoneList(e);for(var t=new THREE.Geometry,r=0;rn;n++)for(var a=0,s=e[n].vertexNormals.length;s>a;a++)r.vertices.push(new THREE.Vector3,new THREE.Vector3);THREE.Line.call(this,r,new THREE.LineBasicMaterial({color:t,linewidth:i}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new THREE.Matrix3,this.update()},THREE.VertexNormalsHelper.prototype=Object.create(THREE.Line.prototype),THREE.VertexNormalsHelper.prototype.constructor=THREE.VertexNormalsHelper,THREE.VertexNormalsHelper.prototype.update=function(e){var t=new THREE.Vector3;return function(e){e=["a","b","c","d"],this.object.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(this.object.matrixWorld);for(var r=this.geometry.vertices,i=this.object.geometry.vertices,n=this.object.geometry.faces,o=this.object.matrixWorld,a=0,s=0,h=n.length;h>s;s++)for(var l=n[s],c=0,u=l.vertexNormals.length;u>c;c++){var E=l.vertexNormals[c];r[a].copy(i[l[e[c]]]).applyMatrix4(o),t.copy(E).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size),t.add(r[a]),a+=1,r[a].copy(t),a+=1}return this.geometry.verticesNeedUpdate=!0,this}}(),THREE.VertexTangentsHelper=function(e,t,r,i){this.object=e,this.size=void 0!==t?t:1,t=void 0!==r?r:255,i=void 0!==i?i:1,r=new THREE.Geometry,e=e.geometry.faces;for(var n=0,o=e.length;o>n;n++)for(var a=0,s=e[n].vertexTangents.length;s>a;a++)r.vertices.push(new THREE.Vector3),r.vertices.push(new THREE.Vector3);THREE.Line.call(this,r,new THREE.LineBasicMaterial({color:t,linewidth:i}),THREE.LinePieces),this.matrixAutoUpdate=!1,this.update()},THREE.VertexTangentsHelper.prototype=Object.create(THREE.Line.prototype),THREE.VertexTangentsHelper.prototype.constructor=THREE.VertexTangentsHelper,THREE.VertexTangentsHelper.prototype.update=function(e){var t=new THREE.Vector3;return function(e){e=["a","b","c","d"],this.object.updateMatrixWorld(!0);for(var r=this.geometry.vertices,i=this.object.geometry.vertices,n=this.object.geometry.faces,o=this.object.matrixWorld,a=0,s=0,h=n.length;h>s;s++)for(var l=n[s],c=0,u=l.vertexTangents.length;u>c;c++){var E=l.vertexTangents[c];r[a].copy(i[l[e[c]]]).applyMatrix4(o),t.copy(E).transformDirection(o).multiplyScalar(this.size),t.add(r[a]),a+=1,r[a].copy(t),a+=1}return this.geometry.verticesNeedUpdate=!0,this}}(),THREE.WireframeHelper=function(e,t){var r=void 0!==t?t:16777215,i=[0,0],n={},o=function(e,t){return e-t},a=["a","b","c"],s=new THREE.BufferGeometry;if(e.geometry instanceof THREE.Geometry){for(var h=e.geometry.vertices,l=e.geometry.faces,c=0,u=new Uint32Array(6*l.length),E=0,p=l.length;p>E;E++)for(var d=l[E],f=0;3>f;f++){i[0]=d[a[f]],i[1]=d[a[(f+1)%3]],i.sort(o);var m=i.toString();void 0===n[m]&&(u[2*c]=i[0],u[2*c+1]=i[1],n[m]=!0,c++)}for(i=new Float32Array(6*c),E=0,p=c;p>E;E++)for(f=0;2>f;f++)c=h[u[2*E+f]],a=6*E+3*f,i[a+0]=c.x,i[a+1]=c.y,i[a+2]=c.z;s.addAttribute("position",new THREE.BufferAttribute(i,3))}else if(e.geometry instanceof THREE.BufferGeometry){if(void 0!==e.geometry.attributes.index){h=e.geometry.attributes.position.array,p=e.geometry.attributes.index.array,l=e.geometry.drawcalls,c=0,0===l.length&&(l=[{count:p.length,index:0,start:0}]);for(var u=new Uint32Array(2*p.length),d=0,T=l.length;T>d;++d)for(var f=l[d].start,m=l[d].count,a=l[d].index,E=f,g=f+m;g>E;E+=3)for(f=0;3>f;f++)i[0]=a+p[E+f],i[1]=a+p[E+(f+1)%3],i.sort(o),m=i.toString(),void 0===n[m]&&(u[2*c]=i[0],u[2*c+1]=i[1],n[m]=!0,c++);for(i=new Float32Array(6*c),E=0,p=c;p>E;E++)for(f=0;2>f;f++)a=6*E+3*f,c=3*u[2*E+f],i[a+0]=h[c],i[a+1]=h[c+1],i[a+2]=h[c+2]}else for(h=e.geometry.attributes.position.array,c=h.length/3,u=c/3,i=new Float32Array(6*c),E=0,p=u;p>E;E++)for(f=0;3>f;f++)a=18*E+6*f,u=9*E+3*f,i[a+0]=h[u],i[a+1]=h[u+1],i[a+2]=h[u+2],c=9*E+(f+1)%3*3,i[a+3]=h[c],i[a+4]=h[c+1],i[a+5]=h[c+2];s.addAttribute("position",new THREE.BufferAttribute(i,3))}THREE.Line.call(this,s,new THREE.LineBasicMaterial({color:r}),THREE.LinePieces),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1},THREE.WireframeHelper.prototype=Object.create(THREE.Line.prototype),THREE.WireframeHelper.prototype.constructor=THREE.WireframeHelper,THREE.ImmediateRenderObject=function(){THREE.Object3D.call(this),this.render=function(e){}},THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype),THREE.ImmediateRenderObject.prototype.constructor=THREE.ImmediateRenderObject,THREE.MorphBlendMesh=function(e,t){THREE.Mesh.call(this,e,t),this.animationsMap={},this.animationsList=[];var r=this.geometry.morphTargets.length;this.createAnimation("__default",0,r-1,r/1),this.setAnimationWeight("__default",1)},THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype),THREE.MorphBlendMesh.prototype.constructor=THREE.MorphBlendMesh,THREE.MorphBlendMesh.prototype.createAnimation=function(e,t,r,i){t={startFrame:t,endFrame:r,length:r-t+1,fps:i,duration:(r-t)/i,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1},this.animationsMap[e]=t,this.animationsList.push(t)},THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(e){for(var t,r=/([a-z]+)_?(\d+)/,i={},n=this.geometry,o=0,a=n.morphTargets.length;a>o;o++){var s=n.morphTargets[o].name.match(r);if(s&&1s.end&&(s.end=o),t||(t=h)}}for(h in i)s=i[h],this.createAnimation(h,s.start,s.end,e);this.firstAnimation=t},THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(e){(e=this.animationsMap[e])&&(e.direction=1,e.directionBackwards=!1)},THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(e){(e=this.animationsMap[e])&&(e.direction=-1,e.directionBackwards=!0)},THREE.MorphBlendMesh.prototype.setAnimationFPS=function(e,t){var r=this.animationsMap[e];r&&(r.fps=t,r.duration=(r.end-r.start)/r.fps)},THREE.MorphBlendMesh.prototype.setAnimationDuration=function(e,t){var r=this.animationsMap[e];r&&(r.duration=t,r.fps=(r.end-r.start)/r.duration)},THREE.MorphBlendMesh.prototype.setAnimationWeight=function(e,t){var r=this.animationsMap[e];r&&(r.weight=t)},THREE.MorphBlendMesh.prototype.setAnimationTime=function(e,t){var r=this.animationsMap[e];r&&(r.time=t)},THREE.MorphBlendMesh.prototype.getAnimationTime=function(e){var t=0;return(e=this.animationsMap[e])&&(t=e.time),t},THREE.MorphBlendMesh.prototype.getAnimationDuration=function(e){var t=-1;return(e=this.animationsMap[e])&&(t=e.duration),t},THREE.MorphBlendMesh.prototype.playAnimation=function(e){var t=this.animationsMap[e];t?(t.time=0,t.active=!0):THREE.warn("THREE.MorphBlendMesh: animation["+e+"] undefined in .playAnimation()")},THREE.MorphBlendMesh.prototype.stopAnimation=function(e){(e=this.animationsMap[e])&&(e.active=!1)},THREE.MorphBlendMesh.prototype.update=function(e){for(var t=0,r=this.animationsList.length;r>t;t++){var i=this.animationsList[t]; +if(i.active){var n=i.duration/i.length;i.time+=i.direction*e,i.mirroredLoop?(i.time>i.duration||0>i.time)&&(i.direction*=-1,i.time>i.duration&&(i.time=i.duration,i.directionBackwards=!0),0>i.time&&(i.time=0,i.directionBackwards=!1)):(i.time%=i.duration,0>i.time&&(i.time+=i.duration));var o=i.startFrame+THREE.Math.clamp(Math.floor(i.time/n),0,i.length-1),a=i.weight;o!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*a,this.morphTargetInfluences[o]=0,i.lastFrame=i.currentFrame,i.currentFrame=o),n=i.time%n/n,i.directionBackwards&&(n=1-n),this.morphTargetInfluences[i.currentFrame]=n*a,this.morphTargetInfluences[i.lastFrame]=(1-n)*a}}},THREE.SpriteCanvasMaterial=function(e){THREE.Material.call(this),this.type="SpriteCanvasMaterial",this.color=new THREE.Color(16777215),this.program=function(e,t){},this.setValues(e)},THREE.SpriteCanvasMaterial.prototype=Object.create(THREE.Material.prototype),THREE.SpriteCanvasMaterial.prototype.constructor=THREE.SpriteCanvasMaterial,THREE.SpriteCanvasMaterial.prototype.clone=function(){var e=new THREE.SpriteCanvasMaterial;return THREE.Material.prototype.clone.call(this,e),e.color.copy(this.color),e.program=this.program,e},THREE.CanvasRenderer=function(e){function t(){Re.setRGB(0,0,0),ye.setRGB(0,0,0),ve.setRGB(0,0,0);for(var e=0,t=b.length;t>e;e++){var r=b[e],i=r.color;r instanceof THREE.AmbientLight?Re.add(i):r instanceof THREE.DirectionalLight?ye.add(i):r instanceof THREE.PointLight&&ve.add(i)}}function r(e,t,r){for(var i=0,n=b.length;n>i;i++){var o=b[i];if(de.copy(o.color),o instanceof THREE.DirectionalLight){var a=He.setFromMatrixPosition(o.matrixWorld).normalize(),s=t.dot(a);if(0>=s)continue;s*=o.intensity,r.add(de.multiplyScalar(s))}else if(o instanceof THREE.PointLight){var a=He.setFromMatrixPosition(o.matrixWorld),s=t.dot(He.subVectors(a,e).normalize());if(0>=s)continue;if(s*=0==o.distance?1:1-Math.min(e.distanceTo(a)/o.distance,1),0==s)continue;s*=o.intensity,r.add(de.multiplyScalar(s))}}}function i(e,t,r){p(r.opacity),d(r.blending);var i=t.scale.x*q,n=t.scale.y*Y,o=.5*Math.sqrt(i*i+n*n);if(ge.min.set(e.x-o,e.y-o),ge.max.set(e.x+o,e.y+o),r instanceof THREE.SpriteMaterial){var a=r.map;if(null!==a&&void 0!==a.image){a.hasEventListener("update",l)===!1&&(a.image.width>0&&c(a),a.addEventListener("update",l));var s=fe[a.id];R(void 0!==s?s:"rgba( 0, 0, 0, 1 )");var h=a.image,u=h.width*a.offset.x,E=h.height*a.offset.y,f=h.width*a.repeat.x,m=h.height*a.repeat.y,T=i/f,y=n/m;ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.translate(-i/2,-n/2),ee.scale(T,y),ee.translate(-u,-E),ee.fillRect(u,E,f,m),ee.restore()}else R(r.color.getStyle()),ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.scale(i,-n),ee.fillRect(-.5,-.5,1,1),ee.restore()}else r instanceof THREE.SpriteCanvasMaterial&&(g(r.color.getStyle()),R(r.color.getStyle()),ee.save(),ee.translate(e.x,e.y),0!==r.rotation&&ee.rotate(r.rotation),ee.scale(i,n),r.program(ee),ee.restore())}function n(e,t,r,i){if(p(i.opacity),d(i.blending),ee.beginPath(),ee.moveTo(e.positionScreen.x,e.positionScreen.y),ee.lineTo(t.positionScreen.x,t.positionScreen.y),i instanceof THREE.LineBasicMaterial){if(f(i.linewidth),m(i.linecap),T(i.linejoin),i.vertexColors!==THREE.VertexColors)g(i.color.getStyle());else{var n=r.vertexColors[0].getStyle(),o=r.vertexColors[1].getStyle();if(n===o)g(n);else{try{var a=ee.createLinearGradient(e.positionScreen.x,e.positionScreen.y,t.positionScreen.x,t.positionScreen.y);a.addColorStop(0,n),a.addColorStop(1,o)}catch(s){a=n}g(a)}}ee.stroke(),ge.expandByScalar(2*i.linewidth)}else i instanceof THREE.LineDashedMaterial&&(f(i.linewidth),m(i.linecap),T(i.linejoin),g(i.color.getStyle()),y([i.dashSize,i.gapSize]),ee.stroke(),ge.expandByScalar(2*i.linewidth),y([]))}function o(e,t,i,n,o,l,c,E){if(G.info.render.vertices+=3,G.info.render.faces++,p(E.opacity),d(E.blending),C=e.positionScreen.x,A=e.positionScreen.y,L=t.positionScreen.x,P=t.positionScreen.y,F=i.positionScreen.x,B=i.positionScreen.y,a(C,A,L,P,F,B),(E instanceof THREE.MeshLambertMaterial||E instanceof THREE.MeshPhongMaterial)&&null===E.map)Ee.copy(E.color),pe.copy(E.emissive),E.vertexColors===THREE.FaceColors&&Ee.multiply(c.color),ue.copy(Re),xe.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),r(xe,c.normalModel,ue),ue.multiply(Ee).add(pe),E.wireframe===!0?s(ue,E.wireframeLinewidth,E.wireframeLinecap,E.wireframeLinejoin):h(ue);else if(E instanceof THREE.MeshBasicMaterial||E instanceof THREE.MeshLambertMaterial||E instanceof THREE.MeshPhongMaterial)if(null!==E.map){var f=E.map.mapping;f===THREE.UVMapping&&(U=c.uvs,u(C,A,L,P,F,B,U[n].x,U[n].y,U[o].x,U[o].y,U[l].x,U[l].y,E.map))}else null!==E.envMap?E.envMap.mapping===THREE.SphericalReflectionMapping&&(be.copy(c.vertexNormalsModel[n]).applyMatrix3(we),D=.5*be.x+.5,V=.5*be.y+.5,be.copy(c.vertexNormalsModel[o]).applyMatrix3(we),z=.5*be.x+.5,k=.5*be.y+.5,be.copy(c.vertexNormalsModel[l]).applyMatrix3(we),N=.5*be.x+.5,O=.5*be.y+.5,u(C,A,L,P,F,B,D,V,z,k,N,O,E.envMap)):(ue.copy(E.color),E.vertexColors===THREE.FaceColors&&ue.multiply(c.color),E.wireframe===!0?s(ue,E.wireframeLinewidth,E.wireframeLinecap,E.wireframeLinejoin):h(ue));else E instanceof THREE.MeshDepthMaterial?(ue.r=ue.g=ue.b=1-v(e.positionScreen.z*e.positionScreen.w,w.near,w.far),E.wireframe===!0?s(ue,E.wireframeLinewidth,E.wireframeLinecap,E.wireframeLinejoin):h(ue)):E instanceof THREE.MeshNormalMaterial?(be.copy(c.normalModel).applyMatrix3(we),ue.setRGB(be.x,be.y,be.z).multiplyScalar(.5).addScalar(.5),E.wireframe===!0?s(ue,E.wireframeLinewidth,E.wireframeLinecap,E.wireframeLinejoin):h(ue)):(ue.setRGB(1,1,1),E.wireframe===!0?s(ue,E.wireframeLinewidth,E.wireframeLinecap,E.wireframeLinejoin):h(ue))}function a(e,t,r,i,n,o){ee.beginPath(),ee.moveTo(e,t),ee.lineTo(r,i),ee.lineTo(n,o),ee.closePath()}function s(e,t,r,i){f(t),m(r),T(i),g(e.getStyle()),ee.stroke(),ge.expandByScalar(2*t)}function h(e){R(e.getStyle()),ee.fill()}function l(e){c(e.target)}function c(e){if(!(e instanceof THREE.CompressedTexture)){var t=e.wrapS===THREE.RepeatWrapping,r=e.wrapT===THREE.RepeatWrapping,i=e.image,n=document.createElement("canvas");n.width=i.width,n.height=i.height;var o=n.getContext("2d");o.setTransform(1,0,0,-1,0,i.height),o.drawImage(i,0,0),fe[e.id]=ee.createPattern(n,t===!0&&r===!0?"repeat":t===!0&&r===!1?"repeat-x":t===!1&&r===!0?"repeat-y":"no-repeat")}}function u(e,t,r,i,n,o,a,s,h,u,E,p,d){if(!(d instanceof THREE.DataTexture)){d.hasEventListener("update",l)===!1&&(void 0!==d.image&&d.image.width>0&&c(d),d.addEventListener("update",l));var f=fe[d.id];if(void 0===f)return R("rgba(0,0,0,1)"),void ee.fill();R(f);var m,T,g,y,v,H,x,b,w=d.offset.x/d.repeat.x,_=d.offset.y/d.repeat.y,M=d.image.width*d.repeat.x,S=d.image.height*d.repeat.y;a=(a+w)*M,s=(s+_)*S,h=(h+w)*M,u=(u+_)*S,E=(E+w)*M,p=(p+_)*S,r-=e,i-=t,n-=e,o-=t,h-=a,u-=s,E-=a,p-=s,x=h*p-E*u,0!==x&&(b=1/x,m=(p*r-u*n)*b,T=(p*i-u*o)*b,g=(h*n-E*r)*b,y=(h*o-E*i)*b,v=e-m*a-g*s,H=t-T*a-y*s,ee.save(),ee.transform(m,T,g,y,v,H),ee.fill(),ee.restore())}}function E(e,t,r){var i,n=t.x-e.x,o=t.y-e.y,a=n*n+o*o;0!==a&&(i=r/Math.sqrt(a),n*=i,o*=i,t.x+=n,t.y+=o,e.x-=n,e.y-=o)}function p(e){ie!==e&&(ee.globalAlpha=e,ie=e)}function d(e){ne!==e&&(e===THREE.NormalBlending?ee.globalCompositeOperation="source-over":e===THREE.AdditiveBlending?ee.globalCompositeOperation="lighter":e===THREE.SubtractiveBlending&&(ee.globalCompositeOperation="darker"),ne=e)}function f(e){se!==e&&(ee.lineWidth=e,se=e)}function m(e){he!==e&&(ee.lineCap=e,he=e)}function T(e){le!==e&&(ee.lineJoin=e,le=e)}function g(e){oe!==e&&(ee.strokeStyle=e,oe=e)}function R(e){ae!==e&&(ee.fillStyle=e,ae=e)}function y(e){ce.length!==e.length&&(ee.setLineDash(e),ce=e)}console.log("THREE.CanvasRenderer",THREE.REVISION);var v=THREE.Math.smoothstep;e=e||{};var H,x,b,w,_,M,S,C,A,L,P,F,B,U,D,V,z,k,N,O,G=this,I=new THREE.Projector,W=void 0!==e.canvas?e.canvas:document.createElement("canvas"),j=W.width,X=W.height,q=Math.floor(j/2),Y=Math.floor(X/2),K=0,Q=0,Z=j,J=X,$=1,ee=W.getContext("2d",{alpha:e.alpha===!0}),te=new THREE.Color(0),re=e.alpha===!0?0:1,ie=1,ne=0,oe=null,ae=null,se=null,he=null,le=null,ce=[],ue=(new THREE.RenderableVertex,new THREE.RenderableVertex,new THREE.Color),Ee=(new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color),pe=new THREE.Color,de=new THREE.Color,fe={},me=new THREE.Box2,Te=new THREE.Box2,ge=new THREE.Box2,Re=new THREE.Color,ye=new THREE.Color,ve=new THREE.Color,He=new THREE.Vector3,xe=new THREE.Vector3,be=new THREE.Vector3,we=new THREE.Matrix3;void 0===ee.setLineDash&&(ee.setLineDash=function(){}),this.domElement=W,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.supportsVertexTextures=function(){},this.setFaceCulling=function(){},this.getPixelRatio=function(){return $},this.setPixelRatio=function(e){$=e},this.setSize=function(e,t,r){j=e*$,X=t*$,W.width=j,W.height=X,q=Math.floor(j/2),Y=Math.floor(X/2),r!==!1&&(W.style.width=e+"px",W.style.height=t+"px"),me.min.set(-q,-Y),me.max.set(q,Y),Te.min.set(-q,-Y),Te.max.set(q,Y),ie=1,ne=0,oe=null,ae=null,se=null,he=null,le=null,this.setViewport(0,0,e,t)},this.setViewport=function(e,t,r,i){K=e*$,Q=t*$,Z=r*$,J=i*$},this.setScissor=function(){},this.enableScissorTest=function(){},this.setClearColor=function(e,t){te.set(e),re=void 0!==t?t:1,Te.min.set(-q,-Y),Te.max.set(q,Y)},this.setClearColorHex=function(e,t){console.warn("THREE.CanvasRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(e,t)},this.getClearColor=function(){return te},this.getClearAlpha=function(){return re},this.getMaxAnisotropy=function(){return 0},this.clear=function(){Te.empty()===!1&&(Te.intersect(me),Te.expandByScalar(2),Te.min.x=Te.min.x+q,Te.min.y=-Te.min.y+Y,Te.max.x=Te.max.x+q,Te.max.y=-Te.max.y+Y,1>re&&ee.clearRect(0|Te.min.x,0|Te.max.y,Te.max.x-Te.min.x|0,Te.min.y-Te.max.y|0),re>0&&(d(THREE.NormalBlending),p(1),R("rgba("+Math.floor(255*te.r)+","+Math.floor(255*te.g)+","+Math.floor(255*te.b)+","+re+")"),ee.fillRect(0|Te.min.x,0|Te.max.y,Te.max.x-Te.min.x|0,Te.min.y-Te.max.y|0)),Te.makeEmpty())},this.clearColor=function(){},this.clearDepth=function(){},this.clearStencil=function(){},this.render=function(e,r){if(r instanceof THREE.Camera==!1)return void console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");this.autoClear===!0&&this.clear(),G.info.render.vertices=0,G.info.render.faces=0,ee.setTransform(Z/j,0,0,-J/X,K,X-Q),ee.translate(q,Y),H=I.projectScene(e,r,this.sortObjects,this.sortElements),x=H.elements,b=H.lights,w=r,we.getNormalMatrix(r.matrixWorldInverse),t();for(var a=0,s=x.length;s>a;a++){var h=x[a],l=h.material;if(void 0!==l&&0!==l.opacity){if(ge.makeEmpty(),h instanceof THREE.RenderableSprite)_=h,_.x*=q,_.y*=Y,i(_,h,l);else if(h instanceof THREE.RenderableLine)_=h.v1,M=h.v2,_.positionScreen.x*=q,_.positionScreen.y*=Y,M.positionScreen.x*=q,M.positionScreen.y*=Y,ge.setFromPoints([_.positionScreen,M.positionScreen]),me.isIntersectionBox(ge)===!0&&n(_,M,h,l);else if(h instanceof THREE.RenderableFace){if(_=h.v1,M=h.v2,S=h.v3,_.positionScreen.z<-1||_.positionScreen.z>1)continue;if(M.positionScreen.z<-1||M.positionScreen.z>1)continue;if(S.positionScreen.z<-1||S.positionScreen.z>1)continue;_.positionScreen.x*=q,_.positionScreen.y*=Y,M.positionScreen.x*=q,M.positionScreen.y*=Y,S.positionScreen.x*=q,S.positionScreen.y*=Y,l.overdraw>0&&(E(_.positionScreen,M.positionScreen,l.overdraw),E(M.positionScreen,S.positionScreen,l.overdraw),E(S.positionScreen,_.positionScreen,l.overdraw)),ge.setFromPoints([_.positionScreen,M.positionScreen,S.positionScreen]),me.isIntersectionBox(ge)===!0&&o(_,M,S,0,1,2,h,l)}Te.union(ge)}}ee.setTransform(1,0,0,1,0,0)}},THREE.RenderableObject=function(){this.id=0,this.object=null,this.z=0},THREE.RenderableFace=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0},THREE.RenderableVertex=function(){this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0},THREE.RenderableSprite=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null},THREE.Projector=function(){function e(){if(h===R){var e=new THREE.RenderableObject;return g.push(e),R++,h++,e}return g[h++]}function t(){if(c===v){var e=new THREE.RenderableVertex;return y.push(e),v++,c++,e}return y[c++]}function r(){if(E===x){var e=new THREE.RenderableFace;return H.push(e),x++,E++,e}return H[E++]}function i(){if(d===w){var e=new THREE.RenderableLine;return b.push(e),w++,d++,e}return b[d++]}function n(){if(m===M){var e=new THREE.RenderableSprite;return _.push(e),M++,m++,e}return _[m++]}function o(e,t){return e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function a(e,t){var r=0,i=1,n=e.z+e.w,o=t.z+t.w,a=-e.z+e.w,s=-t.z+t.w;return n>=0&&o>=0&&a>=0&&s>=0?!0:0>n&&0>o||0>a&&0>s?!1:(0>n?r=Math.max(r,n/(n-o)):0>o&&(i=Math.min(i,n/(n-o))),0>a?r=Math.max(r,a/(a-s)):0>s&&(i=Math.min(i,a/(a-s))),r>i?!1:(e.lerp(t,r),t.lerp(e,1-i),!0))}var s,h,l,c,u,E,p,d,f,m,T,g=[],R=0,y=[],v=0,H=[],x=0,b=[],w=0,_=[],M=0,S={objects:[],lights:[],elements:[]},C=new THREE.Vector3,A=new THREE.Vector4,L=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),P=new THREE.Box3,F=new Array(3),B=(new Array(4),new THREE.Matrix4),U=new THREE.Matrix4,D=new THREE.Matrix4,V=new THREE.Matrix3,z=new THREE.Frustum,k=new THREE.Vector4,N=new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(e,t){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")};var O=function(){var e=[],n=[],o=null,a=null,s=new THREE.Matrix3,h=function(t){o=t,a=o.material,s.getNormalMatrix(o.matrixWorld),e.length=0,n.length=0},c=function(e){var t=e.position,r=e.positionWorld,i=e.positionScreen;r.copy(t).applyMatrix4(T),i.copy(r).applyMatrix4(U);var n=1/i.w;i.x*=n,i.y*=n,i.z*=n,e.visible=i.x>=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1},E=function(e,r,i){l=t(),l.position.set(e,r,i),c(l)},d=function(t,r,i){e.push(t,r,i)},f=function(e,t){n.push(e,t)},m=function(e,t,r){return e.visible===!0||t.visible===!0||r.visible===!0?!0:(F[0]=e.positionScreen,F[1]=t.positionScreen,F[2]=r.positionScreen,L.isIntersectionBox(P.setFromPoints(F)))},g=function(e,t,r){return(r.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(r.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0},R=function(e,t){var r=y[e],n=y[t];p=i(),p.id=o.id,p.v1.copy(r),p.v2.copy(n),p.z=(r.positionScreen.z+n.positionScreen.z)/2,p.material=o.material,S.elements.push(p)},v=function(t,i,h){var l=y[t],c=y[i],E=y[h];if(m(l,c,E)!==!1&&(a.side===THREE.DoubleSide||g(l,c,E)===!0)){u=r(),u.id=o.id,u.v1.copy(l),u.v2.copy(c),u.v3.copy(E),u.z=(l.positionScreen.z+c.positionScreen.z+E.positionScreen.z)/3;for(var p=0;3>p;p++){var d=3*arguments[p],f=u.vertexNormalsModel[p];f.set(e[d],e[d+1],e[d+2]),f.applyMatrix3(s).normalize();var T=2*arguments[p],R=u.uvs[p];R.set(n[T],n[T+1])}u.vertexNormalsLength=3,u.material=o.material,S.elements.push(u)}};return{setObject:h,projectVertex:c,checkTriangleVisibility:m,checkBackfaceCulling:g,pushVertex:E,pushNormal:d,pushUv:f,pushLine:R,pushTriangle:v}},G=new O;this.projectScene=function(l,g,R,v){E=0,d=0,m=0,S.elements.length=0,l.autoUpdate===!0&&l.updateMatrixWorld(),void 0===g.parent&&g.updateMatrixWorld(),B.copy(g.matrixWorldInverse.getInverse(g.matrixWorld)),U.multiplyMatrices(g.projectionMatrix,B),z.setFromMatrix(U),h=0,S.objects.length=0,S.lights.length=0,l.traverseVisible(function(t){if(t instanceof THREE.Light)S.lights.push(t);else if(t instanceof THREE.Mesh||t instanceof THREE.Line||t instanceof THREE.Sprite){if(t.material.visible===!1)return;(t.frustumCulled===!1||z.intersectsObject(t)===!0)&&(s=e(),s.id=t.id,s.object=t,C.setFromMatrixPosition(t.matrixWorld),C.applyProjection(U),s.z=C.z,S.objects.push(s))}}),R===!0&&S.objects.sort(o);for(var H=0,x=S.objects.length;x>H;H++){var b=S.objects[H].object,w=b.geometry;if(G.setObject(b),T=b.matrixWorld,c=0,b instanceof THREE.Mesh){if(w instanceof THREE.BufferGeometry){var _=w.attributes,M=w.offsets;if(void 0===_.position)continue;for(var L=_.position.array,P=0,F=L.length;F>P;P+=3)G.pushVertex(L[P],L[P+1],L[P+2]);if(void 0!==_.normal)for(var O=_.normal.array,P=0,F=O.length;F>P;P+=3)G.pushNormal(O[P],O[P+1],O[P+2]);if(void 0!==_.uv)for(var I=_.uv.array,P=0,F=I.length;F>P;P+=2)G.pushUv(I[P],I[P+1]);if(void 0!==_.index){var W=_.index.array;if(M.length>0)for(var H=0;HP;P+=3)G.pushTriangle(W[P]+X,W[P+1]+X,W[P+2]+X);else for(var P=0,F=W.length;F>P;P+=3)G.pushTriangle(W[P],W[P+1],W[P+2])}else for(var P=0,F=L.length/3;F>P;P+=3)G.pushTriangle(P,P+1,P+2)}else if(w instanceof THREE.Geometry){var q=w.vertices,Y=w.faces,K=w.faceVertexUvs[0];V.getNormalMatrix(T);for(var Q=b.material,Z=Q instanceof THREE.MeshFaceMaterial,J=Z===!0?b.material:null,$=0,ee=q.length;ee>$;$++){var te=q[$];if(C.copy(te),Q.morphTargets===!0)for(var re=w.morphTargets,ie=b.morphTargetInfluences,ne=0,oe=re.length;oe>ne;ne++){var ae=ie[ne];if(0!==ae){var se=re[ne],he=se.vertices[$];C.x+=(he.x-te.x)*ae,C.y+=(he.y-te.y)*ae,C.z+=(he.z-te.z)*ae}}G.pushVertex(C.x,C.y,C.z)}for(var le=0,ce=Y.length;ce>le;le++){var ue=Y[le],Q=Z===!0?J.materials[ue.materialIndex]:b.material;if(void 0!==Q){var Ee=Q.side,pe=y[ue.a],de=y[ue.b],fe=y[ue.c];if(G.checkTriangleVisibility(pe,de,fe)!==!1){var me=G.checkBackfaceCulling(pe,de,fe);if(Ee!==THREE.DoubleSide){if(Ee===THREE.FrontSide&&me===!1)continue;if(Ee===THREE.BackSide&&me===!0)continue}u=r(),u.id=b.id,u.v1.copy(pe),u.v2.copy(de),u.v3.copy(fe),u.normalModel.copy(ue.normal),me!==!1||Ee!==THREE.BackSide&&Ee!==THREE.DoubleSide||u.normalModel.negate(),u.normalModel.applyMatrix3(V).normalize();for(var Te=ue.vertexNormals,ge=0,Re=Math.min(Te.length,3);Re>ge;ge++){var ye=u.vertexNormalsModel[ge];ye.copy(Te[ge]),me!==!1||Ee!==THREE.BackSide&&Ee!==THREE.DoubleSide||ye.negate(),ye.applyMatrix3(V).normalize()}u.vertexNormalsLength=Te.length;var ve=K[le];if(void 0!==ve)for(var He=0;3>He;He++)u.uvs[He].copy(ve[He]);u.color=ue.color,u.material=Q,u.z=(pe.positionScreen.z+de.positionScreen.z+fe.positionScreen.z)/3,S.elements.push(u)}}}}}else if(b instanceof THREE.Line){if(w instanceof THREE.BufferGeometry){var _=w.attributes;if(void 0!==_.position){for(var L=_.position.array,P=0,F=L.length;F>P;P+=3)G.pushVertex(L[P],L[P+1],L[P+2]);if(void 0!==_.index)for(var W=_.index.array,P=0,F=W.length;F>P;P+=2)G.pushLine(W[P],W[P+1]);else for(var xe=b.mode===THREE.LinePieces?2:1,P=0,F=L.length/3-1;F>P;P+=xe)G.pushLine(P,P+1)}}else if(w instanceof THREE.Geometry){D.multiplyMatrices(U,T);var q=b.geometry.vertices;if(0===q.length)continue;pe=t(),pe.positionScreen.copy(q[0]).applyMatrix4(D);for(var xe=b.mode===THREE.LinePieces?2:1,$=1,ee=q.length;ee>$;$++)pe=t(),pe.positionScreen.copy(q[$]).applyMatrix4(D),($+1)%xe>0||(de=y[c-2],k.copy(pe.positionScreen),N.copy(de.positionScreen),a(k,N)===!0&&(k.multiplyScalar(1/k.w),N.multiplyScalar(1/N.w),p=i(),p.id=b.id,p.v1.positionScreen.copy(k),p.v2.positionScreen.copy(N),p.z=Math.max(k.z,N.z),p.material=b.material,b.material.vertexColors===THREE.VertexColors&&(p.vertexColors[0].copy(b.geometry.colors[$]),p.vertexColors[1].copy(b.geometry.colors[$-1])),S.elements.push(p)))}}else if(b instanceof THREE.Sprite){A.set(T.elements[12],T.elements[13],T.elements[14],1),A.applyMatrix4(U);var be=1/A.w;A.z*=be,A.z>=-1&&A.z<=1&&(f=n(),f.id=b.id,f.x=A.x*be,f.y=A.y*be,f.z=A.z,f.object=b,f.rotation=b.rotation,f.scale.x=b.scale.x*Math.abs(f.x-(A.x+g.projectionMatrix.elements[0])/(A.w+g.projectionMatrix.elements[12])),f.scale.y=b.scale.y*Math.abs(f.y-(A.y+g.projectionMatrix.elements[5])/(A.w+g.projectionMatrix.elements[13])),f.material=b.material,S.elements.push(f))}}return v===!0&&S.elements.sort(o),S}},THREE.StereoEffect=function(e){var t=this;this.eyeSeparation=3,this.focalLength=15,Object.defineProperties(this,{separation:{get:function(){return t.eyeSeparation},set:function(e){console.warn("THREE.StereoEffect: .separation is now .eyeSeparation."),t.eyeSeparation=e}},targetDistance:{get:function(){return t.focalLength},set:function(e){console.warn("THREE.StereoEffect: .targetDistance is now .focalLength."),t.focalLength=e}}});var r,i,n,o,a,s,h,l,c,u,E,p,d=new THREE.Vector3,f=new THREE.Quaternion,m=new THREE.Vector3,T=new THREE.PerspectiveCamera,g=new THREE.PerspectiveCamera;e.autoClear=!1,this.setSize=function(t,n){r=t/2,i=n,e.setSize(t,n)},this.render=function(t,R){t.updateMatrixWorld(),void 0===R.parent&&R.updateMatrixWorld(),R.matrixWorld.decompose(d,f,m),n=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(R.fov))/R.zoom)),l=R.near/this.focalLength,u=Math.tan(.5*THREE.Math.degToRad(n))*this.focalLength,c=.5*u*R.aspect,s=u*l,h=-s,E=(c+this.eyeSeparation/2)/(2*c),p=1-E,o=2*c*l*p,a=2*c*l*E,T.projectionMatrix.makeFrustum(-o,a,h,s,R.near,R.far),T.position.copy(d),T.quaternion.copy(f),T.translateX(-this.eyeSeparation/2),g.projectionMatrix.makeFrustum(-a,o,h,s,R.near,R.far),g.position.copy(d),g.quaternion.copy(f),g.translateX(this.eyeSeparation/2),e.clear(),e.enableScissorTest(!0),e.setScissor(0,0,r,i),e.setViewport(0,0,r,i),e.render(t,T),e.setScissor(r,0,r,i),e.setViewport(r,0,r,i),e.render(t,g),e.enableScissorTest(!1)}}; \ No newline at end of file diff --git a/readme.txt b/readme.txt index 3b6306b..22c02de 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: Jeremy Heleine Tags: Google, Android, Photo Sphere, photos, panoramas, 360-degree, equirectangular Requires at least: 3.1 -Tested up to: 4.2.2 -Stable tag: 3.2.2 +Tested up to: 4.2.4 +Stable tag: 3.3 License: MIT License URI: http://opensource.org/licenses/MIT @@ -14,13 +14,15 @@ A filter that displays 360x180 degree panoramas. WP Photo Sphere is a filter that allows you to display 360x180 degree panoramas. With WP Photo Sphere, your visitors will be able to navigate through your panoramas without install any plugin. -WP Photo Sphere is based on the JavaScript library [Photo Sphere Viewer](http://jeremyheleine.me/#photo-sphere-viewer). +WP Photo Sphere is based on the JavaScript library [Photo Sphere Viewer](http://jeremyheleine.me/photo-sphere-viewer). This plugin allows you to display equirectangular panoramas, taken with a classic camera or with Photo Sphere on Android and iOS. If you want to contact me for any reason, feel free to email me at jeremy.heleine@gmail.com or contact me on: * Twitter: http://twitter.com/JeremyHeleine +* GitHub: https://github.com/JeremyHeleine +* LinkedIn: https://fr.linkedin.com/pub/j%C3%A9r%C3%A9my-heleine/55/a14/64a * Google+: https://plus.google.com/+JérémyHeleine * Facebook: https://www.facebook.com/jeremy.heleine @@ -102,6 +104,10 @@ also use the `min_fov` and `max_fov` attributes. == Changelog == += 3.3 = +* Gyroscope support +* Virtual reality support + = 3.2.2 = * Fixed: multiple panoramas on a single page @@ -167,6 +173,10 @@ also use the `min_fov` and `max_fov` attributes. == Upgrade Notice == += 3.3 = +* Gyroscope support +* Virtual reality support + = 3.2.2 = * Fixed: multiple panoramas on a single page diff --git a/wp-photo-sphere.js b/wp-photo-sphere.js index 6d0134c..718e121 100644 --- a/wp-photo-sphere.js +++ b/wp-photo-sphere.js @@ -1,6 +1,6 @@ /* - * This file is part of WP Photo Sphere v3.2.2 - * http://jeremyheleine.me/#wp-photo-sphere + * This file is part of WP Photo Sphere v3.3 + * http://jeremyheleine.me * * Copyright (c) 2013-2015 Jérémy Heleine * @@ -100,11 +100,11 @@ jQuery(function($) { max_fov: params.max_fov, zoom_level: params.zoom_level, default_position: { - long: params.long * Math.PI / 180.0, - lat: params.lat * Math.PI / 180.0 + long: params.long + 'deg', + lat: params.lat + 'deg' }, - tilt_up_max: params.tilt_up_max * Math.PI / 180.0, - tilt_down_max: params.tilt_down_max * Math.PI / 180.0, + tilt_up_max: params.tilt_up_max + 'deg', + tilt_down_max: params.tilt_down_max + 'deg', usexmpdata: params.xmp, size: {height: params.height} }; diff --git a/wp-photo-sphere.php b/wp-photo-sphere.php index fe971a0..6119365 100644 --- a/wp-photo-sphere.php +++ b/wp-photo-sphere.php @@ -1,7 +1,7 @@