├── .nvmrc ├── .gitignore ├── assets ├── earth.jpg └── style.css ├── app ├── components │ ├── app │ │ ├── app.html │ │ ├── app.ts │ │ ├── app.js.map │ │ └── app.js │ └── modifier │ │ ├── modifier.html │ │ ├── modifier.ts │ │ ├── modifier.js.map │ │ └── modifier.js ├── boot.js.map ├── boot.ts ├── boot.js └── services │ ├── renderService.ts │ ├── renderService.js.map │ └── renderService.js ├── tsconfig.json ├── typings ├── stats │ └── stats.d.ts ├── threejs │ └── three-trackballcontrols.d.ts ├── tween.js │ └── tween.js.d.ts ├── webrtc │ └── MediaStream.d.ts └── webaudioapi │ └── waa.d.ts ├── README.md ├── package.json ├── index-dist.html ├── index.html ├── vendor ├── stats.js ├── TrackballControls.js ├── tween.js └── touchpolyfill.js └── dist ├── shims_for_IE.js ├── system-polyfills.js └── es6-shim.min.js /.nvmrc: -------------------------------------------------------------------------------- 1 | v5 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /assets/earth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/christianliebel/angular2-3d-demo/HEAD/assets/earth.jpg -------------------------------------------------------------------------------- /app/components/app/app.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | -------------------------------------------------------------------------------- /app/boot.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"boot.js","sourceRoot":"","sources":["boot.ts"],"names":[],"mappings":"AAAA,qEAAqE;;;;;;;;;;;;;YAMrE,mBAAS,CAAC,kBAAY,EAAE,EAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /app/boot.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import {bootstrap} from 'angular2/platform/browser'; 4 | import {AppComponent} from './components/app/app'; 5 | import 'rxjs/Rx'; 6 | 7 | bootstrap(AppComponent, []); 8 | -------------------------------------------------------------------------------- /app/components/app/app.ts: -------------------------------------------------------------------------------- 1 | import {Component} from 'angular2/core'; 2 | import {ModifierComponent} from '../modifier/modifier'; 3 | 4 | @Component({ 5 | selector: 'my-app', 6 | templateUrl: 'app/components/app/app.html', 7 | directives: [ModifierComponent] 8 | }) 9 | export class AppComponent { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": false 11 | }, 12 | "exclude": [ 13 | "node_modules" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /app/components/app/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":["AppComponent","AppComponent.constructor"],"mappings":";;;;;;;;;;;;;;;;;;;;;YAGA;gBAAAA;gBAOAC,CAACA;gBAPDD;oBAACA,gBAASA,CAACA;wBACPA,QAAQA,EAAEA,QAAQA;wBAClBA,WAAWA,EAAEA,6BAA6BA;wBAC1CA,UAAUA,EAAEA,CAACA,4BAAiBA,CAACA;qBAClCA,CAACA;;iCAGDA;gBAADA,mBAACA;YAADA,CAACA,AAPD,IAOC;YAPD,uCAOC,CAAA"} -------------------------------------------------------------------------------- /assets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: "Helvetica Neue", "Segoe WP", Roboto, Helvetica, sans-serif; 4 | background: black; 5 | color: white; 6 | user-select: none; 7 | -ms-user-select: none; 8 | -webkit-user-select: none; 9 | overflow: hidden; 10 | } 11 | 12 | #modifier { 13 | height: 90px; 14 | margin: 10px; 15 | } 16 | 17 | #stats { 18 | position: absolute; 19 | bottom: 0; 20 | left: 0; 21 | } 22 | -------------------------------------------------------------------------------- /typings/stats/stats.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Stats.js r12 2 | // Project: http://github.com/mrdoob/stats.js 3 | // Definitions by: Gregory Dalton 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare class Stats { 7 | 8 | REVISION: number; 9 | 10 | domElement: HTMLDivElement; 11 | 12 | // 0: fps, 1: ms 13 | setMode(value: number): void; 14 | 15 | begin(): void; 16 | 17 | end(): number; 18 | 19 | update(): void; 20 | } -------------------------------------------------------------------------------- /app/components/modifier/modifier.html: -------------------------------------------------------------------------------- 1 |
2 |

Universe Configurator

3 | 7 |
8 | Stars: 9 | 10 | 11 | 12 |
13 |
14 | -------------------------------------------------------------------------------- /app/boot.js: -------------------------------------------------------------------------------- 1 | /// 2 | System.register(['angular2/platform/browser', './components/app/app', 'rxjs/Rx'], function(exports_1) { 3 | var browser_1, app_1; 4 | return { 5 | setters:[ 6 | function (browser_1_1) { 7 | browser_1 = browser_1_1; 8 | }, 9 | function (app_1_1) { 10 | app_1 = app_1_1; 11 | }, 12 | function (_1) {}], 13 | execute: function() { 14 | browser_1.bootstrap(app_1.AppComponent, []); 15 | } 16 | } 17 | }); 18 | //# sourceMappingURL=boot.js.map -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular 2 3D Demo 2 | 3 | Small demo showcase for integrating Angular 2 with WebGL 3D graphics powered by THREE.js. Please find [further reading on 3D and WebGL here](https://github.com/thinktecture/2d-3d-usergroup-2015). This is the Angular 2 version of [this original AngularJS 3D sample](https://github.com/chliebel/angular-3d-demo). 4 | 5 | ## Run it 6 | Clone this repository and run `npm i` followed by `npm start` — or just [click here](https://cdn.rawgit.com/christianliebel/angular2-3d-demo/1.1.0/index-dist.html). 7 | 8 | ## Credits 9 | Earth texture: NASA/Goddard Space Flight Center Scientific Visualization Studio The Blue Marble Next Generation data is courtesy of Reto Stockli (NASA/GSFC) and NASA's Earth Observatory. 10 | -------------------------------------------------------------------------------- /app/components/modifier/modifier.ts: -------------------------------------------------------------------------------- 1 | import {Component, Input} from 'angular2/core'; 2 | import {RenderService} from '../../services/renderService'; 3 | 4 | @Component({ 5 | selector: 'modifier', 6 | templateUrl: 'app/components/modifier/modifier.html', 7 | providers: [RenderService] 8 | }) 9 | export class ModifierComponent { 10 | public scale: number = 1; 11 | 12 | constructor(private _renderService: RenderService) { 13 | } 14 | 15 | @Input() 16 | public set container(value: HTMLElement) { 17 | if (value) 18 | this._renderService.init(value); 19 | } 20 | 21 | public addStars(stars: number) { 22 | this._renderService.addStars(stars); 23 | } 24 | 25 | public updateScale(newScale: number) { 26 | this._renderService.updateScale(newScale); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/components/modifier/modifier.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"modifier.js","sourceRoot":"","sources":["modifier.ts"],"names":["ModifierComponent","ModifierComponent.constructor","ModifierComponent.container","ModifierComponent.addStars","ModifierComponent.updateScale"],"mappings":";;;;;;;;;;;;;;;;;;;;;YAGA;gBAQIA,2BAAoBA,cAA6BA;oBAA7BC,mBAAcA,GAAdA,cAAcA,CAAeA;oBAF1CA,UAAKA,GAAWA,CAACA,CAACA;gBAGzBA,CAACA;gBAEDD,sBACWA,wCAASA;yBADpBA,UACqBA,KAAkBA;wBACnCE,EAAEA,CAACA,CAACA,KAAKA,CAACA;4BACNA,IAAIA,CAACA,cAAcA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA;oBACxCA,CAACA;;;mBAAAF;gBAEMA,oCAAQA,GAAfA,UAAgBA,KAAaA;oBACzBG,IAAIA,CAACA,cAAcA,CAACA,QAAQA,CAACA,KAAKA,CAACA,CAACA;gBACxCA,CAACA;gBAEMH,uCAAWA,GAAlBA,UAAmBA,QAAgBA;oBAC/BI,IAAIA,CAACA,cAAcA,CAACA,WAAWA,CAACA,QAAQA,CAACA,CAACA;gBAC9CA,CAACA;gBAZDJ;oBAACA,YAAKA,EAAEA;;;mBACGA,wCAASA,QAGnBA;gBAfLA;oBAACA,gBAASA,CAACA;wBACPA,QAAQA,EAAEA,UAAUA;wBACpBA,WAAWA,EAAEA,uCAAuCA;wBACpDA,SAASA,EAAEA,CAACA,6BAAaA,CAACA;qBAC7BA,CAACA;;sCAoBDA;gBAADA,wBAACA;YAADA,CAACA,AAxBD,IAwBC;YAxBD,iDAwBC,CAAA"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-3d-demo", 3 | "version": "1.1.0", 4 | "description": "Small demo showcase for integrating Angular 2 with WebGL 3D", 5 | "scripts": { 6 | "tsc": "tsc", 7 | "tsc:w": "tsc -w", 8 | "lite": "lite-server", 9 | "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/chliebel/angular2-3d-demo.git" 14 | }, 15 | "keywords": [ 16 | "angular2", 17 | "threejs", 18 | "webgl", 19 | "3d" 20 | ], 21 | "author": "Christian Liebel", 22 | "license": "UNLICENSED", 23 | "bugs": { 24 | "url": "https://github.com/chliebel/angular2-3d-demo/issues" 25 | }, 26 | "homepage": "https://github.com/chliebel/angular2-3d-demo#readme", 27 | "dependencies": { 28 | "angular2": "2.0.0-beta.8", 29 | "systemjs": "0.19.6", 30 | "es6-promise": "^3.0.2", 31 | "es6-shim": "^0.33.3", 32 | "reflect-metadata": "0.1.2", 33 | "rxjs": "5.0.0-beta.2", 34 | "zone.js": "0.5.15" 35 | }, 36 | "devDependencies": { 37 | "concurrently": "^1.0.0", 38 | "lite-server": "^1.3.4", 39 | "typescript": "^1.7.5" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /index-dist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Angular 2 3D Demo 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /typings/threejs/three-trackballcontrols.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for three.js (TrackballControls.js) 2 | // Project: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js 3 | // Definitions by: Satoru Kimura 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /// 7 | 8 | declare module THREE { 9 | class TrackballControls extends EventDispatcher { 10 | constructor(object:Camera, domElement?:HTMLElement); 11 | 12 | object:Camera; 13 | domElement:HTMLElement; 14 | 15 | // API 16 | enabled:boolean; 17 | screen:{ left: number; top: number; width: number; height: number }; 18 | rotateSpeed:number; 19 | zoomSpeed:number; 20 | panSpeed:number; 21 | noRotate:boolean; 22 | noZoom:boolean; 23 | noPan:boolean; 24 | noRoll:boolean; 25 | staticMoving:boolean; 26 | dynamicDampingFactor:number; 27 | minDistance:number; 28 | maxDistance:number; 29 | keys:number[]; 30 | 31 | update():void; 32 | reset():void; 33 | checkDistances():void; 34 | zoomCamera():void; 35 | panCamera():void; 36 | rotateCamera():void; 37 | 38 | handleResize():void; 39 | handleEvent(event: any):void; 40 | } 41 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Angular 2 3D Demo 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/components/app/app.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', '../modifier/modifier'], function(exports_1) { 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var core_1, modifier_1; 12 | var AppComponent; 13 | return { 14 | setters:[ 15 | function (core_1_1) { 16 | core_1 = core_1_1; 17 | }, 18 | function (modifier_1_1) { 19 | modifier_1 = modifier_1_1; 20 | }], 21 | execute: function() { 22 | AppComponent = (function () { 23 | function AppComponent() { 24 | } 25 | AppComponent = __decorate([ 26 | core_1.Component({ 27 | selector: 'my-app', 28 | templateUrl: 'app/components/app/app.html', 29 | directives: [modifier_1.ModifierComponent] 30 | }), 31 | __metadata('design:paramtypes', []) 32 | ], AppComponent); 33 | return AppComponent; 34 | })(); 35 | exports_1("AppComponent", AppComponent); 36 | } 37 | } 38 | }); 39 | //# sourceMappingURL=app.js.map -------------------------------------------------------------------------------- /typings/tween.js/tween.js.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for tween.js r12 2 | // Project: https://github.com/sole/tween.js/ 3 | // Definitions by: sunetos , jzarnikov 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | declare module TWEEN { 7 | export var REVISION: string; 8 | export function getAll(): Tween[]; 9 | export function removeAll(): void; 10 | export function add(tween:Tween): void; 11 | export function remove(tween:Tween): void; 12 | export function update(time?:number): boolean; 13 | 14 | export class Tween { 15 | constructor(object?:any); 16 | to(properties:any, duration:number): Tween; 17 | start(time?:number): Tween; 18 | stop(): Tween; 19 | delay(amount:number): Tween; 20 | easing(easing: (k: number) => number): Tween; 21 | interpolation(interpolation: (v:number[], k:number) => number): Tween; 22 | chain(...tweens:Tween[]): Tween; 23 | onStart(callback: (object?: any) => void): Tween; 24 | onUpdate(callback: (object?: any) => void): Tween; 25 | onComplete(callback: (object?: any) => void): Tween; 26 | update(time: number): boolean; 27 | repeat(times: number): Tween; 28 | yoyo(enable: boolean): Tween; 29 | } 30 | export var Easing: TweenEasing; 31 | export var Interpolation: TweenInterpolation; 32 | } 33 | 34 | interface TweenEasing { 35 | Linear: { 36 | None(k:number): number; 37 | }; 38 | Quadratic: { 39 | In(k:number): number; 40 | Out(k:number): number; 41 | InOut(k:number): number; 42 | }; 43 | Cubic: { 44 | In(k:number): number; 45 | Out(k:number): number; 46 | InOut(k:number): number; 47 | }; 48 | Quartic: { 49 | In(k:number): number; 50 | Out(k:number): number; 51 | InOut(k:number): number; 52 | }; 53 | Quintic: { 54 | In(k:number): number; 55 | Out(k:number): number; 56 | InOut(k:number): number; 57 | }; 58 | Sinusoidal: { 59 | In(k:number): number; 60 | Out(k:number): number; 61 | InOut(k:number): number; 62 | }; 63 | Exponential: { 64 | In(k:number): number; 65 | Out(k:number): number; 66 | InOut(k:number): number; 67 | }; 68 | Circular: { 69 | In(k:number): number; 70 | Out(k:number): number; 71 | InOut(k:number): number; 72 | }; 73 | Elastic: { 74 | In(k:number): number; 75 | Out(k:number): number; 76 | InOut(k:number): number; 77 | }; 78 | Back: { 79 | In(k:number): number; 80 | Out(k:number): number; 81 | InOut(k:number): number; 82 | }; 83 | Bounce: { 84 | In(k:number): number; 85 | Out(k:number): number; 86 | InOut(k:number): number; 87 | }; 88 | } 89 | 90 | interface TweenInterpolation { 91 | Linear(v:number[], k:number): number; 92 | Bezier(v:number[], k:number): number; 93 | CatmullRom(v:number[], k:number): number; 94 | 95 | Utils: { 96 | Linear(p0:number, p1:number, t:number): number; 97 | Bernstein(n:number, i:number): number; 98 | Factorial(n): number; 99 | }; 100 | } -------------------------------------------------------------------------------- /app/components/modifier/modifier.js: -------------------------------------------------------------------------------- 1 | System.register(['angular2/core', '../../services/renderService'], function(exports_1) { 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var core_1, renderService_1; 12 | var ModifierComponent; 13 | return { 14 | setters:[ 15 | function (core_1_1) { 16 | core_1 = core_1_1; 17 | }, 18 | function (renderService_1_1) { 19 | renderService_1 = renderService_1_1; 20 | }], 21 | execute: function() { 22 | ModifierComponent = (function () { 23 | function ModifierComponent(_renderService) { 24 | this._renderService = _renderService; 25 | this.scale = 1; 26 | } 27 | Object.defineProperty(ModifierComponent.prototype, "container", { 28 | set: function (value) { 29 | if (value) 30 | this._renderService.init(value); 31 | }, 32 | enumerable: true, 33 | configurable: true 34 | }); 35 | ModifierComponent.prototype.addStars = function (stars) { 36 | this._renderService.addStars(stars); 37 | }; 38 | ModifierComponent.prototype.updateScale = function (newScale) { 39 | this._renderService.updateScale(newScale); 40 | }; 41 | __decorate([ 42 | core_1.Input(), 43 | __metadata('design:type', HTMLElement), 44 | __metadata('design:paramtypes', [HTMLElement]) 45 | ], ModifierComponent.prototype, "container", null); 46 | ModifierComponent = __decorate([ 47 | core_1.Component({ 48 | selector: 'modifier', 49 | templateUrl: 'app/components/modifier/modifier.html', 50 | providers: [renderService_1.RenderService] 51 | }), 52 | __metadata('design:paramtypes', [renderService_1.RenderService]) 53 | ], ModifierComponent); 54 | return ModifierComponent; 55 | })(); 56 | exports_1("ModifierComponent", ModifierComponent); 57 | } 58 | } 59 | }); 60 | //# sourceMappingURL=modifier.js.map -------------------------------------------------------------------------------- /app/services/renderService.ts: -------------------------------------------------------------------------------- 1 | import WebGLRenderer = THREE.WebGLRenderer; 2 | import Scene = THREE.Scene; 3 | import TrackballControls = THREE.TrackballControls; 4 | import PerspectiveCamera = THREE.PerspectiveCamera; 5 | import Mesh = THREE.Mesh; 6 | 7 | export class RenderService { 8 | private stats: Stats; 9 | private scene: Scene; 10 | private camera: PerspectiveCamera; 11 | private renderer: WebGLRenderer; 12 | private controls: TrackballControls; 13 | private sphere: Mesh; 14 | 15 | public init(container: HTMLElement) { 16 | this.addStats(); 17 | 18 | const width = window.innerWidth; 19 | const height = window.innerHeight - 90; 20 | 21 | this.scene = new THREE.Scene(); 22 | this.camera = new THREE.PerspectiveCamera(45, width/height); 23 | this.camera.position.set(0, 0, 100); 24 | 25 | this.renderer = new THREE.WebGLRenderer({antialias: true}); 26 | this.renderer.setPixelRatio(window.devicePixelRatio); 27 | this.renderer.setSize(width, height); 28 | this.renderer.setClearColor(0x000000); 29 | 30 | container.appendChild(this.renderer.domElement); 31 | this.controls = new THREE.TrackballControls(this.camera, container); 32 | 33 | // Sphere 34 | const textureLoader = new THREE.TextureLoader(); 35 | textureLoader.setCrossOrigin('raw.githubusercontent.com'); // Required for RawGit demo, you can leave this out. 36 | textureLoader.load('assets/earth.jpg', t => { 37 | let geometry = new THREE.SphereGeometry(5, 50, 50); 38 | let material = new THREE.MeshLambertMaterial({map: t}); 39 | this.sphere = new THREE.Mesh(geometry, material); 40 | 41 | this.scene.add(this.sphere); 42 | }); 43 | 44 | // Lights 45 | const ambientLight = new THREE.AmbientLight(0xcccccc); 46 | this.scene.add(ambientLight); 47 | 48 | const pointLight = new THREE.PointLight(0xffffff); 49 | pointLight.position.set(300, 0, 300); 50 | this.scene.add(pointLight); 51 | 52 | // start animation 53 | this.animate(); 54 | 55 | // bind to window resizes 56 | window.addEventListener('resize', _ => this.onResize()); 57 | } 58 | 59 | public addStats() { 60 | this.stats = new Stats(); 61 | document.body.appendChild(this.stats.domElement); 62 | } 63 | 64 | public addStars(starsCount: number) { 65 | const stars = new THREE.Geometry(); 66 | const starMaterial = new THREE.PointCloudMaterial({color: 0xffffff}); 67 | 68 | for (let i = 0; i < starsCount; i++) { 69 | let x = Math.random() * 2000 - 1000; 70 | let y = Math.random() * 2000 - 1000; 71 | let z = Math.random() * 2000 - 1000; 72 | 73 | let star = new THREE.Vector3(x, y, z); 74 | 75 | stars.vertices.push(star); 76 | } 77 | 78 | let pointCloud = new THREE.PointCloud(stars, starMaterial); 79 | this.scene.add(pointCloud); 80 | } 81 | 82 | public updateScale(newScale: number) { 83 | const that = this; 84 | new TWEEN.Tween({scale: this.sphere.scale.x}) 85 | .to({scale: newScale}, 1000) 86 | .easing(TWEEN.Easing.Elastic.InOut) 87 | .onUpdate(function () { 88 | that.sphere.scale.set(this.scale, this.scale, this.scale); 89 | }) 90 | .start(); 91 | } 92 | 93 | public animate() { 94 | window.requestAnimationFrame(_ => this.animate()); 95 | 96 | this.stats.update(); 97 | this.controls.update(); 98 | TWEEN.update(); 99 | 100 | this.renderer.render(this.scene, this.camera); 101 | } 102 | 103 | public onResize() { 104 | const width = window.innerWidth; 105 | const height = window.innerHeight - 90; 106 | 107 | this.camera.aspect = width / height; 108 | this.camera.updateProjectionMatrix(); 109 | 110 | this.renderer.setSize(width, height); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /vendor/stats.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | var Stats = function () { 6 | 7 | var startTime = Date.now(), prevTime = startTime; 8 | var ms = 0, msMin = Infinity, msMax = 0; 9 | var fps = 0, fpsMin = Infinity, fpsMax = 0; 10 | var frames = 0, mode = 0; 11 | 12 | var container = document.createElement( 'div' ); 13 | container.id = 'stats'; 14 | container.addEventListener( 'mousedown', function ( event ) { event.preventDefault(); setMode( ++ mode % 2 ) }, false ); 15 | container.style.cssText = 'width:80px;opacity:0.9;cursor:pointer'; 16 | 17 | var fpsDiv = document.createElement( 'div' ); 18 | fpsDiv.id = 'fps'; 19 | fpsDiv.style.cssText = 'padding:0 0 3px 3px;text-align:left;background-color:#002'; 20 | container.appendChild( fpsDiv ); 21 | 22 | var fpsText = document.createElement( 'div' ); 23 | fpsText.id = 'fpsText'; 24 | fpsText.style.cssText = 'color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px'; 25 | fpsText.innerHTML = 'FPS'; 26 | fpsDiv.appendChild( fpsText ); 27 | 28 | var fpsGraph = document.createElement( 'div' ); 29 | fpsGraph.id = 'fpsGraph'; 30 | fpsGraph.style.cssText = 'position:relative;width:74px;height:30px;background-color:#0ff'; 31 | fpsDiv.appendChild( fpsGraph ); 32 | 33 | while ( fpsGraph.children.length < 74 ) { 34 | 35 | var bar = document.createElement( 'span' ); 36 | bar.style.cssText = 'width:1px;height:30px;float:left;background-color:#113'; 37 | fpsGraph.appendChild( bar ); 38 | 39 | } 40 | 41 | var msDiv = document.createElement( 'div' ); 42 | msDiv.id = 'ms'; 43 | msDiv.style.cssText = 'padding:0 0 3px 3px;text-align:left;background-color:#020;display:none'; 44 | container.appendChild( msDiv ); 45 | 46 | var msText = document.createElement( 'div' ); 47 | msText.id = 'msText'; 48 | msText.style.cssText = 'color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px'; 49 | msText.innerHTML = 'MS'; 50 | msDiv.appendChild( msText ); 51 | 52 | var msGraph = document.createElement( 'div' ); 53 | msGraph.id = 'msGraph'; 54 | msGraph.style.cssText = 'position:relative;width:74px;height:30px;background-color:#0f0'; 55 | msDiv.appendChild( msGraph ); 56 | 57 | while ( msGraph.children.length < 74 ) { 58 | 59 | var bar = document.createElement( 'span' ); 60 | bar.style.cssText = 'width:1px;height:30px;float:left;background-color:#131'; 61 | msGraph.appendChild( bar ); 62 | 63 | } 64 | 65 | var setMode = function ( value ) { 66 | 67 | mode = value; 68 | 69 | switch ( mode ) { 70 | 71 | case 0: 72 | fpsDiv.style.display = 'block'; 73 | msDiv.style.display = 'none'; 74 | break; 75 | case 1: 76 | fpsDiv.style.display = 'none'; 77 | msDiv.style.display = 'block'; 78 | break; 79 | } 80 | 81 | }; 82 | 83 | var updateGraph = function ( dom, value ) { 84 | 85 | var child = dom.appendChild( dom.firstChild ); 86 | child.style.height = value + 'px'; 87 | 88 | }; 89 | 90 | return { 91 | 92 | REVISION: 12, 93 | 94 | domElement: container, 95 | 96 | setMode: setMode, 97 | 98 | begin: function () { 99 | 100 | startTime = Date.now(); 101 | 102 | }, 103 | 104 | end: function () { 105 | 106 | var time = Date.now(); 107 | 108 | ms = time - startTime; 109 | msMin = Math.min( msMin, ms ); 110 | msMax = Math.max( msMax, ms ); 111 | 112 | msText.textContent = ms + ' MS (' + msMin + '-' + msMax + ')'; 113 | updateGraph( msGraph, Math.min( 30, 30 - ( ms / 200 ) * 30 ) ); 114 | 115 | frames ++; 116 | 117 | if ( time > prevTime + 1000 ) { 118 | 119 | fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) ); 120 | fpsMin = Math.min( fpsMin, fps ); 121 | fpsMax = Math.max( fpsMax, fps ); 122 | 123 | fpsText.textContent = fps + ' FPS (' + fpsMin + '-' + fpsMax + ')'; 124 | updateGraph( fpsGraph, Math.min( 30, 30 - ( fps / 100 ) * 30 ) ); 125 | 126 | prevTime = time; 127 | frames = 0; 128 | 129 | } 130 | 131 | return time; 132 | 133 | }, 134 | 135 | update: function () { 136 | 137 | startTime = this.end(); 138 | 139 | } 140 | 141 | } 142 | 143 | }; 144 | 145 | if ( typeof module === 'object' ) { 146 | 147 | module.exports = Stats; 148 | 149 | } -------------------------------------------------------------------------------- /app/services/renderService.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"renderService.js","sourceRoot":"","sources":["renderService.ts"],"names":["RenderService","RenderService.constructor","RenderService.init","RenderService.addStats","RenderService.addStars","RenderService.updateScale","RenderService.animate","RenderService.onResize"],"mappings":";QAAO,aAAa,EACb,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,IAAI;;;;YAEX;gBAAAA;gBAyGAC,CAACA;gBAjGUD,4BAAIA,GAAXA,UAAYA,SAAsBA;oBAAlCE,iBA0CCA;oBAzCGA,IAAIA,CAACA,QAAQA,EAAEA,CAACA;oBAEhBA,IAAMA,KAAKA,GAAGA,MAAMA,CAACA,UAAUA,CAACA;oBAChCA,IAAMA,MAAMA,GAAGA,MAAMA,CAACA,WAAWA,GAAGA,EAAEA,CAACA;oBAEvCA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,KAAKA,CAACA,KAAKA,EAAEA,CAACA;oBAC/BA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,KAAKA,CAACA,iBAAiBA,CAACA,EAAEA,EAAEA,KAAKA,GAACA,MAAMA,CAACA,CAACA;oBAC5DA,IAAIA,CAACA,MAAMA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,EAAEA,CAACA,EAAEA,GAAGA,CAACA,CAACA;oBAEpCA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,KAAKA,CAACA,aAAaA,CAACA,EAACA,SAASA,EAAEA,IAAIA,EAACA,CAACA,CAACA;oBAC3DA,IAAIA,CAACA,QAAQA,CAACA,aAAaA,CAACA,MAAMA,CAACA,gBAAgBA,CAACA,CAACA;oBACrDA,IAAIA,CAACA,QAAQA,CAACA,OAAOA,CAACA,KAAKA,EAAEA,MAAMA,CAACA,CAACA;oBACrCA,IAAIA,CAACA,QAAQA,CAACA,aAAaA,CAACA,QAAQA,CAACA,CAACA;oBAEtCA,SAASA,CAACA,WAAWA,CAACA,IAAIA,CAACA,QAAQA,CAACA,UAAUA,CAACA,CAACA;oBAChDA,IAAIA,CAACA,QAAQA,GAAGA,IAAIA,KAAKA,CAACA,iBAAiBA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;oBAEpEA,SAASA;oBACTA,IAAMA,aAAaA,GAAGA,IAAIA,KAAKA,CAACA,aAAaA,EAAEA,CAACA;oBAChDA,aAAaA,CAACA,cAAcA,CAACA,2BAA2BA,CAACA,CAACA,CAACA,oDAAoDA;oBAC/GA,aAAaA,CAACA,IAAIA,CAACA,kBAAkBA,EAAEA,UAAAA,CAACA;wBACpCA,IAAIA,QAAQA,GAAGA,IAAIA,KAAKA,CAACA,cAAcA,CAACA,CAACA,EAAEA,EAAEA,EAAEA,EAAEA,CAACA,CAACA;wBACnDA,IAAIA,QAAQA,GAAGA,IAAIA,KAAKA,CAACA,mBAAmBA,CAACA,EAACA,GAAGA,EAAEA,CAACA,EAACA,CAACA,CAACA;wBACvDA,KAAIA,CAACA,MAAMA,GAAGA,IAAIA,KAAKA,CAACA,IAAIA,CAACA,QAAQA,EAAEA,QAAQA,CAACA,CAACA;wBAEjDA,KAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,KAAIA,CAACA,MAAMA,CAACA,CAACA;oBAChCA,CAACA,CAACA,CAACA;oBAEHA,SAASA;oBACTA,IAAMA,YAAYA,GAAGA,IAAIA,KAAKA,CAACA,YAAYA,CAACA,QAAQA,CAACA,CAACA;oBACtDA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,YAAYA,CAACA,CAACA;oBAE7BA,IAAMA,UAAUA,GAAGA,IAAIA,KAAKA,CAACA,UAAUA,CAACA,QAAQA,CAACA,CAACA;oBAClDA,UAAUA,CAACA,QAAQA,CAACA,GAAGA,CAACA,GAAGA,EAAEA,CAACA,EAAEA,GAAGA,CAACA,CAACA;oBACrCA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,UAAUA,CAACA,CAACA;oBAE3BA,kBAAkBA;oBAClBA,IAAIA,CAACA,OAAOA,EAAEA,CAACA;oBAEfA,yBAAyBA;oBACzBA,MAAMA,CAACA,gBAAgBA,CAACA,QAAQA,EAAEA,UAAAA,CAACA,IAAIA,OAAAA,KAAIA,CAACA,QAAQA,EAAEA,EAAfA,CAAeA,CAACA,CAACA;gBAC5DA,CAACA;gBAEMF,gCAAQA,GAAfA;oBACIG,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,KAAKA,EAAEA,CAACA;oBACzBA,QAAQA,CAACA,IAAIA,CAACA,WAAWA,CAACA,IAAIA,CAACA,KAAKA,CAACA,UAAUA,CAACA,CAACA;gBACrDA,CAACA;gBAEMH,gCAAQA,GAAfA,UAAgBA,UAAkBA;oBAC9BI,IAAMA,KAAKA,GAAGA,IAAIA,KAAKA,CAACA,QAAQA,EAAEA,CAACA;oBACnCA,IAAMA,YAAYA,GAAGA,IAAIA,KAAKA,CAACA,kBAAkBA,CAACA,EAACA,KAAKA,EAAEA,QAAQA,EAACA,CAACA,CAACA;oBAErEA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,UAAUA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;wBAClCA,IAAIA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,GAAGA,IAAIA,GAAGA,IAAIA,CAACA;wBACpCA,IAAIA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,GAAGA,IAAIA,GAAGA,IAAIA,CAACA;wBACpCA,IAAIA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,EAAEA,GAAGA,IAAIA,GAAGA,IAAIA,CAACA;wBAEpCA,IAAIA,IAAIA,GAAGA,IAAIA,KAAKA,CAACA,OAAOA,CAACA,CAACA,EAAEA,CAACA,EAAEA,CAACA,CAACA,CAACA;wBAEtCA,KAAKA,CAACA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA;oBAC9BA,CAACA;oBAEDA,IAAIA,UAAUA,GAAGA,IAAIA,KAAKA,CAACA,UAAUA,CAACA,KAAKA,EAAEA,YAAYA,CAACA,CAACA;oBAC3DA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,UAAUA,CAACA,CAACA;gBAC/BA,CAACA;gBAEMJ,mCAAWA,GAAlBA,UAAmBA,QAAgBA;oBAC/BK,IAAMA,IAAIA,GAAGA,IAAIA,CAACA;oBAClBA,IAAIA,KAAKA,CAACA,KAAKA,CAACA,EAACA,KAAKA,EAAEA,IAAIA,CAACA,MAAMA,CAACA,KAAKA,CAACA,CAACA,EAACA,CAACA;yBACxCA,EAAEA,CAACA,EAACA,KAAKA,EAAEA,QAAQA,EAACA,EAAEA,IAAIA,CAACA;yBAC3BA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,CAACA,OAAOA,CAACA,KAAKA,CAACA;yBAClCA,QAAQA,CAACA;wBACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC9D,CAAC,CAACA;yBACDA,KAAKA,EAAEA,CAACA;gBACjBA,CAACA;gBAEML,+BAAOA,GAAdA;oBAAAM,iBAQCA;oBAPGA,MAAMA,CAACA,qBAAqBA,CAACA,UAAAA,CAACA,IAAIA,OAAAA,KAAIA,CAACA,OAAOA,EAAEA,EAAdA,CAAcA,CAACA,CAACA;oBAElDA,IAAIA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,CAACA;oBACpBA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA;oBACvBA,KAAKA,CAACA,MAAMA,EAAEA,CAACA;oBAEfA,IAAIA,CAACA,QAAQA,CAACA,MAAMA,CAACA,IAAIA,CAACA,KAAKA,EAAEA,IAAIA,CAACA,MAAMA,CAACA,CAACA;gBAClDA,CAACA;gBAEMN,gCAAQA,GAAfA;oBACIO,IAAMA,KAAKA,GAAGA,MAAMA,CAACA,UAAUA,CAACA;oBAChCA,IAAMA,MAAMA,GAAGA,MAAMA,CAACA,WAAWA,GAAGA,EAAEA,CAACA;oBAEvCA,IAAIA,CAACA,MAAMA,CAACA,MAAMA,GAAGA,KAAKA,GAAGA,MAAMA,CAACA;oBACpCA,IAAIA,CAACA,MAAMA,CAACA,sBAAsBA,EAAEA,CAACA;oBAErCA,IAAIA,CAACA,QAAQA,CAACA,OAAOA,CAACA,KAAKA,EAAEA,MAAMA,CAACA,CAACA;gBACzCA,CAACA;gBACLP,oBAACA;YAADA,CAACA,AAzGD,IAyGC;YAzGD,yCAyGC,CAAA"} -------------------------------------------------------------------------------- /app/services/renderService.js: -------------------------------------------------------------------------------- 1 | System.register([], function(exports_1) { 2 | var WebGLRenderer, Scene, TrackballControls, PerspectiveCamera, Mesh, RenderService; 3 | return { 4 | setters:[], 5 | execute: function() { 6 | RenderService = (function () { 7 | function RenderService() { 8 | } 9 | RenderService.prototype.init = function (container) { 10 | var _this = this; 11 | this.addStats(); 12 | var width = window.innerWidth; 13 | var height = window.innerHeight - 90; 14 | this.scene = new THREE.Scene(); 15 | this.camera = new THREE.PerspectiveCamera(45, width / height); 16 | this.camera.position.set(0, 0, 100); 17 | this.renderer = new THREE.WebGLRenderer({ antialias: true }); 18 | this.renderer.setPixelRatio(window.devicePixelRatio); 19 | this.renderer.setSize(width, height); 20 | this.renderer.setClearColor(0x000000); 21 | container.appendChild(this.renderer.domElement); 22 | this.controls = new THREE.TrackballControls(this.camera, container); 23 | // Sphere 24 | var textureLoader = new THREE.TextureLoader(); 25 | textureLoader.setCrossOrigin('raw.githubusercontent.com'); // Required for RawGit demo, you can leave this out. 26 | textureLoader.load('assets/earth.jpg', function (t) { 27 | var geometry = new THREE.SphereGeometry(5, 50, 50); 28 | var material = new THREE.MeshLambertMaterial({ map: t }); 29 | _this.sphere = new THREE.Mesh(geometry, material); 30 | _this.scene.add(_this.sphere); 31 | }); 32 | // Lights 33 | var ambientLight = new THREE.AmbientLight(0xcccccc); 34 | this.scene.add(ambientLight); 35 | var pointLight = new THREE.PointLight(0xffffff); 36 | pointLight.position.set(300, 0, 300); 37 | this.scene.add(pointLight); 38 | // start animation 39 | this.animate(); 40 | // bind to window resizes 41 | window.addEventListener('resize', function (_) { return _this.onResize(); }); 42 | }; 43 | RenderService.prototype.addStats = function () { 44 | this.stats = new Stats(); 45 | document.body.appendChild(this.stats.domElement); 46 | }; 47 | RenderService.prototype.addStars = function (starsCount) { 48 | var stars = new THREE.Geometry(); 49 | var starMaterial = new THREE.PointCloudMaterial({ color: 0xffffff }); 50 | for (var i = 0; i < starsCount; i++) { 51 | var x = Math.random() * 2000 - 1000; 52 | var y = Math.random() * 2000 - 1000; 53 | var z = Math.random() * 2000 - 1000; 54 | var star = new THREE.Vector3(x, y, z); 55 | stars.vertices.push(star); 56 | } 57 | var pointCloud = new THREE.PointCloud(stars, starMaterial); 58 | this.scene.add(pointCloud); 59 | }; 60 | RenderService.prototype.updateScale = function (newScale) { 61 | var that = this; 62 | new TWEEN.Tween({ scale: this.sphere.scale.x }) 63 | .to({ scale: newScale }, 1000) 64 | .easing(TWEEN.Easing.Elastic.InOut) 65 | .onUpdate(function () { 66 | that.sphere.scale.set(this.scale, this.scale, this.scale); 67 | }) 68 | .start(); 69 | }; 70 | RenderService.prototype.animate = function () { 71 | var _this = this; 72 | window.requestAnimationFrame(function (_) { return _this.animate(); }); 73 | this.stats.update(); 74 | this.controls.update(); 75 | TWEEN.update(); 76 | this.renderer.render(this.scene, this.camera); 77 | }; 78 | RenderService.prototype.onResize = function () { 79 | var width = window.innerWidth; 80 | var height = window.innerHeight - 90; 81 | this.camera.aspect = width / height; 82 | this.camera.updateProjectionMatrix(); 83 | this.renderer.setSize(width, height); 84 | }; 85 | return RenderService; 86 | })(); 87 | exports_1("RenderService", RenderService); 88 | } 89 | } 90 | }); 91 | //# sourceMappingURL=renderService.js.map -------------------------------------------------------------------------------- /typings/webrtc/MediaStream.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for WebRTC 2 | // Project: http://dev.w3.org/2011/webrtc/ 3 | // Definitions by: Ken Smith 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | // Taken from http://dev.w3.org/2011/webrtc/editor/getusermedia.html 7 | // version: W3C Editor's Draft 29 June 2015 8 | 9 | interface ConstrainBooleanParameters { 10 | exact?: boolean; 11 | ideal?: boolean; 12 | } 13 | 14 | interface NumberRange { 15 | max?: number; 16 | min?: number; 17 | } 18 | 19 | interface ConstrainNumberRange extends NumberRange { 20 | exact?: number; 21 | ideal?: number; 22 | } 23 | 24 | interface ConstrainStringParameters { 25 | exact?: string | string[]; 26 | ideal?: string | string[]; 27 | } 28 | 29 | interface MediaStreamConstraints { 30 | video?: boolean | MediaTrackConstraints; 31 | audio?: boolean | MediaTrackConstraints; 32 | } 33 | 34 | declare module W3C { 35 | type LongRange = NumberRange; 36 | type DoubleRange = NumberRange; 37 | type ConstrainBoolean = boolean | ConstrainBooleanParameters; 38 | type ConstrainNumber = number | ConstrainNumberRange; 39 | type ConstrainLong = ConstrainNumber; 40 | type ConstrainDouble = ConstrainNumber; 41 | type ConstrainString = string | string[] | ConstrainStringParameters; 42 | } 43 | 44 | interface MediaTrackConstraints extends MediaTrackConstraintSet { 45 | advanced?: MediaTrackConstraintSet[]; 46 | } 47 | 48 | interface MediaTrackConstraintSet { 49 | width?: W3C.ConstrainLong; 50 | height?: W3C.ConstrainLong; 51 | aspectRatio?: W3C.ConstrainDouble; 52 | frameRate?: W3C.ConstrainDouble; 53 | facingMode?: W3C.ConstrainString; 54 | volume?: W3C.ConstrainDouble; 55 | sampleRate?: W3C.ConstrainLong; 56 | sampleSize?: W3C.ConstrainLong; 57 | echoCancellation?: W3C.ConstrainBoolean; 58 | latency?: W3C.ConstrainDouble; 59 | deviceId?: W3C.ConstrainString; 60 | groupId?: W3C.ConstrainString; 61 | } 62 | 63 | interface MediaTrackSupportedConstraints { 64 | width?: boolean; 65 | height?: boolean; 66 | aspectRatio?: boolean; 67 | frameRate?: boolean; 68 | facingMode?: boolean; 69 | volume?: boolean; 70 | sampleRate?: boolean; 71 | sampleSize?: boolean; 72 | echoCancellation?: boolean; 73 | latency?: boolean; 74 | deviceId?: boolean; 75 | groupId?: boolean; 76 | } 77 | 78 | interface MediaStream extends EventTarget { 79 | id: string; 80 | active: boolean; 81 | 82 | onactive: EventListener; 83 | oninactive: EventListener; 84 | onaddtrack: (event: MediaStreamTrackEvent) => any; 85 | onremovetrack: (event: MediaStreamTrackEvent) => any; 86 | 87 | clone(): MediaStream; 88 | stop(): void; 89 | 90 | getAudioTracks(): MediaStreamTrack[]; 91 | getVideoTracks(): MediaStreamTrack[]; 92 | getTracks(): MediaStreamTrack[]; 93 | 94 | getTrackById(trackId: string): MediaStreamTrack; 95 | 96 | addTrack(track: MediaStreamTrack): void; 97 | removeTrack(track: MediaStreamTrack): void; 98 | } 99 | 100 | interface MediaStreamTrackEvent extends Event { 101 | track: MediaStreamTrack; 102 | } 103 | 104 | declare enum MediaStreamTrackState { 105 | "live", 106 | "ended" 107 | } 108 | 109 | interface MediaStreamTrack extends EventTarget { 110 | id: string; 111 | kind: string; 112 | label: string; 113 | enabled: boolean; 114 | muted: boolean; 115 | remote: boolean; 116 | readyState: MediaStreamTrackState; 117 | 118 | onmute: EventListener; 119 | onunmute: EventListener; 120 | onended: EventListener; 121 | onoverconstrained: EventListener; 122 | 123 | clone(): MediaStreamTrack; 124 | 125 | stop(): void; 126 | 127 | getCapabilities(): MediaTrackCapabilities; 128 | getConstraints(): MediaTrackConstraints; 129 | getSettings(): MediaTrackSettings; 130 | applyConstraints(constraints: MediaTrackConstraints): Promise; 131 | } 132 | 133 | interface MediaTrackCapabilities { 134 | width: number | W3C.LongRange; 135 | height: number | W3C.LongRange; 136 | aspectRatio: number | W3C.DoubleRange; 137 | frameRate: number | W3C.DoubleRange; 138 | facingMode: string; 139 | volume: number | W3C.DoubleRange; 140 | sampleRate: number | W3C.LongRange; 141 | sampleSize: number | W3C.LongRange; 142 | echoCancellation: boolean[]; 143 | latency: number | W3C.DoubleRange; 144 | deviceId: string; 145 | groupId: string; 146 | } 147 | 148 | interface MediaTrackSettings { 149 | width: number; 150 | height: number; 151 | aspectRatio: number; 152 | frameRate: number; 153 | facingMode: string; 154 | volume: number; 155 | sampleRate: number; 156 | sampleSize: number; 157 | echoCancellation: boolean; 158 | latency: number; 159 | deviceId: string; 160 | groupId: string; 161 | } 162 | 163 | interface MediaStreamError { 164 | name: string; 165 | message: string; 166 | constraintName: string; 167 | } 168 | 169 | interface NavigatorGetUserMedia { 170 | (constraints: MediaStreamConstraints, 171 | successCallback: (stream: MediaStream) => void, 172 | errorCallback: (error: MediaStreamError) => void): void; 173 | } 174 | 175 | // to use with adapter.js, see: https://github.com/webrtc/adapter 176 | declare var getUserMedia: NavigatorGetUserMedia; 177 | 178 | interface Navigator { 179 | getUserMedia: NavigatorGetUserMedia; 180 | 181 | webkitGetUserMedia: NavigatorGetUserMedia; 182 | 183 | mozGetUserMedia: NavigatorGetUserMedia; 184 | 185 | msGetUserMedia: NavigatorGetUserMedia; 186 | 187 | mediaDevices: MediaDevices; 188 | } 189 | 190 | interface MediaDevices { 191 | getSupportedConstraints(): MediaTrackSupportedConstraints; 192 | 193 | getUserMedia(constraints: MediaStreamConstraints): Promise; 194 | enumerateDevices(): Promise; 195 | } 196 | 197 | interface MediaDeviceInfo { 198 | label: string; 199 | id: string; 200 | kind: string; 201 | facing: string; 202 | } 203 | -------------------------------------------------------------------------------- /dist/shims_for_IE.js: -------------------------------------------------------------------------------- 1 | // function.name (all IE) 2 | /*! @source http://stackoverflow.com/questions/6903762/function-name-not-supported-in-ie*/ 3 | if (!Object.hasOwnProperty('name')) { 4 | Object.defineProperty(Function.prototype, 'name', { 5 | get: function() { 6 | var matches = this.toString().match(/^\s*function\s*(\S*)\s*\(/); 7 | var name = matches && matches.length > 1 ? matches[1] : ""; 8 | // For better performance only parse once, and then cache the 9 | // result through a new accessor for repeated access. 10 | Object.defineProperty(this, 'name', {value: name}); 11 | return name; 12 | } 13 | }); 14 | } 15 | 16 | // URL polyfill for SystemJS (all IE) 17 | /*! @source https://github.com/ModuleLoader/es6-module-loader/blob/master/src/url-polyfill.js*/ 18 | // from https://gist.github.com/Yaffle/1088850 19 | (function(global) { 20 | function URLPolyfill(url, baseURL) { 21 | if (typeof url != 'string') { 22 | throw new TypeError('URL must be a string'); 23 | } 24 | var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); 25 | if (!m) { 26 | throw new RangeError(); 27 | } 28 | var protocol = m[1] || ""; 29 | var username = m[2] || ""; 30 | var password = m[3] || ""; 31 | var host = m[4] || ""; 32 | var hostname = m[5] || ""; 33 | var port = m[6] || ""; 34 | var pathname = m[7] || ""; 35 | var search = m[8] || ""; 36 | var hash = m[9] || ""; 37 | if (baseURL !== undefined) { 38 | var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL); 39 | var flag = protocol === "" && host === "" && username === ""; 40 | if (flag && pathname === "" && search === "") { 41 | search = base.search; 42 | } 43 | if (flag && pathname.charAt(0) !== "/") { 44 | pathname = (pathname !== "" ? (((base.host !== "" || base.username !== "") && base.pathname === "" ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname); 45 | } 46 | // dot segments removal 47 | var output = []; 48 | pathname.replace(/^(\.\.?(\/|$))+/, "") 49 | .replace(/\/(\.(\/|$))+/g, "/") 50 | .replace(/\/\.\.$/, "/../") 51 | .replace(/\/?[^\/]*/g, function (p) { 52 | if (p === "/..") { 53 | output.pop(); 54 | } else { 55 | output.push(p); 56 | } 57 | }); 58 | pathname = output.join("").replace(/^\//, pathname.charAt(0) === "/" ? "/" : ""); 59 | if (flag) { 60 | port = base.port; 61 | hostname = base.hostname; 62 | host = base.host; 63 | password = base.password; 64 | username = base.username; 65 | } 66 | if (protocol === "") { 67 | protocol = base.protocol; 68 | } 69 | } 70 | 71 | // convert windows file URLs to use / 72 | if (protocol == 'file:') 73 | pathname = pathname.replace(/\\/g, '/'); 74 | 75 | this.origin = protocol + (protocol !== "" || host !== "" ? "//" : "") + host; 76 | this.href = protocol + (protocol !== "" || host !== "" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash; 77 | this.protocol = protocol; 78 | this.username = username; 79 | this.password = password; 80 | this.host = host; 81 | this.hostname = hostname; 82 | this.port = port; 83 | this.pathname = pathname; 84 | this.search = search; 85 | this.hash = hash; 86 | } 87 | global.URLPolyfill = URLPolyfill; 88 | })(typeof self != 'undefined' ? self : global); 89 | 90 | //classList (IE9) 91 | /*! @license please refer to http://unlicense.org/ */ 92 | /*! @author Eli Grey */ 93 | /*! @source https://github.com/eligrey/classList.js */ 94 | ;if("document" in self&&!("classList" in document.createElement("_"))){(function(j){"use strict";if(!("Element" in j)){return}var a="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;p, Kon , kubosho 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | // 6 | // This file refers to the latest published working draft (currently from 10 october 2013) http://www.w3.org/TR/2013/WD-webaudio-20131010/, not to be confused with the latest editor's draft http://webaudio.github.io/web-audio-api/ 7 | 8 | // DEPRECATED: use TypeScript 1.5.3 9 | 10 | /// 11 | 12 | declare var webkitAudioContext: { 13 | new (): AudioContext; 14 | } 15 | 16 | declare var webkitOfflineAudioContext: { 17 | new (numberOfChannels: number, length: number, sampleRate: number): OfflineAudioContext; 18 | } 19 | 20 | declare enum ChannelCountMode { 21 | 'max', 22 | 'clamped-max', 23 | 'explicit' 24 | } 25 | 26 | declare enum ChannelInterpretation { 27 | speakers, 28 | discrete 29 | } 30 | 31 | declare enum PanningModelType { 32 | /** 33 | * A simple and efficient spatialization algorithm using equal-power panning. 34 | */ 35 | equalpower, 36 | 37 | /** 38 | * A higher quality spatialization algorithm using a convolution with measured impulse responses from human subjects. This panning method renders stereo output. 39 | */ 40 | HRTF 41 | } 42 | 43 | declare enum DistanceModelType { 44 | /** 45 | * A linear distance model which calculates distanceGain according to: 46 | * 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance) 47 | */ 48 | linear, 49 | 50 | /** 51 | * An inverse distance model which calculates distanceGain according to: 52 | * refDistance / (refDistance + rolloffFactor * (distance - refDistance)) 53 | */ 54 | inverse, 55 | 56 | /** 57 | * An exponential distance model which calculates distanceGain according to: 58 | * pow(distance / refDistance, -rolloffFactor) 59 | */ 60 | exponential 61 | } 62 | 63 | declare enum BiquadFilterType { 64 | /** 65 | * A lowpass filter allows frequencies below the cutoff frequency to pass through and attenuates frequencies above the cutoff. It implements a standard second-order resonant lowpass filter with 12dB/octave rolloff. 66 | * 67 | * ## frequency 68 | * The cutoff frequency 69 | * ## Q 70 | * Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels. 71 | * ## gain 72 | * Not used in this filter type 73 | */ 74 | lowpass, 75 | 76 | /** 77 | * A highpass filter is the opposite of a lowpass filter. Frequencies above the cutoff frequency are passed through, but frequencies below the cutoff are attenuated. It implements a standard second-order resonant highpass filter with 12dB/octave rolloff. 78 | * 79 | * ## frequency 80 | * The cutoff frequency below which the frequencies are attenuated 81 | * ## Q 82 | * Controls how peaked the response will be at the cutoff frequency. A large value makes the response more peaked. Please note that for this filter type, this value is not a traditional Q, but is a resonance value in decibels. 83 | * ## gain 84 | * Not used in this filter type 85 | */ 86 | highpass, 87 | 88 | /** 89 | * A bandpass filter allows a range of frequencies to pass through and attenuates the frequencies below and above this frequency range. It implements a second-order bandpass filter. 90 | * 91 | * ## frequency 92 | * The center of the frequency band 93 | * ## Q 94 | * Controls the width of the band. The width becomes narrower as the Q value increases. 95 | * ## gain 96 | * Not used in this filter type 97 | */ 98 | bandpass, 99 | 100 | /** 101 | * The lowshelf filter allows all frequencies through, but adds a boost (or attenuation) to the lower frequencies. It implements a second-order lowshelf filter. 102 | * 103 | * ## frequency 104 | * The upper limit of the frequences where the boost (or attenuation) is applied. 105 | * ## Q 106 | * Not used in this filter type. 107 | * ## gain 108 | * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. 109 | */ 110 | lowshelf, 111 | 112 | /** 113 | * The highshelf filter is the opposite of the lowshelf filter and allows all frequencies through, but adds a boost to the higher frequencies. It implements a second-order highshelf filter 114 | * 115 | * ## frequency 116 | * The lower limit of the frequences where the boost (or attenuation) is applied. 117 | * ## Q 118 | * Not used in this filter type. 119 | * ## gain 120 | * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. 121 | */ 122 | highshelf, 123 | 124 | /** 125 | * The peaking filter allows all frequencies through, but adds a boost (or attenuation) to a range of frequencies. 126 | * 127 | * ## frequency 128 | * The center frequency of where the boost is applied. 129 | * ## Q 130 | * Controls the width of the band of frequencies that are boosted. A large value implies a narrow width. 131 | * ## gain 132 | * The boost, in dB, to be applied. If the value is negative, the frequencies are attenuated. 133 | */ 134 | peaking, 135 | 136 | /** 137 | * The notch filter (also known as a band-stop or band-rejection filter) is the opposite of a bandpass filter. It allows all frequencies through, except for a set of frequencies. 138 | * 139 | * ## frequency 140 | * The center frequency of where the notch is applied. 141 | * ## Q 142 | * Controls the width of the band of frequencies that are attenuated. A large value implies a narrow width. 143 | * ## gain 144 | * Not used in this filter type. 145 | */ 146 | notch, 147 | 148 | /** 149 | * An allpass filter allows all frequencies through, but changes the phase relationship between the various frequencies. It implements a second-order allpass filter 150 | * 151 | * ## frequency 152 | * The frequency where the center of the phase transition occurs. Viewed another way, this is the frequency with maximal group delay. 153 | * ## Q 154 | * Controls how sharp the phase transition is at the center frequency. A larger value implies a sharper transition and a larger group delay. 155 | * ## gain 156 | * Not used in this filter type. 157 | */ 158 | allpass 159 | } 160 | 161 | declare enum OverSampleType { 162 | 'none', 163 | '2x', 164 | '4x' 165 | } 166 | 167 | declare enum OscillatorType { 168 | sine, 169 | square, 170 | sawtooth, 171 | triangle, 172 | custom 173 | } 174 | 175 | interface AudioContextConstructor { 176 | new(): AudioContext; 177 | } 178 | 179 | interface Window { 180 | AudioContext: AudioContextConstructor; 181 | } 182 | 183 | interface AudioContext { 184 | createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode; 185 | } 186 | 187 | interface MediaStreamAudioSourceNode extends AudioNode { 188 | 189 | } 190 | 191 | interface AudioBuffer { 192 | copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; 193 | 194 | copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; 195 | } 196 | 197 | interface AudioNode { 198 | disconnect(destination: AudioNode): void; 199 | } 200 | 201 | interface AudioContext { 202 | suspend(): Promise; 203 | resume(): Promise; 204 | close(): Promise; 205 | } 206 | -------------------------------------------------------------------------------- /dist/system-polyfills.js: -------------------------------------------------------------------------------- 1 | /* 2 | * SystemJS Polyfills for URL and Promise providing IE8+ Support 3 | */ 4 | !function(t){!function(t){function e(t,n){if("string"!=typeof t)throw new TypeError("URL must be a string");var o=String(t).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);if(!o)throw new RangeError;var r=o[1]||"",i=o[2]||"",u=o[3]||"",c=o[4]||"",s=o[5]||"",f=o[6]||"",a=o[7]||"",h=o[8]||"",p=o[9]||"";if(void 0!==n){var l=n instanceof e?n:new e(n),d=""===r&&""===c&&""===i;d&&""===a&&""===h&&(h=l.search),d&&"/"!==a.charAt(0)&&(a=""!==a?(""===l.host&&""===l.username||""!==l.pathname?"":"/")+l.pathname.slice(0,l.pathname.lastIndexOf("/")+1)+a:l.pathname);var y=[];a.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(t){"/.."===t?y.pop():y.push(t)}),a=y.join("").replace(/^\//,"/"===a.charAt(0)?"/":""),d&&(f=l.port,s=l.hostname,c=l.host,u=l.password,i=l.username),""===r&&(r=l.protocol)}"file:"==r&&(a=a.replace(/\\/g,"/")),this.origin=r+(""!==r||""!==c?"//":"")+c,this.href=r+(""!==r||""!==c?"//":"")+(""!==i?i+(""!==u?":"+u:"")+"@":"")+c+a+h+p,this.protocol=r,this.username=i,this.password=u,this.host=c,this.hostname=s,this.port=f,this.pathname=a,this.search=h,this.hash=p}t.URLPolyfill=e}("undefined"!=typeof self?self:global),!function(e){"object"==typeof exports?module.exports=e():"function"==typeof t&&t.amd?t(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var t;return function e(t,n,o){function r(u,c){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!c&&s)return s(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return r(n?n:e)},f,f.exports,e,t,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u=0&&(l.splice(e,1),h("Handled previous rejection ["+t.id+"] "+r.formatObject(t.value)))}function c(t,e){p.push(t,e),null===d&&(d=o(s,0))}function s(){for(d=null;p.length>0;)p.shift()(p.shift())}var f,a=n,h=n;"undefined"!=typeof console&&(f=console,a="undefined"!=typeof f.error?function(t){f.error(t)}:function(t){f.log(t)},h="undefined"!=typeof f.info?function(t){f.info(t)}:function(t){f.log(t)}),t.onPotentiallyUnhandledRejection=function(t){c(i,t)},t.onPotentiallyUnhandledRejectionHandled=function(t){c(u,t)},t.onFatalRejection=function(t){c(e,t.value)};var p=[],l=[],d=null;return t}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t(e)})},{"../env":5,"../format":6}],5:[function(e,n,o){!function(t){"use strict";t(function(t){function e(){return"undefined"!=typeof process&&null!==process&&"function"==typeof process.nextTick}function n(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function o(t){function e(){var t=n;n=void 0,t()}var n,o=document.createTextNode(""),r=new t(e);r.observe(o,{characterData:!0});var i=0;return function(t){n=t,o.data=i^=1}}var r,i="undefined"!=typeof setTimeout&&setTimeout,u=function(t,e){return setTimeout(t,e)},c=function(t){return clearTimeout(t)},s=function(t){return i(t,0)};if(e())s=function(t){return process.nextTick(t)};else if(r=n())s=o(r);else if(!i){var f=t,a=f("vertx");u=function(t,e){return a.setTimer(e,t)},c=a.cancelTimer,s=a.runOnLoop||a.runOnContext}return{setTimer:u,clearTimer:c,asap:s}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t(e)})},{}],6:[function(e,n,o){!function(t){"use strict";t(function(){function t(t){var n="object"==typeof t&&null!==t&&t.stack?t.stack:e(t);return t instanceof Error?n:n+" (WARNING: non-Error used)"}function e(t){var e=String(t);return"[object Object]"===e&&"undefined"!=typeof JSON&&(e=n(t,e)),e}function n(t,e){try{return JSON.stringify(t)}catch(n){return e}}return{formatError:t,formatObject:e,tryStringify:n}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t()})},{}],7:[function(e,n,o){!function(t){"use strict";t(function(){return function(t){function e(t,e){this._handler=t===j?e:n(t)}function n(t){function e(t){r.resolve(t)}function n(t){r.reject(t)}function o(t){r.notify(t)}var r=new b;try{t(e,n,o)}catch(i){n(i)}return r}function o(t){return k(t)?t:new e(j,new x(v(t)))}function r(t){return new e(j,new x(new q(t)))}function i(){return Z}function u(){return new e(j,new b)}function c(t,e){var n=new b(t.receiver,t.join().context);return new e(j,n)}function s(t){return a(z,null,t)}function f(t,e){return a(J,t,e)}function a(t,n,o){function r(e,r,u){u.resolved||h(o,i,e,t(n,r,e),u)}function i(t,e,n){a[t]=e,0===--f&&n.become(new R(a))}for(var u,c="function"==typeof n?r:i,s=new b,f=o.length>>>0,a=new Array(f),p=0;p0?e(n,i.value,r):(r.become(i),p(t,n+1,i))}else e(n,o,r)}function p(t,e,n){for(var o=e;on&&t._unreport()}}function d(t){return"object"!=typeof t||null===t?r(new TypeError("non-iterable passed to race()")):0===t.length?i():1===t.length?o(t[0]):y(t)}function y(t){var n,o,r,i=new b;for(n=0;n0||"function"!=typeof e&&0>r)return new this.constructor(j,o);var i=this._beget(),u=i._handler;return o.chain(u,o.receiver,t,e,n),i},e.prototype["catch"]=function(t){return this.then(void 0,t)},e.prototype._beget=function(){return c(this._handler,this.constructor)},e.all=s,e.race=d,e._traverse=f,e._visitRemaining=p,j.prototype.when=j.prototype.become=j.prototype.notify=j.prototype.fail=j.prototype._unreport=j.prototype._report=B,j.prototype._state=0,j.prototype.state=function(){return this._state},j.prototype.join=function(){for(var t=this;void 0!==t.handler;)t=t.handler;return t},j.prototype.chain=function(t,e,n,o,r){this.when({resolver:t,receiver:e,fulfilled:n,rejected:o,progress:r})},j.prototype.visit=function(t,e,n,o){this.chain(V,t,e,n,o)},j.prototype.fold=function(t,e,n,o){this.when(new S(t,e,n,o))},W(j,_),_.prototype.become=function(t){t.fail()};var V=new _;W(j,b),b.prototype._state=0,b.prototype.resolve=function(t){this.become(v(t))},b.prototype.reject=function(t){this.resolved||this.become(new q(t))},b.prototype.join=function(){if(!this.resolved)return this;for(var t=this;void 0!==t.handler;)if(t=t.handler,t===this)return this.handler=T();return t},b.prototype.run=function(){var t=this.consumers,e=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var n=0;n 0.0 ) { 220 | 221 | _eye.multiplyScalar( factor ); 222 | 223 | if ( _this.staticMoving ) { 224 | 225 | _zoomStart.copy( _zoomEnd ); 226 | 227 | } else { 228 | 229 | _zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor; 230 | 231 | } 232 | 233 | } 234 | 235 | } 236 | 237 | }; 238 | 239 | this.panCamera = (function() { 240 | 241 | var mouseChange = new THREE.Vector2(), 242 | objectUp = new THREE.Vector3(), 243 | pan = new THREE.Vector3(); 244 | 245 | return function () { 246 | 247 | mouseChange.copy( _panEnd ).sub( _panStart ); 248 | 249 | if ( mouseChange.lengthSq() ) { 250 | 251 | mouseChange.multiplyScalar( _eye.length() * _this.panSpeed ); 252 | 253 | pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x ); 254 | pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) ); 255 | 256 | _this.object.position.add( pan ); 257 | _this.target.add( pan ); 258 | 259 | if ( _this.staticMoving ) { 260 | 261 | _panStart.copy( _panEnd ); 262 | 263 | } else { 264 | 265 | _panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) ); 266 | 267 | } 268 | 269 | } 270 | }; 271 | 272 | }()); 273 | 274 | this.checkDistances = function () { 275 | 276 | if ( !_this.noZoom || !_this.noPan ) { 277 | 278 | if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) { 279 | 280 | _this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) ); 281 | 282 | } 283 | 284 | if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) { 285 | 286 | _this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) ); 287 | 288 | } 289 | 290 | } 291 | 292 | }; 293 | 294 | this.update = function () { 295 | 296 | _eye.subVectors( _this.object.position, _this.target ); 297 | 298 | if ( !_this.noRotate ) { 299 | 300 | _this.rotateCamera(); 301 | 302 | } 303 | 304 | if ( !_this.noZoom ) { 305 | 306 | _this.zoomCamera(); 307 | 308 | } 309 | 310 | if ( !_this.noPan ) { 311 | 312 | _this.panCamera(); 313 | 314 | } 315 | 316 | _this.object.position.addVectors( _this.target, _eye ); 317 | 318 | _this.checkDistances(); 319 | 320 | _this.object.lookAt( _this.target ); 321 | 322 | if ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) { 323 | 324 | _this.dispatchEvent( changeEvent ); 325 | 326 | lastPosition.copy( _this.object.position ); 327 | 328 | } 329 | 330 | }; 331 | 332 | this.reset = function () { 333 | 334 | _state = STATE.NONE; 335 | _prevState = STATE.NONE; 336 | 337 | _this.target.copy( _this.target0 ); 338 | _this.object.position.copy( _this.position0 ); 339 | _this.object.up.copy( _this.up0 ); 340 | 341 | _eye.subVectors( _this.object.position, _this.target ); 342 | 343 | _this.object.lookAt( _this.target ); 344 | 345 | _this.dispatchEvent( changeEvent ); 346 | 347 | lastPosition.copy( _this.object.position ); 348 | 349 | }; 350 | 351 | // listeners 352 | 353 | function keydown( event ) { 354 | 355 | if ( _this.enabled === false ) return; 356 | 357 | window.removeEventListener( 'keydown', keydown ); 358 | 359 | _prevState = _state; 360 | 361 | if ( _state !== STATE.NONE ) { 362 | 363 | return; 364 | 365 | } else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && !_this.noRotate ) { 366 | 367 | _state = STATE.ROTATE; 368 | 369 | } else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && !_this.noZoom ) { 370 | 371 | _state = STATE.ZOOM; 372 | 373 | } else if ( event.keyCode === _this.keys[ STATE.PAN ] && !_this.noPan ) { 374 | 375 | _state = STATE.PAN; 376 | 377 | } 378 | 379 | } 380 | 381 | function keyup( event ) { 382 | 383 | if ( _this.enabled === false ) return; 384 | 385 | _state = _prevState; 386 | 387 | window.addEventListener( 'keydown', keydown, false ); 388 | 389 | } 390 | 391 | function mousedown( event ) { 392 | 393 | if ( _this.enabled === false ) return; 394 | 395 | event.preventDefault(); 396 | event.stopPropagation(); 397 | 398 | if ( _state === STATE.NONE ) { 399 | 400 | _state = event.button; 401 | 402 | } 403 | 404 | if ( _state === STATE.ROTATE && !_this.noRotate ) { 405 | 406 | _moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) ); 407 | _movePrev.copy(_moveCurr); 408 | 409 | } else if ( _state === STATE.ZOOM && !_this.noZoom ) { 410 | 411 | _zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) ); 412 | _zoomEnd.copy(_zoomStart); 413 | 414 | } else if ( _state === STATE.PAN && !_this.noPan ) { 415 | 416 | _panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) ); 417 | _panEnd.copy(_panStart); 418 | 419 | } 420 | 421 | document.addEventListener( 'mousemove', mousemove, false ); 422 | document.addEventListener( 'mouseup', mouseup, false ); 423 | 424 | _this.dispatchEvent( startEvent ); 425 | 426 | } 427 | 428 | function mousemove( event ) { 429 | 430 | if ( _this.enabled === false ) return; 431 | 432 | event.preventDefault(); 433 | event.stopPropagation(); 434 | 435 | if ( _state === STATE.ROTATE && !_this.noRotate ) { 436 | 437 | _movePrev.copy(_moveCurr); 438 | _moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) ); 439 | 440 | } else if ( _state === STATE.ZOOM && !_this.noZoom ) { 441 | 442 | _zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) ); 443 | 444 | } else if ( _state === STATE.PAN && !_this.noPan ) { 445 | 446 | _panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) ); 447 | 448 | } 449 | 450 | } 451 | 452 | function mouseup( event ) { 453 | 454 | if ( _this.enabled === false ) return; 455 | 456 | event.preventDefault(); 457 | event.stopPropagation(); 458 | 459 | _state = STATE.NONE; 460 | 461 | document.removeEventListener( 'mousemove', mousemove ); 462 | document.removeEventListener( 'mouseup', mouseup ); 463 | _this.dispatchEvent( endEvent ); 464 | 465 | } 466 | 467 | function mousewheel( event ) { 468 | 469 | if ( _this.enabled === false ) return; 470 | 471 | event.preventDefault(); 472 | event.stopPropagation(); 473 | 474 | var delta = 0; 475 | 476 | if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9 477 | 478 | delta = event.wheelDelta / 40; 479 | 480 | } else if ( event.detail ) { // Firefox 481 | 482 | delta = - event.detail / 3; 483 | 484 | } 485 | 486 | _zoomStart.y += delta * 0.01; 487 | _this.dispatchEvent( startEvent ); 488 | _this.dispatchEvent( endEvent ); 489 | 490 | } 491 | 492 | function touchstart( event ) { 493 | 494 | if ( _this.enabled === false ) return; 495 | 496 | switch ( event.touches.length ) { 497 | 498 | case 1: 499 | _state = STATE.TOUCH_ROTATE; 500 | _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); 501 | _movePrev.copy(_moveCurr); 502 | break; 503 | 504 | case 2: 505 | _state = STATE.TOUCH_ZOOM_PAN; 506 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 507 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 508 | _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy ); 509 | 510 | var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2; 511 | var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2; 512 | _panStart.copy( getMouseOnScreen( x, y ) ); 513 | _panEnd.copy( _panStart ); 514 | break; 515 | 516 | default: 517 | _state = STATE.NONE; 518 | 519 | } 520 | _this.dispatchEvent( startEvent ); 521 | 522 | 523 | } 524 | 525 | function touchmove( event ) { 526 | 527 | if ( _this.enabled === false ) return; 528 | 529 | event.preventDefault(); 530 | event.stopPropagation(); 531 | 532 | switch ( event.touches.length ) { 533 | 534 | case 1: 535 | _movePrev.copy(_moveCurr); 536 | _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); 537 | break; 538 | 539 | case 2: 540 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 541 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 542 | _touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy ); 543 | 544 | var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2; 545 | var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2; 546 | _panEnd.copy( getMouseOnScreen( x, y ) ); 547 | break; 548 | 549 | default: 550 | _state = STATE.NONE; 551 | 552 | } 553 | 554 | } 555 | 556 | function touchend( event ) { 557 | 558 | if ( _this.enabled === false ) return; 559 | 560 | switch ( event.touches.length ) { 561 | 562 | case 1: 563 | _movePrev.copy(_moveCurr); 564 | _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); 565 | break; 566 | 567 | case 2: 568 | _touchZoomDistanceStart = _touchZoomDistanceEnd = 0; 569 | 570 | var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2; 571 | var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2; 572 | _panEnd.copy( getMouseOnScreen( x, y ) ); 573 | _panStart.copy( _panEnd ); 574 | break; 575 | 576 | } 577 | 578 | _state = STATE.NONE; 579 | _this.dispatchEvent( endEvent ); 580 | 581 | } 582 | 583 | this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false ); 584 | 585 | this.domElement.addEventListener( 'mousedown', mousedown, false ); 586 | 587 | this.domElement.addEventListener( 'mousewheel', mousewheel, false ); 588 | this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox 589 | 590 | this.domElement.addEventListener( 'touchstart', touchstart, false ); 591 | this.domElement.addEventListener( 'touchend', touchend, false ); 592 | this.domElement.addEventListener( 'touchmove', touchmove, false ); 593 | 594 | window.addEventListener( 'keydown', keydown, false ); 595 | window.addEventListener( 'keyup', keyup, false ); 596 | 597 | this.handleResize(); 598 | 599 | // force an update at start 600 | this.update(); 601 | 602 | }; 603 | 604 | THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype ); 605 | THREE.TrackballControls.prototype.constructor = THREE.TrackballControls; -------------------------------------------------------------------------------- /vendor/tween.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Tween.js - Licensed under the MIT license 3 | * https://github.com/sole/tween.js 4 | * ---------------------------------------------- 5 | * 6 | * See https://github.com/sole/tween.js/graphs/contributors for the full list of contributors. 7 | * Thank you all, you're awesome! 8 | */ 9 | 10 | // performance.now polyfill 11 | ( function ( root ) { 12 | 13 | if ( 'performance' in root === false ) { 14 | root.performance = {}; 15 | } 16 | 17 | // IE 8 18 | Date.now = ( Date.now || function () { 19 | return new Date().getTime(); 20 | } ); 21 | 22 | if ( 'now' in root.performance === false ) { 23 | var offset = root.performance.timing && root.performance.timing.navigationStart ? performance.timing.navigationStart 24 | : Date.now(); 25 | 26 | root.performance.now = function () { 27 | return Date.now() - offset; 28 | }; 29 | } 30 | 31 | } )( this ); 32 | 33 | var TWEEN = TWEEN || ( function () { 34 | 35 | var _tweens = []; 36 | 37 | return { 38 | 39 | REVISION: '14', 40 | 41 | getAll: function () { 42 | 43 | return _tweens; 44 | 45 | }, 46 | 47 | removeAll: function () { 48 | 49 | _tweens = []; 50 | 51 | }, 52 | 53 | add: function ( tween ) { 54 | 55 | _tweens.push( tween ); 56 | 57 | }, 58 | 59 | remove: function ( tween ) { 60 | 61 | var i = _tweens.indexOf( tween ); 62 | 63 | if ( i !== -1 ) { 64 | 65 | _tweens.splice( i, 1 ); 66 | 67 | } 68 | 69 | }, 70 | 71 | update: function ( time ) { 72 | 73 | if ( _tweens.length === 0 ) return false; 74 | 75 | var i = 0; 76 | 77 | time = time !== undefined ? time : window.performance.now(); 78 | 79 | while ( i < _tweens.length ) { 80 | 81 | if ( _tweens[ i ].update( time ) ) { 82 | 83 | i++; 84 | 85 | } else { 86 | 87 | _tweens.splice( i, 1 ); 88 | 89 | } 90 | 91 | } 92 | 93 | return true; 94 | 95 | } 96 | }; 97 | 98 | } )(); 99 | 100 | TWEEN.Tween = function ( object ) { 101 | 102 | var _object = object; 103 | var _valuesStart = {}; 104 | var _valuesEnd = {}; 105 | var _valuesStartRepeat = {}; 106 | var _duration = 1000; 107 | var _repeat = 0; 108 | var _yoyo = false; 109 | var _isPlaying = false; 110 | var _reversed = false; 111 | var _delayTime = 0; 112 | var _startTime = null; 113 | var _easingFunction = TWEEN.Easing.Linear.None; 114 | var _interpolationFunction = TWEEN.Interpolation.Linear; 115 | var _chainedTweens = []; 116 | var _onStartCallback = null; 117 | var _onStartCallbackFired = false; 118 | var _onUpdateCallback = null; 119 | var _onCompleteCallback = null; 120 | var _onStopCallback = null; 121 | 122 | // Set all starting values present on the target object 123 | for ( var field in object ) { 124 | 125 | _valuesStart[ field ] = parseFloat(object[field], 10); 126 | 127 | } 128 | 129 | this.to = function ( properties, duration ) { 130 | 131 | if ( duration !== undefined ) { 132 | 133 | _duration = duration; 134 | 135 | } 136 | 137 | _valuesEnd = properties; 138 | 139 | return this; 140 | 141 | }; 142 | 143 | this.start = function ( time ) { 144 | 145 | TWEEN.add( this ); 146 | 147 | _isPlaying = true; 148 | 149 | _onStartCallbackFired = false; 150 | 151 | _startTime = time !== undefined ? time : window.performance.now(); 152 | _startTime += _delayTime; 153 | 154 | for ( var property in _valuesEnd ) { 155 | 156 | // check if an Array was provided as property value 157 | if ( _valuesEnd[ property ] instanceof Array ) { 158 | 159 | if ( _valuesEnd[ property ].length === 0 ) { 160 | 161 | continue; 162 | 163 | } 164 | 165 | // create a local copy of the Array with the start value at the front 166 | _valuesEnd[ property ] = [ _object[ property ] ].concat( _valuesEnd[ property ] ); 167 | 168 | } 169 | 170 | _valuesStart[ property ] = _object[ property ]; 171 | 172 | if( ( _valuesStart[ property ] instanceof Array ) === false ) { 173 | _valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings 174 | } 175 | 176 | _valuesStartRepeat[ property ] = _valuesStart[ property ] || 0; 177 | 178 | } 179 | 180 | return this; 181 | 182 | }; 183 | 184 | this.stop = function () { 185 | 186 | if ( !_isPlaying ) { 187 | return this; 188 | } 189 | 190 | TWEEN.remove( this ); 191 | _isPlaying = false; 192 | 193 | if ( _onStopCallback !== null ) { 194 | 195 | _onStopCallback.call( _object ); 196 | 197 | } 198 | 199 | this.stopChainedTweens(); 200 | return this; 201 | 202 | }; 203 | 204 | this.stopChainedTweens = function () { 205 | 206 | for ( var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++ ) { 207 | 208 | _chainedTweens[ i ].stop(); 209 | 210 | } 211 | 212 | }; 213 | 214 | this.delay = function ( amount ) { 215 | 216 | _delayTime = amount; 217 | return this; 218 | 219 | }; 220 | 221 | this.repeat = function ( times ) { 222 | 223 | _repeat = times; 224 | return this; 225 | 226 | }; 227 | 228 | this.yoyo = function( yoyo ) { 229 | 230 | _yoyo = yoyo; 231 | return this; 232 | 233 | }; 234 | 235 | 236 | this.easing = function ( easing ) { 237 | 238 | _easingFunction = easing; 239 | return this; 240 | 241 | }; 242 | 243 | this.interpolation = function ( interpolation ) { 244 | 245 | _interpolationFunction = interpolation; 246 | return this; 247 | 248 | }; 249 | 250 | this.chain = function () { 251 | 252 | _chainedTweens = arguments; 253 | return this; 254 | 255 | }; 256 | 257 | this.onStart = function ( callback ) { 258 | 259 | _onStartCallback = callback; 260 | return this; 261 | 262 | }; 263 | 264 | this.onUpdate = function ( callback ) { 265 | 266 | _onUpdateCallback = callback; 267 | return this; 268 | 269 | }; 270 | 271 | this.onComplete = function ( callback ) { 272 | 273 | _onCompleteCallback = callback; 274 | return this; 275 | 276 | }; 277 | 278 | this.onStop = function ( callback ) { 279 | 280 | _onStopCallback = callback; 281 | return this; 282 | 283 | }; 284 | 285 | this.update = function ( time ) { 286 | 287 | var property; 288 | 289 | if ( time < _startTime ) { 290 | 291 | return true; 292 | 293 | } 294 | 295 | if ( _onStartCallbackFired === false ) { 296 | 297 | if ( _onStartCallback !== null ) { 298 | 299 | _onStartCallback.call( _object ); 300 | 301 | } 302 | 303 | _onStartCallbackFired = true; 304 | 305 | } 306 | 307 | var elapsed = ( time - _startTime ) / _duration; 308 | elapsed = elapsed > 1 ? 1 : elapsed; 309 | 310 | var value = _easingFunction( elapsed ); 311 | 312 | for ( property in _valuesEnd ) { 313 | 314 | var start = _valuesStart[ property ] || 0; 315 | var end = _valuesEnd[ property ]; 316 | 317 | if ( end instanceof Array ) { 318 | 319 | _object[ property ] = _interpolationFunction( end, value ); 320 | 321 | } else { 322 | 323 | // Parses relative end values with start as base (e.g.: +10, -3) 324 | if ( typeof(end) === "string" ) { 325 | end = start + parseFloat(end, 10); 326 | } 327 | 328 | // protect against non numeric properties. 329 | if ( typeof(end) === "number" ) { 330 | _object[ property ] = start + ( end - start ) * value; 331 | } 332 | 333 | } 334 | 335 | } 336 | 337 | if ( _onUpdateCallback !== null ) { 338 | 339 | _onUpdateCallback.call( _object, value ); 340 | 341 | } 342 | 343 | if ( elapsed == 1 ) { 344 | 345 | if ( _repeat > 0 ) { 346 | 347 | if( isFinite( _repeat ) ) { 348 | _repeat--; 349 | } 350 | 351 | // reassign starting values, restart by making startTime = now 352 | for( property in _valuesStartRepeat ) { 353 | 354 | if ( typeof( _valuesEnd[ property ] ) === "string" ) { 355 | _valuesStartRepeat[ property ] = _valuesStartRepeat[ property ] + parseFloat(_valuesEnd[ property ], 10); 356 | } 357 | 358 | if (_yoyo) { 359 | var tmp = _valuesStartRepeat[ property ]; 360 | _valuesStartRepeat[ property ] = _valuesEnd[ property ]; 361 | _valuesEnd[ property ] = tmp; 362 | } 363 | 364 | _valuesStart[ property ] = _valuesStartRepeat[ property ]; 365 | 366 | } 367 | 368 | if (_yoyo) { 369 | _reversed = !_reversed; 370 | } 371 | 372 | _startTime = time + _delayTime; 373 | 374 | return true; 375 | 376 | } else { 377 | 378 | if ( _onCompleteCallback !== null ) { 379 | 380 | _onCompleteCallback.call( _object ); 381 | 382 | } 383 | 384 | for ( var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++ ) { 385 | 386 | _chainedTweens[ i ].start( time ); 387 | 388 | } 389 | 390 | return false; 391 | 392 | } 393 | 394 | } 395 | 396 | return true; 397 | 398 | }; 399 | 400 | }; 401 | 402 | 403 | TWEEN.Easing = { 404 | 405 | Linear: { 406 | 407 | None: function ( k ) { 408 | 409 | return k; 410 | 411 | } 412 | 413 | }, 414 | 415 | Quadratic: { 416 | 417 | In: function ( k ) { 418 | 419 | return k * k; 420 | 421 | }, 422 | 423 | Out: function ( k ) { 424 | 425 | return k * ( 2 - k ); 426 | 427 | }, 428 | 429 | InOut: function ( k ) { 430 | 431 | if ( ( k *= 2 ) < 1 ) return 0.5 * k * k; 432 | return - 0.5 * ( --k * ( k - 2 ) - 1 ); 433 | 434 | } 435 | 436 | }, 437 | 438 | Cubic: { 439 | 440 | In: function ( k ) { 441 | 442 | return k * k * k; 443 | 444 | }, 445 | 446 | Out: function ( k ) { 447 | 448 | return --k * k * k + 1; 449 | 450 | }, 451 | 452 | InOut: function ( k ) { 453 | 454 | if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k; 455 | return 0.5 * ( ( k -= 2 ) * k * k + 2 ); 456 | 457 | } 458 | 459 | }, 460 | 461 | Quartic: { 462 | 463 | In: function ( k ) { 464 | 465 | return k * k * k * k; 466 | 467 | }, 468 | 469 | Out: function ( k ) { 470 | 471 | return 1 - ( --k * k * k * k ); 472 | 473 | }, 474 | 475 | InOut: function ( k ) { 476 | 477 | if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k; 478 | return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 ); 479 | 480 | } 481 | 482 | }, 483 | 484 | Quintic: { 485 | 486 | In: function ( k ) { 487 | 488 | return k * k * k * k * k; 489 | 490 | }, 491 | 492 | Out: function ( k ) { 493 | 494 | return --k * k * k * k * k + 1; 495 | 496 | }, 497 | 498 | InOut: function ( k ) { 499 | 500 | if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k; 501 | return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 ); 502 | 503 | } 504 | 505 | }, 506 | 507 | Sinusoidal: { 508 | 509 | In: function ( k ) { 510 | 511 | return 1 - Math.cos( k * Math.PI / 2 ); 512 | 513 | }, 514 | 515 | Out: function ( k ) { 516 | 517 | return Math.sin( k * Math.PI / 2 ); 518 | 519 | }, 520 | 521 | InOut: function ( k ) { 522 | 523 | return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); 524 | 525 | } 526 | 527 | }, 528 | 529 | Exponential: { 530 | 531 | In: function ( k ) { 532 | 533 | return k === 0 ? 0 : Math.pow( 1024, k - 1 ); 534 | 535 | }, 536 | 537 | Out: function ( k ) { 538 | 539 | return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k ); 540 | 541 | }, 542 | 543 | InOut: function ( k ) { 544 | 545 | if ( k === 0 ) return 0; 546 | if ( k === 1 ) return 1; 547 | if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 ); 548 | return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 ); 549 | 550 | } 551 | 552 | }, 553 | 554 | Circular: { 555 | 556 | In: function ( k ) { 557 | 558 | return 1 - Math.sqrt( 1 - k * k ); 559 | 560 | }, 561 | 562 | Out: function ( k ) { 563 | 564 | return Math.sqrt( 1 - ( --k * k ) ); 565 | 566 | }, 567 | 568 | InOut: function ( k ) { 569 | 570 | if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1); 571 | return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1); 572 | 573 | } 574 | 575 | }, 576 | 577 | Elastic: { 578 | 579 | In: function ( k ) { 580 | 581 | var s, a = 0.1, p = 0.4; 582 | if ( k === 0 ) return 0; 583 | if ( k === 1 ) return 1; 584 | if ( !a || a < 1 ) { a = 1; s = p / 4; } 585 | else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); 586 | return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); 587 | 588 | }, 589 | 590 | Out: function ( k ) { 591 | 592 | var s, a = 0.1, p = 0.4; 593 | if ( k === 0 ) return 0; 594 | if ( k === 1 ) return 1; 595 | if ( !a || a < 1 ) { a = 1; s = p / 4; } 596 | else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); 597 | return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 ); 598 | 599 | }, 600 | 601 | InOut: function ( k ) { 602 | 603 | var s, a = 0.1, p = 0.4; 604 | if ( k === 0 ) return 0; 605 | if ( k === 1 ) return 1; 606 | if ( !a || a < 1 ) { a = 1; s = p / 4; } 607 | else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI ); 608 | if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) ); 609 | return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1; 610 | 611 | } 612 | 613 | }, 614 | 615 | Back: { 616 | 617 | In: function ( k ) { 618 | 619 | var s = 1.70158; 620 | return k * k * ( ( s + 1 ) * k - s ); 621 | 622 | }, 623 | 624 | Out: function ( k ) { 625 | 626 | var s = 1.70158; 627 | return --k * k * ( ( s + 1 ) * k + s ) + 1; 628 | 629 | }, 630 | 631 | InOut: function ( k ) { 632 | 633 | var s = 1.70158 * 1.525; 634 | if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) ); 635 | return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 ); 636 | 637 | } 638 | 639 | }, 640 | 641 | Bounce: { 642 | 643 | In: function ( k ) { 644 | 645 | return 1 - TWEEN.Easing.Bounce.Out( 1 - k ); 646 | 647 | }, 648 | 649 | Out: function ( k ) { 650 | 651 | if ( k < ( 1 / 2.75 ) ) { 652 | 653 | return 7.5625 * k * k; 654 | 655 | } else if ( k < ( 2 / 2.75 ) ) { 656 | 657 | return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; 658 | 659 | } else if ( k < ( 2.5 / 2.75 ) ) { 660 | 661 | return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; 662 | 663 | } else { 664 | 665 | return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; 666 | 667 | } 668 | 669 | }, 670 | 671 | InOut: function ( k ) { 672 | 673 | if ( k < 0.5 ) return TWEEN.Easing.Bounce.In( k * 2 ) * 0.5; 674 | return TWEEN.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; 675 | 676 | } 677 | 678 | } 679 | 680 | }; 681 | 682 | TWEEN.Interpolation = { 683 | 684 | Linear: function ( v, k ) { 685 | 686 | var m = v.length - 1, f = m * k, i = Math.floor( f ), fn = TWEEN.Interpolation.Utils.Linear; 687 | 688 | if ( k < 0 ) return fn( v[ 0 ], v[ 1 ], f ); 689 | if ( k > 1 ) return fn( v[ m ], v[ m - 1 ], m - f ); 690 | 691 | return fn( v[ i ], v[ i + 1 > m ? m : i + 1 ], f - i ); 692 | 693 | }, 694 | 695 | Bezier: function ( v, k ) { 696 | 697 | var b = 0, n = v.length - 1, pw = Math.pow, bn = TWEEN.Interpolation.Utils.Bernstein, i; 698 | 699 | for ( i = 0; i <= n; i++ ) { 700 | b += pw( 1 - k, n - i ) * pw( k, i ) * v[ i ] * bn( n, i ); 701 | } 702 | 703 | return b; 704 | 705 | }, 706 | 707 | CatmullRom: function ( v, k ) { 708 | 709 | var m = v.length - 1, f = m * k, i = Math.floor( f ), fn = TWEEN.Interpolation.Utils.CatmullRom; 710 | 711 | if ( v[ 0 ] === v[ m ] ) { 712 | 713 | if ( k < 0 ) i = Math.floor( f = m * ( 1 + k ) ); 714 | 715 | return fn( v[ ( i - 1 + m ) % m ], v[ i ], v[ ( i + 1 ) % m ], v[ ( i + 2 ) % m ], f - i ); 716 | 717 | } else { 718 | 719 | if ( k < 0 ) return v[ 0 ] - ( fn( v[ 0 ], v[ 0 ], v[ 1 ], v[ 1 ], -f ) - v[ 0 ] ); 720 | if ( k > 1 ) return v[ m ] - ( fn( v[ m ], v[ m ], v[ m - 1 ], v[ m - 1 ], f - m ) - v[ m ] ); 721 | 722 | return fn( v[ i ? i - 1 : 0 ], v[ i ], v[ m < i + 1 ? m : i + 1 ], v[ m < i + 2 ? m : i + 2 ], f - i ); 723 | 724 | } 725 | 726 | }, 727 | 728 | Utils: { 729 | 730 | Linear: function ( p0, p1, t ) { 731 | 732 | return ( p1 - p0 ) * t + p0; 733 | 734 | }, 735 | 736 | Bernstein: function ( n , i ) { 737 | 738 | var fc = TWEEN.Interpolation.Utils.Factorial; 739 | return fc( n ) / fc( i ) / fc( n - i ); 740 | 741 | }, 742 | 743 | Factorial: ( function () { 744 | 745 | var a = [ 1 ]; 746 | 747 | return function ( n ) { 748 | 749 | var s = 1, i; 750 | if ( a[ n ] ) return a[ n ]; 751 | for ( i = n; i > 1; i-- ) s *= i; 752 | return a[ n ] = s; 753 | 754 | }; 755 | 756 | } )(), 757 | 758 | CatmullRom: function ( p0, p1, p2, p3, t ) { 759 | 760 | var v0 = ( p2 - p0 ) * 0.5, v1 = ( p3 - p1 ) * 0.5, t2 = t * t, t3 = t * t2; 761 | return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1; 762 | 763 | } 764 | 765 | } 766 | 767 | }; 768 | 769 | // UMD (Universal Module Definition) 770 | ( function ( root ) { 771 | 772 | if ( typeof define === 'function' && define.amd ) { 773 | 774 | // AMD 775 | define( [], function () { 776 | return TWEEN; 777 | } ); 778 | 779 | } else if ( typeof exports === 'object' ) { 780 | 781 | // Node.js 782 | module.exports = TWEEN; 783 | 784 | } else { 785 | 786 | // Global variable 787 | root.TWEEN = TWEEN; 788 | 789 | } 790 | 791 | } )( this ); -------------------------------------------------------------------------------- /vendor/touchpolyfill.js: -------------------------------------------------------------------------------- 1 | // polyfill touch functionality on browsers that have pointer functionality (that piece of trash internet explorer) 2 | // this thing is mostly just a hack on handjs, but does the reverse 3 | // cameron henlin, cam.henlin@gmail.com 4 | 5 | // jslint directive 6 | /*jslint browser: true, unparam: true, nomen: true*/ 7 | /*global HTMLBodyElement, HTMLDivElement, HTMLImageElement, HTMLUListElement, HTMLAnchorElement, HTMLLIElement, HTMLTableElement, HTMLSpanElement, HTMLCanvasElement, SVGElement*/ 8 | 9 | (function () { 10 | // We should start using 'use strict' as soon as we can get rid of the implied globals. 11 | // 'use strict'; 12 | 13 | // the timestamp of the last touch event processed. 14 | // It is used to determine what touches should be in the changedTouches TouchList array. 15 | var lastHwTimestamp = 0, 16 | // whether or not to log events to console 17 | logToConsole = false, 18 | userAgent = navigator.userAgent, 19 | supportedEventsNames = ["touchstart", "touchmove", "touchend", "touchcancel", "touchleave"], 20 | // commented out because not used 21 | // upperCaseEventsNames = ["TouchStart", "TouchMove", "TouchEnd", "TouchCancel", "TouchLeave"], 22 | previousTargets = {}, 23 | // wraps a W3C compliant implementation of the "touches" TouchList 24 | touchesWrapper, 25 | // wraps a W3C compliant implementation of the "changedTouches" TouchList 26 | changedTouchesWrapper, 27 | // wraps a W3C compliant implementation of the "targetTouches" TouchList 28 | targetTouchesWrapper; 29 | 30 | // a constructor for an object that wraps a W3C compliant TouchList. 31 | function TouchListWrapper() { 32 | var touchList = []; // an array of W3C compliant Touch objects. 33 | 34 | // constructor for W3C compliant touch object 35 | // http://www.w3.org/TR/touch-events/ 36 | function Touch(identifier, target, screenX, screenY, clientX, clientY, pageX, pageY) { 37 | this.identifier = identifier; 38 | this.target = target; 39 | this.screenX = screenX; 40 | this.screenY = screenY; 41 | this.clientX = clientX; 42 | this.clientY = clientY; 43 | this.pageX = pageX; 44 | this.pageY = pageY; 45 | } 46 | 47 | // Search the TouchList for a Touch with the given identifier. 48 | // If it is found, return it. Otherwise, return null; 49 | function getTouch(identifier) { 50 | var i; 51 | for (i = 0; i < touchList.length; i += 1) { 52 | if (touchList[i].identifier === identifier) { 53 | return touchList[i]; 54 | } 55 | } 56 | } 57 | 58 | // If this is a new touch, add it to the TouchList. 59 | // If this is an existing touch, update it in the TouchList. 60 | function addUpdateTouch(touch) { 61 | var i; 62 | for (i = 0; i < touchList.length; i += 1) { 63 | if (touchList[i].identifier === touch.identifier) { 64 | touchList[i] = touch; 65 | return; 66 | } 67 | } 68 | // If we finished the loop, then this is a new touch. 69 | touchList.push(touch); 70 | } 71 | 72 | function removeTouch(identifier) { 73 | var i; 74 | for (i = 0; i < touchList.length; i += 1) { 75 | if (touchList[i].identifier === identifier) { 76 | touchList.splice(i, 1); 77 | } 78 | } 79 | } 80 | 81 | function clearTouches() { 82 | // According to http://stackoverflow.com/questions/1232040/how-to-empty-an-array-in-javascript 83 | // this is the fastest way to clear the array. 84 | while (touchList.length > 0) { 85 | touchList.pop(); 86 | } 87 | } 88 | 89 | // Return true if the current TouchList object contains a touch at the specified screenX, clientY. 90 | // Returns false otherwise. 91 | // This is used to differentiate touches that have moved from those that haven't. 92 | function containsTouchAt(screenX, screenY) { 93 | var i; 94 | 95 | for (i = 0; i < touchList.length; i += 1) { 96 | if (touchList[i].screenX === screenX && touchList[i].screenY === screenY) { 97 | return true; 98 | } 99 | } 100 | 101 | return false; 102 | } 103 | 104 | // touchList is the actual W3C compliant TouchList object being emulated. 105 | this.touchList = touchList; 106 | 107 | this.Touch = Touch; 108 | this.getTouch = getTouch; 109 | this.addUpdateTouch = addUpdateTouch; 110 | this.removeTouch = removeTouch; 111 | this.clearTouches = clearTouches; 112 | this.containsTouchAt = containsTouchAt; 113 | } 114 | 115 | function touchesAreAtSameSpot(touch0, touch1) { 116 | return touch0.screenX === touch1.screenX && touch0.screenY === touch1.screenY; 117 | } 118 | 119 | // polyfill custom event 120 | function CustomEvent(event, params) { 121 | var evt; 122 | params = params || { 123 | bubbles: false, 124 | cancelable: false, 125 | detail: undefined 126 | }; 127 | evt = document.createEvent("CustomEvent"); 128 | evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 129 | return evt; 130 | } 131 | 132 | function checkPreventDefault(node) { 133 | while (node && !node.handJobjs_forcePreventDefault) { 134 | node = node.parentNode; 135 | } 136 | return !!node || window.handJobjs_forcePreventDefault; 137 | } 138 | 139 | // Touch events 140 | function generateTouchClonedEvent(sourceEvent, newName, canBubble, target, relatedTarget) { 141 | var evObj, oldTouch, oldTarget; 142 | 143 | // Updates the targetTouches so that it contains the touches from the "touches" TouchList 144 | // that have the same target as the touch that triggered this event. 145 | function updateTargetTouches(thisTouchTarget, touchesTouchList) { 146 | var i, touch; 147 | 148 | targetTouchesWrapper.clearTouches(); 149 | 150 | for (i = 0; i < touchesTouchList.length; i++) { 151 | touch = touchesTouchList[i]; 152 | if (touch.target.isSameNode(thisTouchTarget)) { 153 | targetTouchesWrapper.addUpdateTouch(touch); 154 | } 155 | } 156 | } 157 | 158 | function touchHandler(event) { 159 | var eventType, 160 | oldTouch, 161 | touch, 162 | touchEvent, 163 | isTouchChanged; 164 | 165 | log("touch!"); 166 | 167 | if (event.type === "pointerdown") { 168 | eventType = "touchstart"; 169 | } else if (event.type === "pointermove") { 170 | eventType = "touchmove"; 171 | } else { 172 | throw new Error('touchHandler received invalid event type: ' + eventType + '. Valid event types are pointerdown and pointermove'); 173 | } 174 | log(eventType); 175 | 176 | touch = new touchesWrapper.Touch(event.pointerId, (event.type === 'pointerdown' ? event.target : oldTarget), 177 | event.screenX, event.screenY, event.clientX, event.clientY, event.pageX, event.pageY); 178 | 179 | // Remove, from changedTouches, any Touch that is no longer being touched, or is being touched 180 | // in exactly the same place. 181 | // In order to make sure that simultaneous touches don't kick each other off of the changedTouches array 182 | // (because they are processed as different pointer events), skip this if the lastHwTimestamp hasn't increased. 183 | if (event.hwTimestamp > lastHwTimestamp) { 184 | (function () { 185 | var i, changedTouchList, changedTouch, matchingTouch, identifier; 186 | changedTouchList = changedTouchesWrapper.touchList; 187 | for (i = 0; i < changedTouchList.length; i += 1) { 188 | changedTouch = changedTouchList[i]; 189 | identifier = changedTouch.identifier; 190 | matchingTouch = touchesWrapper.getTouch(identifier); 191 | 192 | if (!matchingTouch || touchesAreAtSameSpot(matchingTouch, changedTouch)) { 193 | changedTouchesWrapper.removeTouch(identifier); 194 | } 195 | } 196 | } ()); 197 | } 198 | 199 | log("generating touch cloned"); 200 | 201 | touchesWrapper.addUpdateTouch(touch); 202 | changedTouchesWrapper.addUpdateTouch(touch); 203 | updateTargetTouches(touch.target, touchesWrapper.touchList); 204 | 205 | event.type = eventType; 206 | touchEvent = new CustomEvent(eventType, { bubbles: true, cancelable: true }); 207 | 208 | touchEvent.touches = touchesWrapper.touchList; 209 | touchEvent.changedTouches = changedTouchesWrapper.touchList; 210 | touchEvent.targetTouches = targetTouchesWrapper.touchList; 211 | touchEvent.type = eventType; 212 | 213 | // Awesomely, I figured out how to keep track of the touches in the "Touches" TouchList using an array. 214 | // TODO: Do the same thing for the changedTouches and targetTouches properties of the TouchEvent. 215 | // TODONE! changedTouches is implemented. 216 | // TODONE! targetTouches is implemented. 217 | 218 | // The other members of the TouchEvent are altKey, metaKey, ctrlKey, and shiftKey 219 | 220 | return touchEvent; 221 | } 222 | 223 | function touchChangedHandler(event) { 224 | var eventType, 225 | touch, 226 | touchEvent; 227 | 228 | log("touchchanged!"); 229 | event.changedTouches = []; 230 | event.changedTouches.length = 1; 231 | event.changedTouches[0] = event; 232 | event.changedTouches[0].identifier = event.pointerId; 233 | 234 | if (event.type === "pointerup") { 235 | eventType = "touchend"; 236 | } else if (event.type === "pointercancel") { 237 | eventType = "touchcancel"; 238 | } else if (event.type === "pointerleave") { 239 | eventType = "touchleave"; 240 | } 241 | 242 | touch = new touchesWrapper.Touch(event.pointerId, oldTarget, event.screenX, event.screenY, event.clientX, event.clientY, event.pageX, event.pageY); 243 | 244 | // This is a new touch event if it happened at a greater time than the last touch event. 245 | // If it is a new touch event, clear out the changedTouches TouchList. 246 | if (event.hwTimestamp > lastHwTimestamp) { 247 | changedTouchesWrapper.clearTouches(); 248 | } 249 | 250 | touchesWrapper.removeTouch(touch.identifier); 251 | changedTouchesWrapper.addUpdateTouch(touch); 252 | updateTargetTouches(touch.target, touchesWrapper.touchList); 253 | 254 | event.type = eventType; 255 | touchEvent = new CustomEvent(eventType, { bubbles: true, cancelable: true }); 256 | touchEvent.touches = touchesWrapper.touchList; 257 | touchEvent.changedTouches = changedTouchesWrapper.touchList; 258 | touchEvent.targetTouches = targetTouchesWrapper.touchList; 259 | touchEvent.type = eventType; 260 | 261 | return touchEvent; 262 | } 263 | 264 | // An important difference between the MS pointer events and the W3C touch events 265 | // is that for pointer events except for pointerdown, all target the element that the touch 266 | // is over when the event is fired. 267 | // The W3C touch events target the element where the touch originally started. 268 | // Therefore, when these events are fired, we must make this change manually. 269 | if (sourceEvent.type !== 'pointerdown') { 270 | oldTouch = touchesWrapper.getTouch(sourceEvent.pointerId); 271 | oldTarget = oldTouch.target; 272 | sourceEvent.target = oldTarget; 273 | } 274 | 275 | if (sourceEvent.type === "pointerdown" || sourceEvent.type === "pointermove") { 276 | evObj = touchHandler(sourceEvent); 277 | } else { 278 | evObj = touchChangedHandler(sourceEvent); 279 | } 280 | 281 | // PreventDefault 282 | evObj.preventDefault = function () { 283 | if (sourceEvent.preventDefault !== undefined) { 284 | sourceEvent.preventDefault(); 285 | } 286 | }; 287 | 288 | // Fire event 289 | log("dispatching!"); 290 | sourceEvent.target.dispatchEvent(evObj); 291 | 292 | lastHwTimestamp = event.hwTimestamp; 293 | } 294 | 295 | function generateTouchEventProxy(name, touchPoint, target, eventObject, canBubble, relatedTarget) { 296 | generateTouchClonedEvent(touchPoint, name, canBubble, target, relatedTarget); 297 | } 298 | 299 | function registerOrUnregisterEvent(item, name, func, enable) { 300 | log("registerOrUnregisterEvent"); 301 | if (item.__handJobjsRegisteredEvents === undefined) { 302 | item.__handJobjsRegisteredEvents = []; 303 | } 304 | 305 | if (enable) { 306 | if (item.__handJobjsRegisteredEvents[name] !== undefined) { 307 | item.__handJobjsRegisteredEvents[name] += 1; 308 | return; 309 | } 310 | 311 | item.__handJobjsRegisteredEvents[name] = 1; 312 | log("adding event " + name); 313 | item.addEventListener(name, func, false); 314 | } else { 315 | 316 | if (item.__handJobjsRegisteredEvents.indexOf(name) !== -1) { 317 | item.__handJobjsRegisteredEvents[name] -= 1; 318 | 319 | if (item.__handJobjsRegisteredEvents[name] !== 0) { 320 | return; 321 | } 322 | } 323 | log("removing event"); 324 | item.removeEventListener(name, func); 325 | item.__handJobjsRegisteredEvents[name] = 0; 326 | } 327 | } 328 | 329 | function setTouchAware(item, eventName, enable) { 330 | var eventGenerator, 331 | targetEvent; 332 | 333 | function nameGenerator(name) { 334 | return name; 335 | } // easier than doing this right and replacing all the references 336 | 337 | log("setTouchAware " + enable + " " + eventName); 338 | // Leaving tokens 339 | if (!item.__handJobjsGlobalRegisteredEvents) { 340 | item.__handJobjsGlobalRegisteredEvents = []; 341 | } 342 | if (enable) { 343 | if (item.__handJobjsGlobalRegisteredEvents[eventName] !== undefined) { 344 | item.__handJobjsGlobalRegisteredEvents[eventName] += 1; 345 | return; 346 | } 347 | item.__handJobjsGlobalRegisteredEvents[eventName] = 1; 348 | 349 | log(item.__handJobjsGlobalRegisteredEvents[eventName]); 350 | } else { 351 | if (item.__handJobjsGlobalRegisteredEvents[eventName] !== undefined) { 352 | item.__handJobjsGlobalRegisteredEvents[eventName] -= 1; 353 | if (item.__handJobjsGlobalRegisteredEvents[eventName] < 0) { 354 | item.__handJobjsGlobalRegisteredEvents[eventName] = 0; 355 | } 356 | } 357 | } 358 | 359 | eventGenerator = generateTouchClonedEvent; 360 | 361 | //switch (eventName) { 362 | // case "touchenter": 363 | // log("touchenter"); 364 | // break; 365 | // case "touchleave": 366 | // log("touchleave"); 367 | targetEvent = nameGenerator(eventName); 368 | 369 | if (item['on' + targetEvent.toLowerCase()] !== undefined) { 370 | registerOrUnregisterEvent(item, targetEvent, function (evt) { eventGenerator(evt, eventName); }, enable); 371 | } 372 | // break; 373 | //} 374 | } 375 | 376 | // Intercept addEventListener calls by changing the prototype 377 | function interceptAddEventListener(root) { 378 | var current = root.prototype ? root.prototype.addEventListener : root.addEventListener; 379 | 380 | function customAddEventListener(name, func, capture) { 381 | log("customAddEventListener"); 382 | log(name); 383 | 384 | if (supportedEventsNames.indexOf(name) !== -1) { 385 | log("setting touch aware..."); 386 | setTouchAware(this, name, true); 387 | } 388 | current.call(this, name, func, capture); 389 | } 390 | 391 | log("intercepting add event listener!"); 392 | log(root); 393 | 394 | if (root.prototype) { 395 | root.prototype.addEventListener = customAddEventListener; 396 | } else { 397 | root.addEventListener = customAddEventListener; 398 | } 399 | } 400 | 401 | function handleOtherEvent(eventObject, name) { 402 | log("handle other event"); 403 | if (eventObject.preventManipulation) { 404 | eventObject.preventManipulation(); 405 | } 406 | 407 | // TODO: JSLint found that touchPoint here is an implied global! 408 | generateTouchClonedEvent(touchPoint, name); 409 | } 410 | 411 | function removeTouchAware(item, eventName) { 412 | // If item is already touch aware, do nothing 413 | if (item.ontouchdown !== undefined) { 414 | return; 415 | } 416 | 417 | // Chrome, Firefox 418 | if (item.ontouchstart !== undefined) { 419 | switch (eventName.toLowerCase()) { 420 | case "touchstart": 421 | item.removeEventListener("pointerdown", function (evt) { handleOtherEvent(evt, eventName); }); 422 | break; 423 | case "touchmove": 424 | item.removeEventListener("pointermove", function (evt) { handleOtherEvent(evt, eventName); }); 425 | break; 426 | case "touchend": 427 | item.removeEventListener("pointerup", function (evt) { handleOtherEvent(evt, eventName); }); 428 | break; 429 | case "touchcancel": 430 | item.removeEventListener("pointercancel", function (evt) { handleOtherEvent(evt, eventName); }); 431 | break; 432 | } 433 | } 434 | } 435 | 436 | // Intercept removeEventListener calls by changing the prototype 437 | function interceptRemoveEventListener(root) { 438 | var current = root.prototype ? root.prototype.removeEventListener : root.removeEventListener; 439 | 440 | function customRemoveEventListener(name, func, capture) { 441 | // Branch when a PointerXXX is used 442 | if (supportedEventsNames.indexOf(name) !== -1) { 443 | removeTouchAware(this, name); 444 | } 445 | 446 | current.call(this, name, func, capture); 447 | } 448 | 449 | if (root.prototype) { 450 | root.prototype.removeEventListener = customRemoveEventListener; 451 | } else { 452 | root.removeEventListener = customRemoveEventListener; 453 | } 454 | } 455 | 456 | function checkEventRegistration(node, eventName) { 457 | log("checkEventRegistration"); 458 | return node.__handJobjsGlobalRegisteredEvents && node.__handJobjsGlobalRegisteredEvents[eventName]; 459 | } 460 | 461 | function findEventRegisteredNode(node, eventName) { 462 | log("findEventRegisteredNode"); 463 | while (node && !checkEventRegistration(node, eventName)) { 464 | node = node.parentNode; 465 | } 466 | if (node) { 467 | return node; 468 | } 469 | if (checkEventRegistration(window, eventName)) { 470 | return window; 471 | } 472 | } 473 | 474 | function generateTouchEventProxyIfRegistered(eventName, touchPoint, target, eventObject, canBubble, relatedTarget) { // Check if user registered this event 475 | log("generateTouchEventProxyIfRegistered"); 476 | if (findEventRegisteredNode(target, eventName)) { 477 | generateTouchEventProxy(eventName, touchPoint, target, eventObject, canBubble, relatedTarget); 478 | } 479 | } 480 | 481 | function getDomUpperHierarchy(node) { 482 | var nodes = []; 483 | if (node) { 484 | nodes.unshift(node); 485 | while (node.parentNode) { 486 | nodes.unshift(node.parentNode); 487 | node = node.parentNode; 488 | } 489 | } 490 | return nodes; 491 | } 492 | 493 | function getFirstCommonNode(node1, node2) { 494 | var parents1 = getDomUpperHierarchy(node1), 495 | parents2 = getDomUpperHierarchy(node2), 496 | lastmatch = null; 497 | 498 | while (parents1.length > 0 && parents1[0] === parents2.shift()) { 499 | lastmatch = parents1.shift(); 500 | } 501 | return lastmatch; 502 | } 503 | 504 | // generateProxy receives a node to dispatch the event 505 | function dispatchPointerEnter(currentTarget, relatedTarget, generateProxy) { 506 | log("dispatchPointerEnter"); 507 | var commonParent = getFirstCommonNode(currentTarget, relatedTarget), 508 | node = currentTarget, 509 | nodelist = []; 510 | 511 | while (node && node !== commonParent) { // target range: this to the direct child of parent relatedTarget 512 | if (checkEventRegistration(node, "touchenter")) { 513 | // check if any parent node has pointerenter 514 | nodelist.push(node); 515 | } 516 | node = node.parentNode; 517 | } 518 | while (nodelist.length > 0) { 519 | generateProxy(nodelist.pop()); 520 | } 521 | } 522 | 523 | // generateProxy receives a node to dispatch the event 524 | function dispatchPointerLeave(currentTarget, relatedTarget, generateProxy) { 525 | log("dispatchPointerLeave"); 526 | var commonParent = getFirstCommonNode(currentTarget, relatedTarget), 527 | node = currentTarget; 528 | while (node && node !== commonParent) {//target range: this to the direct child of parent relatedTarget 529 | if (checkEventRegistration(node, "touchleave")) { 530 | // check if any parent node has pointerleave 531 | generateProxy(node); 532 | } 533 | node = node.parentNode; 534 | } 535 | } 536 | 537 | function log(s) { 538 | if (logToConsole) { 539 | console.log(s.toString()); 540 | } 541 | } 542 | 543 | CustomEvent.prototype = window.Event.prototype; 544 | 545 | if (typeof (window.ontouchstart) === "object") { 546 | return; 547 | } 548 | 549 | if (userAgent.match(/iPad/i) || userAgent.match(/iPhone/i) || userAgent.match(/iPod/i) || userAgent.match(/Android/i) || (userAgent.match(/MSIE/i) && !userAgent.match(/Touch/i))) { 550 | return; 551 | } 552 | 553 | // Add CSS to disable MS IE default scrolling functionality. 554 | (function () { 555 | var css = 'html { -ms-touch-action: none; }', 556 | head = document.head || document.getElementsByTagName('head')[0], 557 | style = document.createElement('style'); 558 | 559 | style.type = 'text/css'; 560 | if (style.styleSheet) { 561 | style.styleSheet.cssText = css; 562 | } else { 563 | style.appendChild(document.createTextNode(css)); 564 | } 565 | 566 | head.appendChild(style); 567 | } ()); 568 | 569 | touchesWrapper = new TouchListWrapper(); 570 | changedTouchesWrapper = new TouchListWrapper(); 571 | targetTouchesWrapper = new TouchListWrapper(); 572 | 573 | window.CustomEvent = CustomEvent; 574 | 575 | // Hooks 576 | interceptAddEventListener(window); 577 | interceptAddEventListener(window.HTMLElement || window.Element); 578 | interceptAddEventListener(document); 579 | interceptAddEventListener(HTMLBodyElement); 580 | interceptAddEventListener(HTMLDivElement); 581 | interceptAddEventListener(HTMLImageElement); 582 | interceptAddEventListener(HTMLUListElement); 583 | interceptAddEventListener(HTMLAnchorElement); 584 | interceptAddEventListener(HTMLLIElement); 585 | interceptAddEventListener(HTMLTableElement); 586 | if (window.HTMLSpanElement) { 587 | interceptAddEventListener(HTMLSpanElement); 588 | } 589 | if (window.HTMLCanvasElement) { 590 | interceptAddEventListener(HTMLCanvasElement); 591 | } 592 | if (window.SVGElement) { 593 | interceptAddEventListener(SVGElement); 594 | } 595 | 596 | interceptRemoveEventListener(window); 597 | interceptRemoveEventListener(window.HTMLElement || window.Element); 598 | interceptRemoveEventListener(document); 599 | interceptRemoveEventListener(HTMLBodyElement); 600 | interceptRemoveEventListener(HTMLDivElement); 601 | interceptRemoveEventListener(HTMLImageElement); 602 | interceptRemoveEventListener(HTMLUListElement); 603 | interceptRemoveEventListener(HTMLAnchorElement); 604 | interceptRemoveEventListener(HTMLLIElement); 605 | interceptRemoveEventListener(HTMLTableElement); 606 | if (window.HTMLSpanElement) { 607 | interceptRemoveEventListener(HTMLSpanElement); 608 | } 609 | if (window.HTMLCanvasElement) { 610 | interceptRemoveEventListener(HTMLCanvasElement); 611 | } 612 | if (window.SVGElement) { 613 | interceptRemoveEventListener(SVGElement); 614 | } 615 | 616 | (function () { 617 | // Returns true if and only if the event should be ignored. 618 | function ignorePointerEvent(event) { 619 | // Don't interpret mouse pointers as touches 620 | if (event.pointerType === 'mouse') { 621 | return true; 622 | } 623 | // Don't interpret pointerdown events on the scrollbars as touch events. 624 | // It appears to be the case that when the event is on the scrollbar in IE, 625 | // event.x === 0 and event.y === 0 626 | if (event.type === 'pointerdown' && event.x === 0 && event.y === 0) { 627 | return true; 628 | } 629 | // A user reported that when the input type is 'pen', the pointermove event fires with a pressure of 0 630 | // before the pen touches the screen. We want to ignore this. 631 | if (event.pointerType === 'pen' && event.pressure === 0 && event.type === 'pointermove') { 632 | return true; 633 | } 634 | return false; 635 | } 636 | 637 | // Handling move on window to detect pointerleave/out/over 638 | window.addEventListener('pointerdown', function (eventObject) { 639 | log("pointerdownfired"); 640 | var touchPoint = eventObject; 641 | 642 | if (ignorePointerEvent(eventObject)) { 643 | return; 644 | } 645 | 646 | previousTargets[touchPoint.identifier] = touchPoint.target; 647 | generateTouchEventProxyIfRegistered("touchenter", touchPoint, touchPoint.target, eventObject, true); 648 | 649 | // pointerenter should not be bubbled 650 | dispatchPointerEnter(touchPoint.target, null, function (targetNode) { 651 | generateTouchEventProxy("touchenter", touchPoint, targetNode, eventObject, false); 652 | }); 653 | 654 | generateTouchEventProxyIfRegistered("touchstart", touchPoint, touchPoint.target, eventObject, true); 655 | }); 656 | 657 | window.addEventListener('pointerup', function (eventObject) { 658 | var touchPoint = eventObject, 659 | currentTarget = previousTargets[touchPoint.identifier]; 660 | 661 | log("pointer up fired"); 662 | 663 | if (ignorePointerEvent(eventObject)) { 664 | return; 665 | } 666 | 667 | generateTouchEventProxyIfRegistered("touchend", touchPoint, currentTarget, eventObject, true); 668 | generateTouchEventProxyIfRegistered("touchleave", touchPoint, currentTarget, eventObject, true); 669 | 670 | //pointerleave should not be bubbled 671 | dispatchPointerLeave(currentTarget, null, function (targetNode) { 672 | generateTouchEventProxy("touchleave", touchPoint, targetNode, eventObject, false); 673 | }); 674 | }); 675 | 676 | window.addEventListener('pointermove', function (eventObject) { 677 | var touchPoint = eventObject, 678 | currentTarget = previousTargets[touchPoint.identifier]; 679 | 680 | log("pointer move fired"); 681 | 682 | if (ignorePointerEvent(eventObject)) { 683 | return; 684 | } 685 | 686 | log('x: ' + eventObject.screenX + ', y: ' + eventObject.screenY); 687 | 688 | // pointermove fires over and over when a touch-point stays stationary. 689 | // This is at odds with the other browsers that implement the W3C standard touch events 690 | // which fire touchmove only when the touch-point actually moves. 691 | // Therefore, return without doing anything if the pointermove event fired for a touch 692 | // that hasn't moved. 693 | if (touchesWrapper.containsTouchAt(eventObject.screenX, eventObject.screenY)) { 694 | return; 695 | } 696 | 697 | // If force preventDefault 698 | if (currentTarget && checkPreventDefault(currentTarget) === true) { 699 | eventObject.preventDefault(); 700 | } 701 | 702 | generateTouchEventProxyIfRegistered("touchmove", touchPoint, currentTarget, eventObject, true); 703 | }); 704 | } ()); 705 | } ()); -------------------------------------------------------------------------------- /dist/es6-shim.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * https://github.com/paulmillr/es6-shim 3 | * @license es6-shim Copyright 2013-2015 by Paul Miller (http://paulmillr.com) 4 | * and contributors, MIT License 5 | * es6-shim: v0.33.13 6 | * see https://github.com/paulmillr/es6-shim/blob/0.33.13/LICENSE 7 | * Details and documentation: 8 | * https://github.com/paulmillr/es6-shim/ 9 | */ 10 | (function(e,t){if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){"use strict";var e=Function.call.bind(Function.apply);var t=Function.call.bind(Function.call);var r=Array.isArray;var n=function notThunker(t){return function notThunk(){return!e(t,this,arguments)}};var o=function(e){try{e();return false}catch(t){return true}};var i=function valueOrFalseIfThrows(e){try{return e()}catch(t){return false}};var a=n(o);var u=function(){return!o(function(){Object.defineProperty({},"x",{get:function(){}})})};var s=!!Object.defineProperty&&u();var f=function foo(){}.name==="foo";var c=Function.call.bind(Array.prototype.forEach);var l=Function.call.bind(Array.prototype.reduce);var p=Function.call.bind(Array.prototype.filter);var v=Function.call.bind(Array.prototype.some);var y=function(e,t,r,n){if(!n&&t in e){return}if(s){Object.defineProperty(e,t,{configurable:true,enumerable:false,writable:true,value:r})}else{e[t]=r}};var h=function(e,t){c(Object.keys(t),function(r){var n=t[r];y(e,r,n,false)})};var g=Object.create||function(e,t){var r=function Prototype(){};r.prototype=e;var n=new r;if(typeof t!=="undefined"){Object.keys(t).forEach(function(e){U.defineByDescriptor(n,e,t[e])})}return n};var b=function(e,t){if(!Object.setPrototypeOf){return false}return i(function(){var r=function Subclass(t){var r=new e(t);Object.setPrototypeOf(r,Subclass.prototype);return r};Object.setPrototypeOf(r,e);r.prototype=g(e.prototype,{constructor:{value:r}});return t(r)})};var d=function(){if(typeof self!=="undefined"){return self}if(typeof window!=="undefined"){return window}if(typeof global!=="undefined"){return global}throw new Error("unable to locate global object")};var m=d();var O=m.isFinite;var w=Function.call.bind(String.prototype.indexOf);var j=Function.call.bind(Object.prototype.toString);var S=Function.call.bind(Array.prototype.concat);var T=Function.call.bind(String.prototype.slice);var I=Function.call.bind(Array.prototype.push);var E=Function.apply.bind(Array.prototype.push);var M=Function.call.bind(Array.prototype.shift);var P=Math.max;var x=Math.min;var N=Math.floor;var C=Math.abs;var A=Math.log;var k=Math.sqrt;var _=Function.call.bind(Object.prototype.hasOwnProperty);var R;var F=function(){};var D=m.Symbol||{};var z=D.species||"@@species";var L=Number.isNaN||function isNaN(e){return e!==e};var q=Number.isFinite||function isFinite(e){return typeof e==="number"&&O(e)};var G=function isArguments(e){return j(e)==="[object Arguments]"};var W=function isArguments(e){return e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&j(e)!=="[object Array]"&&j(e.callee)==="[object Function]"};var H=G(arguments)?G:W;var B={primitive:function(e){return e===null||typeof e!=="function"&&typeof e!=="object"},object:function(e){return e!==null&&typeof e==="object"},string:function(e){return j(e)==="[object String]"},regex:function(e){return j(e)==="[object RegExp]"},symbol:function(e){return typeof m.Symbol==="function"&&typeof e==="symbol"}};var $=B.symbol(D.iterator)?D.iterator:"_es6-shim iterator_";if(m.Set&&typeof(new m.Set)["@@iterator"]==="function"){$="@@iterator"}if(!m.Reflect){y(m,"Reflect",{})}var V=m.Reflect;var J={Call:function Call(t,r){var n=arguments.length>2?arguments[2]:[];if(!J.IsCallable(t)){throw new TypeError(t+" is not a function")}return e(t,r,n)},RequireObjectCoercible:function(e,t){if(e==null){throw new TypeError(t||"Cannot call method on "+e)}},TypeIsObject:function(e){return e!=null&&Object(e)===e},ToObject:function(e,t){J.RequireObjectCoercible(e,t);return Object(e)},IsCallable:function(e){return typeof e==="function"&&j(e)==="[object Function]"},IsConstructor:function(e){return J.IsCallable(e)},ToInt32:function(e){return J.ToNumber(e)>>0},ToUint32:function(e){return J.ToNumber(e)>>>0},ToNumber:function(e){if(j(e)==="[object Symbol]"){throw new TypeError("Cannot convert a Symbol value to a number")}return+e},ToInteger:function(e){var t=J.ToNumber(e);if(L(t)){return 0}if(t===0||!q(t)){return t}return(t>0?1:-1)*N(C(t))},ToLength:function(e){var t=J.ToInteger(e);if(t<=0){return 0}if(t>Number.MAX_SAFE_INTEGER){return Number.MAX_SAFE_INTEGER}return t},SameValue:function(e,t){if(e===t){if(e===0){return 1/e===1/t}return true}return L(e)&&L(t)},SameValueZero:function(e,t){return e===t||L(e)&&L(t)},IsIterable:function(e){return J.TypeIsObject(e)&&(typeof e[$]!=="undefined"||H(e))},GetIterator:function(e){if(H(e)){return new R(e,"value")}var r=J.GetMethod(e,$);if(!J.IsCallable(r)){throw new TypeError("value is not an iterable")}var n=t(r,e);if(!J.TypeIsObject(n)){throw new TypeError("bad iterator")}return n},GetMethod:function(e,t){var r=J.ToObject(e)[t];if(r===void 0||r===null){return void 0}if(!J.IsCallable(r)){throw new TypeError("Method not callable: "+t)}return r},IteratorComplete:function(e){return!!e.done},IteratorClose:function(e,r){var n=J.GetMethod(e,"return");if(n===void 0){return}var o,i;try{o=t(n,e)}catch(a){i=a}if(r){return}if(i){throw i}if(!J.TypeIsObject(o)){throw new TypeError("Iterator's return method returned a non-object.")}},IteratorNext:function(e){var t=arguments.length>1?e.next(arguments[1]):e.next();if(!J.TypeIsObject(t)){throw new TypeError("bad iterator")}return t},IteratorStep:function(e){var t=J.IteratorNext(e);var r=J.IteratorComplete(t);return r?false:t},Construct:function(e,t,r,n){var o=typeof r==="undefined"?e:r;if(!n){return V.construct(e,t,o)}var i=o.prototype;if(!J.TypeIsObject(i)){i=Object.prototype}var a=g(i);var u=J.Call(e,a,t);return J.TypeIsObject(u)?u:a},SpeciesConstructor:function(e,t){var r=e.constructor;if(r===void 0){return t}if(!J.TypeIsObject(r)){throw new TypeError("Bad constructor")}var n=r[z];if(n===void 0||n===null){return t}if(!J.IsConstructor(n)){throw new TypeError("Bad @@species")}return n},CreateHTML:function(e,t,r,n){var o=String(e);var i="<"+t;if(r!==""){var a=String(n);var u=a.replace(/"/g,""");i+=" "+r+'="'+u+'"'}var s=i+">";var f=s+o;return f+""}};var U={getter:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}Object.defineProperty(e,t,{configurable:true,enumerable:false,get:r})},proxy:function(e,t,r){if(!s){throw new TypeError("getters require true ES5 support")}var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,{configurable:n.configurable,enumerable:n.enumerable,get:function getKey(){return e[t]},set:function setKey(r){e[t]=r}})},redefine:function(e,t,r){if(s){var n=Object.getOwnPropertyDescriptor(e,t);n.value=r;Object.defineProperty(e,t,n)}else{e[t]=r}},defineByDescriptor:function(e,t,r){if(s){Object.defineProperty(e,t,r)}else if("value"in r){e[t]=r.value}},preserveToString:function(e,t){if(t&&J.IsCallable(t.toString)){y(e,"toString",t.toString.bind(t),true)}}};var K=function wrapConstructor(e,t,r){U.preserveToString(t,e);if(Object.setPrototypeOf){Object.setPrototypeOf(e,t)}if(s){c(Object.getOwnPropertyNames(e),function(n){if(n in F||r[n]){return}U.proxy(e,n,t)})}else{c(Object.keys(e),function(n){if(n in F||r[n]){return}t[n]=e[n]})}t.prototype=e.prototype;U.redefine(e.prototype,"constructor",t)};var X=function(){return this};var Z=function(e){if(s&&!_(e,z)){U.getter(e,z,X)}};var Q=function overrideNative(e,t,r){var n=e[t];y(e,t,r,true);U.preserveToString(e[t],n)};var Y=function(e,t){var r=t||function iterator(){return this};y(e,$,r);if(!e[$]&&B.symbol($)){e[$]=r}};var ee=function createDataProperty(e,t,r){if(s){Object.defineProperty(e,t,{configurable:true,enumerable:true,writable:true,value:r})}else{e[t]=r}};var te=function createDataPropertyOrThrow(e,t,r){ee(e,t,r);if(!J.SameValue(e[t],r)){throw new TypeError("property is nonconfigurable")}};var re=function(e,t,r,n){if(!J.TypeIsObject(e)){throw new TypeError("Constructor requires `new`: "+t.name)}var o=t.prototype;if(!J.TypeIsObject(o)){o=r}var i=g(o);for(var a in n){if(_(n,a)){var u=n[a];y(i,a,u,true)}}return i};if(String.fromCodePoint&&String.fromCodePoint.length!==1){var ne=String.fromCodePoint;Q(String,"fromCodePoint",function fromCodePoint(t){return e(ne,this,arguments)})}var oe={fromCodePoint:function fromCodePoint(e){var t=[];var r;for(var n=0,o=arguments.length;n1114111){throw new RangeError("Invalid code point "+r)}if(r<65536){I(t,String.fromCharCode(r))}else{r-=65536;I(t,String.fromCharCode((r>>10)+55296));I(t,String.fromCharCode(r%1024+56320))}}return t.join("")},raw:function raw(e){var t=J.ToObject(e,"bad callSite");var r=J.ToObject(t.raw,"bad raw value");var n=r.length;var o=J.ToLength(n);if(o<=0){return""}var i=[];var a=0;var u,s,f,c;while(a=o){break}s=a+1=ae){throw new RangeError("repeat count must be less than infinity and not overflow maximum string size")}return ie(t,r)},startsWith:function startsWith(e){J.RequireObjectCoercible(this);var t=String(this);if(B.regex(e)){throw new TypeError('Cannot call method "startsWith" with a regex')}var r=String(e);var n=arguments.length>1?arguments[1]:void 0;var o=P(J.ToInteger(n),0);return T(t,o,o+r.length)===r},endsWith:function endsWith(e){J.RequireObjectCoercible(this);var t=String(this);if(B.regex(e)){throw new TypeError('Cannot call method "endsWith" with a regex')}var r=String(e);var n=t.length;var o=arguments.length>1?arguments[1]:void 0;var i=typeof o==="undefined"?n:J.ToInteger(o);var a=x(P(i,0),n);return T(t,a-r.length,a)===r},includes:function includes(e){if(B.regex(e)){throw new TypeError('"includes" does not accept a RegExp')}var t;if(arguments.length>1){t=arguments[1]}return w(this,e,t)!==-1},codePointAt:function codePointAt(e){J.RequireObjectCoercible(this);var t=String(this);var r=J.ToInteger(e);var n=t.length;if(r>=0&&r56319||i){return o}var a=t.charCodeAt(r+1);if(a<56320||a>57343){return o}return(o-55296)*1024+(a-56320)+65536}}};if(String.prototype.includes&&"a".includes("a",Infinity)!==false){Q(String.prototype,"includes",ue.includes)}if(String.prototype.startsWith&&String.prototype.endsWith){var se=o(function(){"/a/".startsWith(/a/)});var fe="abc".startsWith("a",Infinity)===false;if(!se||!fe){Q(String.prototype,"startsWith",ue.startsWith);Q(String.prototype,"endsWith",ue.endsWith)}}h(String.prototype,ue);var ce=[" \n\x0B\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003","\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028","\u2029\ufeff"].join("");var le=new RegExp("(^["+ce+"]+)|(["+ce+"]+$)","g");var pe=function trim(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return String(this).replace(le,"")};var ve=["\x85","\u200b","\ufffe"].join("");var ye=new RegExp("["+ve+"]","g");var he=/^[\-+]0x[0-9a-f]+$/i;var ge=ve.trim().length!==ve.length;y(String.prototype,"trim",pe,ge);var be=function(e){J.RequireObjectCoercible(e);this._s=String(e);this._i=0};be.prototype.next=function(){var e=this._s,t=this._i;if(typeof e==="undefined"||t>=e.length){this._s=void 0;return{value:void 0,done:true}}var r=e.charCodeAt(t),n,o;if(r<55296||r>56319||t+1===e.length){o=1}else{n=e.charCodeAt(t+1);o=n<56320||n>57343?1:2}this._i=t+o;return{value:e.substr(t,o),done:false}};Y(be.prototype);Y(String.prototype,function(){return new be(this)});var de={from:function from(e){var r=this;var n=arguments.length>1?arguments[1]:void 0;var o,i;if(n===void 0){o=false}else{if(!J.IsCallable(n)){throw new TypeError("Array.from: when provided, the second argument must be a function")}i=arguments.length>2?arguments[2]:void 0;o=true}var a=typeof(H(e)||J.GetMethod(e,$))!=="undefined";var u,s,f;if(a){s=J.IsConstructor(r)?Object(new r):[];var c=J.GetIterator(e);var l,p;f=0;while(true){l=J.IteratorStep(c);if(l===false){break}p=l.value;try{if(o){p=i===undefined?n(p,f):t(n,i,p,f)}s[f]=p}catch(v){J.IteratorClose(c,true);throw v}f+=1}u=f}else{var y=J.ToObject(e);u=J.ToLength(y.length);s=J.IsConstructor(r)?Object(new r(u)):new Array(u);var h;for(f=0;f0){e=M(t);if(!(e in this.object)){continue}if(this.kind==="key"){return me(e)}else if(this.kind==="value"){return me(this.object[e])}else{return me([e,this.object[e]])}}return me()}});Y(we.prototype);var je=Array.of===de.of||function(){var e=function Foo(e){this.length=e};e.prototype=[];var t=Array.of.apply(e,[1,2]);return t instanceof e&&t.length===2}();if(!je){Q(Array,"of",de.of)}var Se={copyWithin:function copyWithin(e,t){var r=arguments[2];var n=J.ToObject(this);var o=J.ToLength(n.length);var i=J.ToInteger(e);var a=J.ToInteger(t);var u=i<0?P(o+i,0):x(i,o);var s=a<0?P(o+a,0):x(a,o);r=typeof r==="undefined"?o:J.ToInteger(r);var f=r<0?P(o+r,0):x(r,o);var c=x(f-s,o-u);var l=1;if(s0){if(_(n,s)){n[u]=n[s]}else{delete n[s]}s+=l;u+=l;c-=1}return n},fill:function fill(e){var t=arguments.length>1?arguments[1]:void 0;var r=arguments.length>2?arguments[2]:void 0;var n=J.ToObject(this);var o=J.ToLength(n.length);t=J.ToInteger(typeof t==="undefined"?0:t);r=J.ToInteger(typeof r==="undefined"?o:r);var i=t<0?P(o+t,0):x(t,o);var a=r<0?o+r:r;for(var u=i;u1?arguments[1]:null;for(var i=0,a;i1?arguments[1]:null;for(var i=0;i0&&typeof arguments[1]!=="undefined"){return e(Pe,this,arguments)}else{return t(Pe,this,r)}})}var xe=function(e,r){var n={length:-1};n[r?(-1>>>0)-1:0]=true;return i(function(){t(e,n,function(){throw new RangeError("should not reach here")},[])})};if(!xe(Array.prototype.forEach)){var Ne=Array.prototype.forEach;Q(Array.prototype,"forEach",function forEach(t){return e(Ne,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.map)){var Ce=Array.prototype.map;Q(Array.prototype,"map",function map(t){return e(Ce,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.filter)){var Ae=Array.prototype.filter;Q(Array.prototype,"filter",function filter(t){return e(Ae,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.some)){var ke=Array.prototype.some;Q(Array.prototype,"some",function some(t){return e(ke,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.every)){var _e=Array.prototype.every;Q(Array.prototype,"every",function every(t){return e(_e,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.reduce)){var Re=Array.prototype.reduce;Q(Array.prototype,"reduce",function reduce(t){return e(Re,this.length>=0?this:[],arguments)},true)}if(!xe(Array.prototype.reduceRight,true)){var Fe=Array.prototype.reduceRight;Q(Array.prototype,"reduceRight",function reduceRight(t){return e(Fe,this.length>=0?this:[],arguments)},true)}var De=Number("0o10")!==8;var ze=Number("0b10")!==2;var Le=v(ve,function(e){return Number(e+0+e)===0});if(De||ze||Le){var qe=Number;var Ge=/^0b[01]+$/i;var We=/^0o[0-7]+$/i;var He=Ge.test.bind(Ge);var Be=We.test.bind(We);var $e=function(e){var t;if(typeof e.valueOf==="function"){t=e.valueOf();if(B.primitive(t)){return t}}if(typeof e.toString==="function"){t=e.toString();if(B.primitive(t)){return t}}throw new TypeError("No default value")};var Ve=ye.test.bind(ye);var Je=he.test.bind(he);var Ue=function(){var e=function Number(r){var n;if(arguments.length>0){n=B.primitive(r)?r:$e(r,"number")}else{n=0}if(typeof n==="string"){n=t(pe,n);if(He(n)){n=parseInt(T(n,2),2)}else if(Be(n)){n=parseInt(T(n,2),8)}else if(Ve(n)||Je(n)){n=NaN}}var o=this;var a=i(function(){qe.prototype.valueOf.call(o);return true});if(o instanceof e&&!a){return new qe(n)}return qe(n)};return e}();K(qe,Ue,{});Number=Ue;U.redefine(m,"Number",Ue)}var Ke=Math.pow(2,53)-1;h(Number,{MAX_SAFE_INTEGER:Ke,MIN_SAFE_INTEGER:-Ke,EPSILON:2.220446049250313e-16,parseInt:m.parseInt,parseFloat:m.parseFloat,isFinite:q,isInteger:function isInteger(e){return q(e)&&J.ToInteger(e)===e},isSafeInteger:function isSafeInteger(e){return Number.isInteger(e)&&C(e)<=Number.MAX_SAFE_INTEGER},isNaN:L});y(Number,"parseInt",m.parseInt,Number.parseInt!==m.parseInt);if(![,1].find(function(e,t){return t===0})){Q(Array.prototype,"find",Se.find)}if([,1].findIndex(function(e,t){return t===0})!==0){Q(Array.prototype,"findIndex",Se.findIndex)}var Xe=Function.bind.call(Function.bind,Object.prototype.propertyIsEnumerable);var Ze=function sliceArgs(){var e=Number(this);var t=arguments.length;var r=t-e;var n=new Array(r<0?0:r);for(var o=e;o1){return NaN}if(t===-1){return-Infinity}if(t===1){return Infinity}if(t===0){return t}return.5*A((1+t)/(1-t))},cbrt:function cbrt(e){var t=Number(e);if(t===0){return t}var r=t<0,n;if(r){t=-t}if(t===Infinity){n=Infinity}else{n=Math.exp(A(t)/3);n=(t/(n*n)+2*n)/3}return r?-n:n},clz32:function clz32(e){var r=Number(e);var n=J.ToUint32(r);if(n===0){return 32}return Rt?t(Rt,n):31-N(A(n+.5)*Math.LOG2E)},cosh:function cosh(e){var t=Number(e);if(t===0){return 1}if(Number.isNaN(t)){return NaN}if(!O(t)){return Infinity}if(t<0){t=-t}if(t>21){return Math.exp(t)/2}return(Math.exp(t)+Math.exp(-t))/2},expm1:function expm1(e){var t=Number(e);if(t===-Infinity){return-1}if(!O(t)||t===0){return t}if(C(t)>.5){return Math.exp(t)-1}var r=t;var n=0;var o=1;while(n+r!==n){n+=r;o+=1;r*=t/o}return n},hypot:function hypot(e,t){var r=0;var n=0;for(var o=0;o0?i/n*(i/n):i}}return n===Infinity?Infinity:n*k(r)},log2:function log2(e){return A(e)*Math.LOG2E},log10:function log10(e){return A(e)*Math.LOG10E},log1p:function log1p(e){var t=Number(e);if(t<-1||Number.isNaN(t)){return NaN}if(t===0||t===Infinity){return t}if(t===-1){return-Infinity}return 1+t-1===0?t:t*(A(1+t)/(1+t-1))},sign:function sign(e){var t=Number(e);if(t===0){return t}if(Number.isNaN(t)){return t}return t<0?-1:1},sinh:function sinh(e){var t=Number(e);if(!O(t)||t===0){return t}if(C(t)<1){return(Math.expm1(t)-Math.expm1(-t))/2}return(Math.exp(t-1)-Math.exp(-t-1))*Math.E/2},tanh:function tanh(e){var t=Number(e);if(Number.isNaN(t)||t===0){return t}if(t===Infinity){return 1}if(t===-Infinity){return-1}var r=Math.expm1(t);var n=Math.expm1(-t);if(r===Infinity){return 1}if(n===Infinity){return-1}return(r-n)/(Math.exp(t)+Math.exp(-t))},trunc:function trunc(e){var t=Number(e);return t<0?-N(-t):N(t)},imul:function imul(e,t){var r=J.ToUint32(e);var n=J.ToUint32(t);var o=r>>>16&65535;var i=r&65535;var a=n>>>16&65535;var u=n&65535;return i*u+(o*u+i*a<<16>>>0)|0},fround:function fround(e){var t=Number(e);if(t===0||t===Infinity||t===-Infinity||L(t)){return t}var r=Math.sign(t);var n=C(t);if(n<_t){return r*Ct(n/_t/At)*_t*At}var o=(1+At/Number.EPSILON)*n;var i=o-(o-n);if(i>kt||L(i)){return r*Infinity}return r*i}};h(Math,Ft);y(Math,"log1p",Ft.log1p,Math.log1p(-1e-17)!==-1e-17);y(Math,"asinh",Ft.asinh,Math.asinh(-1e7)!==-Math.asinh(1e7));y(Math,"tanh",Ft.tanh,Math.tanh(-2e-17)!==-2e-17);y(Math,"acosh",Ft.acosh,Math.acosh(Number.MAX_VALUE)===Infinity);y(Math,"cbrt",Ft.cbrt,Math.abs(1-Math.cbrt(1e-300)/1e-100)/Number.EPSILON>8);y(Math,"sinh",Ft.sinh,Math.sinh(-2e-17)!==-2e-17);var Dt=Math.expm1(10);y(Math,"expm1",Ft.expm1,Dt>22025.465794806718||Dt<22025.465794806718);var zt=Math.round;var Lt=Math.round(.5-Number.EPSILON/4)===0&&Math.round(-.5+Number.EPSILON/3.99)===1;var qt=Nt+1;var Gt=2*Nt-1;var Wt=[qt,Gt].every(function(e){return Math.round(e)===e});y(Math,"round",function round(e){var t=N(e);var r=t===-1?-0:t+1;return e-t<.5?t:r},!Lt||!Wt);U.preserveToString(Math.round,zt);var Ht=Math.imul;if(Math.imul(4294967295,5)!==-5){Math.imul=Ft.imul;U.preserveToString(Math.imul,Ht)}if(Math.imul.length!==2){Q(Math,"imul",function imul(t,r){return e(Ht,Math,arguments)})}var Bt=function(){var e=m.setTimeout;if(typeof e!=="function"&&typeof e!=="object"){return}J.IsPromise=function(e){if(!J.TypeIsObject(e)){return false}if(typeof e._promise==="undefined"){return false}return true};var r=function(e){if(!J.IsConstructor(e)){throw new TypeError("Bad promise constructor")}var t=this;var r=function(e,r){if(t.resolve!==void 0||t.reject!==void 0){throw new TypeError("Bad Promise implementation!")}t.resolve=e;t.reject=r};t.promise=new e(r);if(!(J.IsCallable(t.resolve)&&J.IsCallable(t.reject))){throw new TypeError("Bad promise constructor")}};var n;if(typeof window!=="undefined"&&J.IsCallable(window.postMessage)){n=function(){var e=[];var t="zero-timeout-message";var r=function(r){I(e,r);window.postMessage(t,"*")};var n=function(r){if(r.source===window&&r.data===t){r.stopPropagation();if(e.length===0){return}var n=M(e);n()}};window.addEventListener("message",n,true);return r}}var o=function(){var e=m.Promise;return e&&e.resolve&&function(t){return e.resolve().then(t)}};var i=J.IsCallable(m.setImmediate)?m.setImmediate.bind(m):typeof process==="object"&&process.nextTick?process.nextTick:o()||(J.IsCallable(n)?n():function(t){e(t,0)});var a=1;var u=2;var s=3;var f=4;var l=5;var p=function(e,t){var r=e.capabilities;var n=e.handler;var o,i=false,s;if(n===a){o=t}else if(n===u){o=t;i=true}else{try{o=n(t)}catch(f){o=f;i=true}}s=i?r.reject:r.resolve;s(o)};var v=function(e,t){c(e,function(e){i(function(){p(e,t)})})};var y=function(e,t){var r=e._promise;var n=r.fulfillReactions;r.result=t;r.fulfillReactions=void 0;r.rejectReactions=void 0;r.state=f;v(n,t)};var g=function(e,t){var r=e._promise;var n=r.rejectReactions;r.result=t;r.fulfillReactions=void 0;r.rejectReactions=void 0;r.state=l;v(n,t)};var b=function(e){var t=false;var r=function(r){var n;if(t){return}t=true;if(r===e){return g(e,new TypeError("Self resolution"))}if(!J.TypeIsObject(r)){return y(e,r)}try{n=r.then}catch(o){return g(e,o)}if(!J.IsCallable(n)){return y(e,r)}i(function(){d(e,r,n)})};var n=function(r){if(t){return}t=true;return g(e,r)};return{resolve:r,reject:n}};var d=function(e,r,n){var o=b(e);var i=o.resolve;var a=o.reject;try{t(n,r,i,a)}catch(u){a(u)}};var O=function(e){if(!J.TypeIsObject(e)){throw new TypeError("Promise is not object")}var t=e[z];if(t!==void 0&&t!==null){return t}return e};var w;var j=function(){var e=function Promise(t){if(!(this instanceof e)){throw new TypeError('Constructor Promise requires "new"')}if(this&&this._promise){throw new TypeError("Bad construction")}if(!J.IsCallable(t)){throw new TypeError("not a valid resolver")}var r=re(this,e,w,{_promise:{result:void 0,state:s,fulfillReactions:[],rejectReactions:[]}});var n=b(r);var o=n.reject;try{t(n.resolve,o)}catch(i){o(i)}return r};return e}();w=j.prototype;var S=function(e,t,r,n){var o=false;return function(i){if(o){return}o=true;t[e]=i;if(--n.count===0){var a=r.resolve;a(t)}}};var T=function(e,t,r){var n=e.iterator;var o=[],i={count:1},a,u;var s=0;while(true){try{a=J.IteratorStep(n);if(a===false){e.done=true;break}u=a.value}catch(f){e.done=true;throw f}o[s]=void 0;var c=t.resolve(u);var l=S(s,o,r,i);i.count+=1;c.then(l,r.reject);s+=1}if(--i.count===0){var p=r.resolve;p(o)}return r.promise};var E=function(e,t,r){var n=e.iterator,o,i,a;while(true){try{o=J.IteratorStep(n);if(o===false){e.done=true;break}i=o.value}catch(u){e.done=true;throw u}a=t.resolve(i);a.then(r.resolve,r.reject)}return r.promise};h(j,{all:function all(e){var t=O(this);var n=new r(t);var o,i;try{o=J.GetIterator(e);i={iterator:o,done:false};return T(i,t,n)}catch(a){var u=a;if(i&&!i.done){try{J.IteratorClose(o,true)}catch(s){u=s}}var f=n.reject;f(u);return n.promise}},race:function race(e){var t=O(this);var n=new r(t);var o,i;try{o=J.GetIterator(e);i={iterator:o,done:false};return E(i,t,n)}catch(a){var u=a;if(i&&!i.done){try{J.IteratorClose(o,true)}catch(s){u=s}}var f=n.reject;f(u);return n.promise}},reject:function reject(e){ 11 | var t=this;var n=new r(t);var o=n.reject;o(e);return n.promise},resolve:function resolve(e){var t=this;if(J.IsPromise(e)){var n=e.constructor;if(n===t){return e}}var o=new r(t);var i=o.resolve;i(e);return o.promise}});h(w,{"catch":function(e){return this.then(void 0,e)},then:function then(e,t){var n=this;if(!J.IsPromise(n)){throw new TypeError("not a promise")}var o=J.SpeciesConstructor(n,j);var c=new r(o);var v={capabilities:c,handler:J.IsCallable(e)?e:a};var y={capabilities:c,handler:J.IsCallable(t)?t:u};var h=n._promise;var g;if(h.state===s){I(h.fulfillReactions,v);I(h.rejectReactions,y)}else if(h.state===f){g=h.result;i(function(){p(v,g)})}else if(h.state===l){g=h.result;i(function(){p(y,g)})}else{throw new TypeError("unexpected Promise state")}return c.promise}});return j}();if(m.Promise){delete m.Promise.accept;delete m.Promise.defer;delete m.Promise.prototype.chain}if(typeof Bt==="function"){h(m,{Promise:Bt});var $t=b(m.Promise,function(e){return e.resolve(42).then(function(){})instanceof e});var Vt=!o(function(){m.Promise.reject(42).then(null,5).then(null,F)});var Jt=o(function(){m.Promise.call(3,F)});var Ut=function(e){var t=e.resolve(5);t.constructor={};var r=e.resolve(t);return t===r}(m.Promise);if(!$t||!Vt||!Jt||Ut){Promise=Bt;Q(m,"Promise",Bt)}Z(Promise)}var Kt=function(e){var t=Object.keys(l(e,function(e,t){e[t]=true;return e},{}));return e.join(":")===t.join(":")};var Xt=Kt(["z","a","bb"]);var Zt=Kt(["z",1,"a","3",2]);if(s){var Qt=function fastkey(e){if(!Xt){return null}var t=typeof e;if(t==="undefined"||e===null){return"^"+String(e)}else if(t==="string"){return"$"+e}else if(t==="number"){if(!Zt){return"n"+e}return e}else if(t==="boolean"){return"b"+e}return null};var Yt=function emptyObject(){return Object.create?Object.create(null):{}};var er=function addIterableToMap(e,n,o){if(r(o)||B.string(o)){c(o,function(e){n.set(e[0],e[1])})}else if(o instanceof e){t(e.prototype.forEach,o,function(e,t){n.set(t,e)})}else{var i,a;if(o!==null&&typeof o!=="undefined"){a=n.set;if(!J.IsCallable(a)){throw new TypeError("bad map")}i=J.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=J.IteratorStep(i);if(u===false){break}var s=u.value;try{if(!J.TypeIsObject(s)){throw new TypeError("expected iterable of pairs")}t(a,n,s[0],s[1])}catch(f){J.IteratorClose(i,true);throw f}}}}};var tr=function addIterableToSet(e,n,o){if(r(o)||B.string(o)){c(o,function(e){n.add(e)})}else if(o instanceof e){t(e.prototype.forEach,o,function(e){n.add(e)})}else{var i,a;if(o!==null&&typeof o!=="undefined"){a=n.add;if(!J.IsCallable(a)){throw new TypeError("bad set")}i=J.GetIterator(o)}if(typeof i!=="undefined"){while(true){var u=J.IteratorStep(i);if(u===false){break}var s=u.value;try{t(a,n,s)}catch(f){J.IteratorClose(i,true);throw f}}}}};var rr={Map:function(){var e={};var r=function MapEntry(e,t){this.key=e;this.value=t;this.next=null;this.prev=null};r.prototype.isRemoved=function isRemoved(){return this.key===e};var n=function isMap(e){return!!e._es6map};var o=function requireMapSlot(e,t){if(!J.TypeIsObject(e)||!n(e)){throw new TypeError("Method Map.prototype."+t+" called on incompatible receiver "+String(e))}};var i=function MapIterator(e,t){o(e,"[[MapIterator]]");this.head=e._head;this.i=this.head;this.kind=t};i.prototype={next:function next(){var e=this.i,t=this.kind,r=this.head,n;if(typeof this.i==="undefined"){return{value:void 0,done:true}}while(e.isRemoved()&&e!==r){e=e.prev}while(e.next!==r){e=e.next;if(!e.isRemoved()){if(t==="key"){n=e.key}else if(t==="value"){n=e.value}else{n=[e.key,e.value]}this.i=e;return{value:n,done:false}}}this.i=void 0;return{value:void 0,done:true}}};Y(i.prototype);var a;var u=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}if(this&&this._es6map){throw new TypeError("Bad construction")}var e=re(this,Map,a,{_es6map:true,_head:null,_storage:Yt(),_size:0});var t=new r(null,null);t.next=t.prev=t;e._head=t;if(arguments.length>0){er(Map,e,arguments[0])}return e};a=u.prototype;U.getter(a,"size",function(){if(typeof this._size==="undefined"){throw new TypeError("size method called on incompatible Map")}return this._size});h(a,{get:function get(e){o(this,"get");var t=Qt(e);if(t!==null){var r=this._storage[t];if(r){return r.value}else{return}}var n=this._head,i=n;while((i=i.next)!==n){if(J.SameValueZero(i.key,e)){return i.value}}},has:function has(e){o(this,"has");var t=Qt(e);if(t!==null){return typeof this._storage[t]!=="undefined"}var r=this._head,n=r;while((n=n.next)!==r){if(J.SameValueZero(n.key,e)){return true}}return false},set:function set(e,t){o(this,"set");var n=this._head,i=n,a;var u=Qt(e);if(u!==null){if(typeof this._storage[u]!=="undefined"){this._storage[u].value=t;return this}else{a=this._storage[u]=new r(e,t);i=n.prev}}while((i=i.next)!==n){if(J.SameValueZero(i.key,e)){i.value=t;return this}}a=a||new r(e,t);if(J.SameValue(-0,e)){a.key=+0}a.next=this._head;a.prev=this._head.prev;a.prev.next=a;a.next.prev=a;this._size+=1;return this},"delete":function(t){o(this,"delete");var r=this._head,n=r;var i=Qt(t);if(i!==null){if(typeof this._storage[i]==="undefined"){return false}n=this._storage[i].prev;delete this._storage[i]}while((n=n.next)!==r){if(J.SameValueZero(n.key,t)){n.key=n.value=e;n.prev.next=n.next;n.next.prev=n.prev;this._size-=1;return true}}return false},clear:function clear(){o(this,"clear");this._size=0;this._storage=Yt();var t=this._head,r=t,n=r.next;while((r=n)!==t){r.key=r.value=e;n=r.next;r.next=r.prev=t}t.next=t.prev=t},keys:function keys(){o(this,"keys");return new i(this,"key")},values:function values(){o(this,"values");return new i(this,"value")},entries:function entries(){o(this,"entries");return new i(this,"key+value")},forEach:function forEach(e){o(this,"forEach");var r=arguments.length>1?arguments[1]:null;var n=this.entries();for(var i=n.next();!i.done;i=n.next()){if(r){t(e,r,i.value[1],i.value[0],this)}else{e(i.value[1],i.value[0],this)}}}});Y(a,a.entries);return u}(),Set:function(){var e=function isSet(e){return e._es6set&&typeof e._storage!=="undefined"};var r=function requireSetSlot(t,r){if(!J.TypeIsObject(t)||!e(t)){throw new TypeError("Set.prototype."+r+" called on incompatible receiver "+String(t))}};var n;var o=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}if(this&&this._es6set){throw new TypeError("Bad construction")}var e=re(this,Set,n,{_es6set:true,"[[SetData]]":null,_storage:Yt()});if(!e._es6set){throw new TypeError("bad set")}if(arguments.length>0){tr(Set,e,arguments[0])}return e};n=o.prototype;var i=function ensureMap(e){if(!e["[[SetData]]"]){var t=e["[[SetData]]"]=new rr.Map;c(Object.keys(e._storage),function(e){var r=e;if(r==="^null"){r=null}else if(r==="^undefined"){r=void 0}else{var n=r.charAt(0);if(n==="$"){r=T(r,1)}else if(n==="n"){r=+T(r,1)}else if(n==="b"){r=r==="btrue"}else{r=+r}}t.set(r,r)});e._storage=null}};U.getter(o.prototype,"size",function(){r(this,"size");i(this);return this["[[SetData]]"].size});h(o.prototype,{has:function has(e){r(this,"has");var t;if(this._storage&&(t=Qt(e))!==null){return!!this._storage[t]}i(this);return this["[[SetData]]"].has(e)},add:function add(e){r(this,"add");var t;if(this._storage&&(t=Qt(e))!==null){this._storage[t]=true;return this}i(this);this["[[SetData]]"].set(e,e);return this},"delete":function(e){r(this,"delete");var t;if(this._storage&&(t=Qt(e))!==null){var n=_(this._storage,t);return delete this._storage[t]&&n}i(this);return this["[[SetData]]"]["delete"](e)},clear:function clear(){r(this,"clear");if(this._storage){this._storage=Yt()}else{this["[[SetData]]"].clear()}},values:function values(){r(this,"values");i(this);return this["[[SetData]]"].values()},entries:function entries(){r(this,"entries");i(this);return this["[[SetData]]"].entries()},forEach:function forEach(e){r(this,"forEach");var n=arguments.length>1?arguments[1]:null;var o=this;i(o);this["[[SetData]]"].forEach(function(r,i){if(n){t(e,n,i,i,o)}else{e(i,i,o)}})}});y(o.prototype,"keys",o.prototype.values,true);Y(o.prototype,o.prototype.values);return o}()};if(m.Map||m.Set){var nr=i(function(){return new Map([[1,2]]).get(1)===2});if(!nr){var or=m.Map;m.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new or;if(arguments.length>0){er(Map,e,arguments[0])}Object.setPrototypeOf(e,m.Map.prototype);y(e,"constructor",Map,true);return e};m.Map.prototype=g(or.prototype);U.preserveToString(m.Map,or)}var ir=new Map;var ar=function(e){e["delete"](0);e["delete"](-0);e.set(0,3);e.get(-0,4);return e.get(0)===3&&e.get(-0)===4}(ir);var ur=ir.set(1,2)===ir;if(!ar||!ur){var sr=Map.prototype.set;Q(Map.prototype,"set",function set(e,r){t(sr,this,e===0?0:e,r);return this})}if(!ar){var fr=Map.prototype.get;var cr=Map.prototype.has;h(Map.prototype,{get:function get(e){return t(fr,this,e===0?0:e)},has:function has(e){return t(cr,this,e===0?0:e)}},true);U.preserveToString(Map.prototype.get,fr);U.preserveToString(Map.prototype.has,cr)}var lr=new Set;var pr=function(e){e["delete"](0);e.add(-0);return!e.has(0)}(lr);var vr=lr.add(1)===lr;if(!pr||!vr){var yr=Set.prototype.add;Set.prototype.add=function add(e){t(yr,this,e===0?0:e);return this};U.preserveToString(Set.prototype.add,yr)}if(!pr){var hr=Set.prototype.has;Set.prototype.has=function has(e){return t(hr,this,e===0?0:e)};U.preserveToString(Set.prototype.has,hr);var gr=Set.prototype["delete"];Set.prototype["delete"]=function SetDelete(e){return t(gr,this,e===0?0:e)};U.preserveToString(Set.prototype["delete"],gr)}var br=b(m.Map,function(e){var t=new e([]);t.set(42,42);return t instanceof e});var dr=Object.setPrototypeOf&&!br;var mr=function(){try{return!(m.Map()instanceof m.Map)}catch(e){return e instanceof TypeError}}();if(m.Map.length!==0||dr||!mr){var Or=m.Map;m.Map=function Map(){if(!(this instanceof Map)){throw new TypeError('Constructor Map requires "new"')}var e=new Or;if(arguments.length>0){er(Map,e,arguments[0])}Object.setPrototypeOf(e,Map.prototype);y(e,"constructor",Map,true);return e};m.Map.prototype=Or.prototype;U.preserveToString(m.Map,Or)}var wr=b(m.Set,function(e){var t=new e([]);t.add(42,42);return t instanceof e});var jr=Object.setPrototypeOf&&!wr;var Sr=function(){try{return!(m.Set()instanceof m.Set)}catch(e){return e instanceof TypeError}}();if(m.Set.length!==0||jr||!Sr){var Tr=m.Set;m.Set=function Set(){if(!(this instanceof Set)){throw new TypeError('Constructor Set requires "new"')}var e=new Tr;if(arguments.length>0){tr(Set,e,arguments[0])}Object.setPrototypeOf(e,Set.prototype);y(e,"constructor",Set,true);return e};m.Set.prototype=Tr.prototype;U.preserveToString(m.Set,Tr)}var Ir=!i(function(){return(new Map).keys().next().done});if(typeof m.Map.prototype.clear!=="function"||(new m.Set).size!==0||(new m.Map).size!==0||typeof m.Map.prototype.keys!=="function"||typeof m.Set.prototype.keys!=="function"||typeof m.Map.prototype.forEach!=="function"||typeof m.Set.prototype.forEach!=="function"||a(m.Map)||a(m.Set)||typeof(new m.Map).keys().next!=="function"||Ir||!br){delete m.Map;delete m.Set;h(m,{Map:rr.Map,Set:rr.Set},true)}if(m.Set.prototype.keys!==m.Set.prototype.values){y(m.Set.prototype,"keys",m.Set.prototype.values,true)}Y(Object.getPrototypeOf((new m.Map).keys()));Y(Object.getPrototypeOf((new m.Set).keys()));if(f&&m.Set.prototype.has.name!=="has"){var Er=m.Set.prototype.has;Q(m.Set.prototype,"has",function has(e){return t(Er,this,e)})}}h(m,rr);Z(m.Map);Z(m.Set)}var Mr=function throwUnlessTargetIsObject(e){if(!J.TypeIsObject(e)){throw new TypeError("target must be an object")}};var Pr={apply:function apply(){return e(J.Call,null,arguments)},construct:function construct(e,t){if(!J.IsConstructor(e)){throw new TypeError("First argument must be a constructor.")}var r=arguments.length<3?e:arguments[2];if(!J.IsConstructor(r)){throw new TypeError("new.target must be a constructor.")}return J.Construct(e,t,r,"internal")},deleteProperty:function deleteProperty(e,t){Mr(e);if(s){var r=Object.getOwnPropertyDescriptor(e,t);if(r&&!r.configurable){return false}}return delete e[t]},enumerate:function enumerate(e){Mr(e);return new we(e,"key")},has:function has(e,t){Mr(e);return t in e}};if(Object.getOwnPropertyNames){Object.assign(Pr,{ownKeys:function ownKeys(e){Mr(e);var t=Object.getOwnPropertyNames(e);if(J.IsCallable(Object.getOwnPropertySymbols)){E(t,Object.getOwnPropertySymbols(e))}return t}})}var xr=function ConvertExceptionToBoolean(e){return!o(e)};if(Object.preventExtensions){Object.assign(Pr,{isExtensible:function isExtensible(e){Mr(e);return Object.isExtensible(e)},preventExtensions:function preventExtensions(e){Mr(e);return xr(function(){Object.preventExtensions(e)})}})}if(s){var Nr=function get(e,r,n){var o=Object.getOwnPropertyDescriptor(e,r);if(!o){var i=Object.getPrototypeOf(e);if(i===null){return undefined}return Nr(i,r,n)}if("value"in o){return o.value}if(o.get){return t(o.get,n)}return undefined};var Cr=function set(e,r,n,o){var i=Object.getOwnPropertyDescriptor(e,r);if(!i){var a=Object.getPrototypeOf(e);if(a!==null){return Cr(a,r,n,o)}i={value:void 0,writable:true,enumerable:true,configurable:true}}if("value"in i){if(!i.writable){return false}if(!J.TypeIsObject(o)){return false}var u=Object.getOwnPropertyDescriptor(o,r);if(u){return V.defineProperty(o,r,{value:n})}else{return V.defineProperty(o,r,{value:n,writable:true,enumerable:true,configurable:true})}}if(i.set){t(i.set,o,n);return true}return false};Object.assign(Pr,{defineProperty:function defineProperty(e,t,r){Mr(e);return xr(function(){Object.defineProperty(e,t,r)})},getOwnPropertyDescriptor:function getOwnPropertyDescriptor(e,t){Mr(e);return Object.getOwnPropertyDescriptor(e,t)},get:function get(e,t){Mr(e);var r=arguments.length>2?arguments[2]:e;return Nr(e,t,r)},set:function set(e,t,r){Mr(e);var n=arguments.length>3?arguments[3]:e;return Cr(e,t,r,n)}})}if(Object.getPrototypeOf){var Ar=Object.getPrototypeOf;Pr.getPrototypeOf=function getPrototypeOf(e){Mr(e);return Ar(e)}}if(Object.setPrototypeOf&&Pr.getPrototypeOf){var kr=function(e,t){var r=t;while(r){if(e===r){return true}r=Pr.getPrototypeOf(r)}return false};Object.assign(Pr,{setPrototypeOf:function setPrototypeOf(e,t){Mr(e);if(t!==null&&!J.TypeIsObject(t)){throw new TypeError("proto must be an object or null")}if(t===V.getPrototypeOf(e)){return true}if(V.isExtensible&&!V.isExtensible(e)){return false}if(kr(e,t)){return false}Object.setPrototypeOf(e,t);return true}})}var _r=function(e,t){if(!J.IsCallable(m.Reflect[e])){y(m.Reflect,e,t)}else{var r=i(function(){m.Reflect[e](1);m.Reflect[e](NaN);m.Reflect[e](true);return true});if(r){Q(m.Reflect,e,t)}}};Object.keys(Pr).forEach(function(e){_r(e,Pr[e])});if(f&&m.Reflect.getPrototypeOf.name!=="getPrototypeOf"){var Rr=m.Reflect.getPrototypeOf;Q(m.Reflect,"getPrototypeOf",function getPrototypeOf(e){return t(Rr,m.Reflect,e)})}if(m.Reflect.setPrototypeOf){if(i(function(){m.Reflect.setPrototypeOf(1,{});return true})){Q(m.Reflect,"setPrototypeOf",Pr.setPrototypeOf)}}if(m.Reflect.defineProperty){if(!i(function(){var e=!m.Reflect.defineProperty(1,"test",{value:1});var t=typeof Object.preventExtensions!=="function"||!m.Reflect.defineProperty(Object.preventExtensions({}),"test",{});return e&&t})){Q(m.Reflect,"defineProperty",Pr.defineProperty)}}if(m.Reflect.construct){if(!i(function(){var e=function F(){};return m.Reflect.construct(function(){},[],e)instanceof e})){Q(m.Reflect,"construct",Pr.construct)}}if(String(new Date(NaN))!=="Invalid Date"){var Fr=Date.prototype.toString;var Dr=function toString(){var e=+this;if(e!==e){return"Invalid Date"}return t(Fr,this)};Q(Date.prototype,"toString",Dr)}var zr={anchor:function anchor(e){return J.CreateHTML(this,"a","name",e)},big:function big(){return J.CreateHTML(this,"big","","")},blink:function blink(){return J.CreateHTML(this,"blink","","")},bold:function bold(){return J.CreateHTML(this,"b","","")},fixed:function fixed(){return J.CreateHTML(this,"tt","","")},fontcolor:function fontcolor(e){return J.CreateHTML(this,"font","color",e)},fontsize:function fontsize(e){return J.CreateHTML(this,"font","size",e)},italics:function italics(){return J.CreateHTML(this,"i","","")},link:function link(e){return J.CreateHTML(this,"a","href",e)},small:function small(){return J.CreateHTML(this,"small","","")},strike:function strike(){return J.CreateHTML(this,"strike","","")},sub:function sub(){return J.CreateHTML(this,"sub","","")},sup:function sub(){return J.CreateHTML(this,"sup","","")}};c(Object.keys(zr),function(e){var r=String.prototype[e];var n=false;if(J.IsCallable(r)){var o=t(r,"",' " ');var i=S([],o.match(/"/g)).length;n=o!==o.toLowerCase()||i>2}else{n=true}if(n){Q(String.prototype,e,zr[e])}});var Lr=function(){if(!B.symbol(D.iterator)){return false}var e=typeof JSON==="object"&&typeof JSON.stringify==="function"?JSON.stringify:null;if(!e){return false}if(typeof e(D())!=="undefined"){return true}if(e([D()])!=="[null]"){return true}var t={a:D()};t[D()]=true;if(e(t)!=="{}"){return true}return false}();var qr=i(function(){if(!B.symbol(D.iterator)){return true}return JSON.stringify(Object(D()))==="{}"&&JSON.stringify([Object(D())])==="[{}]"});if(Lr||!qr){var Gr=JSON.stringify;Q(JSON,"stringify",function stringify(e){if(typeof e==="symbol"){return}var n;if(arguments.length>1){n=arguments[1]}var o=[e];if(!r(n)){var i=J.IsCallable(n)?n:null;var a=function(e,r){var o=n?t(n,this,e,r):r;if(typeof o!=="symbol"){if(B.symbol(o)){return Qe({})(o)}else{return o}}};o.push(a)}else{o.push(n)}if(arguments.length>2){o.push(arguments[2])}return Gr.apply(this,o)})}return m}); 12 | //# sourceMappingURL=es6-shim.map 13 | --------------------------------------------------------------------------------