├── CL-LON-SpeakToGo-Soundboard ├── sounds │ ├── chime.mp3 │ ├── chime.ogg │ ├── error.mp3 │ └── error.ogg ├── CONTRIBUTING.md ├── README.md ├── index.html ├── js │ └── SoundBoard.js └── LICENSE ├── CL-LON-SpeakToGo-Twixt ├── CONTRIBUTING.md ├── README.md ├── index.html ├── js │ └── Twixt.js └── LICENSE ├── CL-LON-SpeakToGo-THREE.TextTexture ├── CONTRIBUTING.md ├── README.md ├── js │ └── Text.js ├── index.html ├── LICENSE └── third_party │ └── OrbitControls.js └── README.md /CL-LON-SpeakToGo-Soundboard/sounds/chime.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlecreativelab/webvr-speaktogo/HEAD/CL-LON-SpeakToGo-Soundboard/sounds/chime.mp3 -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/sounds/chime.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlecreativelab/webvr-speaktogo/HEAD/CL-LON-SpeakToGo-Soundboard/sounds/chime.ogg -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/sounds/error.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlecreativelab/webvr-speaktogo/HEAD/CL-LON-SpeakToGo-Soundboard/sounds/error.mp3 -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/sounds/error.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlecreativelab/webvr-speaktogo/HEAD/CL-LON-SpeakToGo-Soundboard/sounds/error.ogg -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Twixt/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution, 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Speak To Go 2 | 3 | Some libraries used in **[Speak To Go](https://speaktogo.withgoogle.com/)** 4 | 5 | 6 | **[Soundboard](https://github.com/googlecreativelab/webvr-speaktogo/tree/master/CL-LON-SpeakToGo-Soundboard)** Very simple library to load and play sounds with Web Audio API 7 | 8 | **[THREE.TextTexture](https://github.com/googlecreativelab/webvr-speaktogo/tree/master/CL-LON-SpeakToGo-THREE.TextTexture)** A wrapper of THREE.CanvasTexture to easily draw text, used for setting up UIs in VR quickly 9 | 10 | **[Twixt](https://github.com/googlecreativelab/webvr-speaktogo/tree/master/CL-LON-SpeakToGo-Twixt)** A very straightforward tweening library, with Promises 11 | 12 | #### License #### 13 | 14 | Copyright 2017 Google Inc. 15 | 16 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 17 | 18 | http://www.apache.org/licenses/LICENSE-2.0 19 | 20 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 21 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/README.md: -------------------------------------------------------------------------------- 1 | # Soundboard 2 | 3 | Very simple library to load and play sounds with Web Audio API. 4 | 5 | This is not an official Google product. 6 | 7 | #### How to use #### 8 | Include the script in your project: 9 | ```html 10 | 11 | ``` 12 | Define a new instance of `Soundboard`, providing an array of sources ( `'sound_id': 'path/to/file_without_extension'` ): 13 | ```js 14 | let soundboard = new SoundBoard({ 15 | 'ok': 'sounds/ok', 16 | 'error': 'sounds/error' 17 | }); 18 | ``` 19 | Soundboard will look for the filenames, load them using an .mp3 or .ogg extension depending on the browser playback support, and map them to the specified sound_id. 20 | 21 | To play back the sound when needed, just use `.play( sound_id )`: 22 | ```js 23 | soundboard.play( 'ok' ); 24 | ``` 25 | 26 | #### License #### 27 | 28 | Copyright 2017 Google Inc. 29 | 30 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 31 | 32 | http://www.apache.org/licenses/LICENSE-2.0 33 | 34 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 35 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Speak to Go - Soundboard 7 | 8 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |

Soundboard

29 |

The sounds are loaded automatically, press any of the buttons to play the sound.

30 | 31 |

    32 |
  • 33 |
  • 34 |

35 | 36 | 37 | 38 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/README.md: -------------------------------------------------------------------------------- 1 | # THREE.TextTexture 2 | 3 | A wrapper of THREE.CanvasTexture to easily draw text, used for setting up UIs in VR quickly. 4 | 5 | This is not an official Google product. 6 | 7 | #### How to use #### 8 | Include the script in your project after `three.js` has been included: 9 | ```html 10 | 11 | 12 | ``` 13 | Create a Text object passing your WebGLRenderer instance, width and height of the resulting texture: 14 | ```js 15 | let text = new Text( renderer, 1024, 512 ); 16 | scene.add( text.mesh ); 17 | ``` 18 | Add the mesh object to your scene, that will add a plane mesh to your scene with the aspect ratio of the specified dimensions. 19 | 20 | Set text whenever you need an update by using Text.set( sentences ): 21 | ```js 22 | // sentences can be a single sentence 23 | text.set( 'hello world' ); 24 | 25 | // or an array of sentences that will act as multiline 26 | text.set( [ 'hello', 'there,', 'world' ] ); 27 | ``` 28 | Text has a built-in text-splitting mechanism that will prevent lines from being cut horizontally. 29 | #### Changing styles #### 30 | The text uses a white 50px Robot font with some drop shadow effect. Make sure you include in your HTML the fontface you want to use. 31 | To change style or effects, you'll have to change the code Text.set. 32 | #### License #### 33 | 34 | Copyright 2017 Google Inc. 35 | 36 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 37 | 38 | http://www.apache.org/licenses/LICENSE-2.0 39 | 40 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 41 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Twixt/README.md: -------------------------------------------------------------------------------- 1 | # Twixt 2 | 3 | A very straightforward tweening library, with Promises. 4 | 5 | This is not an official Google product. 6 | 7 | #### How to use #### 8 | Include the script in your project: 9 | ```html 10 | 11 | ``` 12 | This will create a global **Twixt** object. 13 | 14 | You can create twixted values by using `Twixt.create`: 15 | ```js 16 | // Twixt.create takes an initial value and an easing mode 17 | let a = Twixt.create( 0, 'Linear' ); 18 | let b = Twixt.create( 100, 'InOutQuint' ); 19 | ``` 20 | From there, you can tween to any value by using .to(): 21 | ```js 22 | // a goes to 1 in 100ms in a Linear tween 23 | a.to( 1, 100 ); 24 | 25 | // b goes to 0 in 500ms using InOutQuint tween after a delay of 100ms 26 | b.to( 0, 500, 'InOutQuint', 100 ) 27 | ``` 28 | Twixt values' `.to()` method returns a promise, so you can chain events or do something when the tween is completed: 29 | ```js 30 | a.to( 0, 100 ).then( () => { 31 | b.to( 100, 200 ).then( () => { 32 | console.log( 'done!' ); 33 | }); 34 | }); 35 | ``` 36 | You can delete tweened values by calling `Twixt.destroy`: 37 | ``` 38 | Twixt.destroy( a ); 39 | ``` 40 | #### Auto updated 41 | Twixt will autoupdate using its own `window.requestAnimationFrame` unless you specify `Twixt.autoUpdate = false;`. In that case, you have to update it manually by calling `Twixt.update();` from inside your animation loop. 42 | #### Available tweening equations 43 | There's only Linear, and In, Out and InOutQuint for now 44 | #### License #### 45 | 46 | Copyright 2017 Google Inc. 47 | 48 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 49 | 50 | http://www.apache.org/licenses/LICENSE-2.0 51 | 52 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 53 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Twixt/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Speak to Go - Twixt 7 | 8 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

Twixt

30 |

Click on the screen. The dot will move to the clicked position in 500ms, stay there for 500ms and then go back to the center of the screen in 1s.

31 | 32 | 33 | 34 | 35 | 36 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/js/SoundBoard.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | /** 18 | * Very simple library to load and play sounds with Web Audio API. 19 | */ 20 | class SoundBoard { 21 | 22 | /** 23 | * Create a SoundBoard object 24 | * 25 | * @param {Object} sounds the id and sound sources 26 | */ 27 | 28 | constructor ( sounds ) { 29 | 30 | const audio = new Audio(); 31 | this.canPlayMp3 = audio.canPlayType( 'audio/mp3' ) !== ''; 32 | this.canPlayOgg = audio.canPlayType( 'audio/ogg' ) !== ''; 33 | 34 | this.sounds = sounds; 35 | 36 | let AudioContext = window.AudioContext || window.webkitAudioContext; 37 | 38 | if( AudioContext === undefined ) { 39 | this.soundEnabled = false; 40 | return; 41 | } 42 | 43 | this.soundEnabled = true; 44 | this.context = new AudioContext(); 45 | this.buffers = {}; 46 | 47 | for( const j in this.sounds ) { 48 | this.loadFile( j, this.sounds[ j ] ); 49 | } 50 | 51 | } 52 | 53 | /** 54 | * Play a previously loaded sound by id 55 | * 56 | * @param {string} id Play the sound with the passed if 57 | */ 58 | 59 | play( id ) { 60 | 61 | if( !this.soundEnabled ) return; 62 | 63 | const source = this.context.createBufferSource(); 64 | source.buffer = this.buffers[ id ]; 65 | source.connect(this.context.destination); 66 | source.start(0); 67 | 68 | } 69 | 70 | /** 71 | * Load a sound via XmlHttpRequest and decodes it 72 | * with Web Audio decodeAudioData 73 | * 74 | * @param {string} id id of the sound to load 75 | * @param {string} path path to the file to load, without extension 76 | */ 77 | 78 | loadFile( id, file ) { 79 | 80 | const context = this.context; 81 | const buffers = this.buffers; 82 | 83 | const extension = this.canPlayMp3 ? '.mp3' : '.ogg'; 84 | 85 | const request = new XMLHttpRequest(); 86 | request.open('GET', file + extension, true); 87 | request.responseType = 'arraybuffer'; 88 | 89 | request.onload = () => { 90 | context.decodeAudioData(request.response, buffer => { 91 | buffers[ id ] = buffer; 92 | }, () => { 93 | console.log( 'error' ); 94 | }); 95 | } 96 | request.send(); 97 | 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/js/Text.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | /** 18 | * A wrapper of THREE.CanvasTexture to easily draw text, 19 | * used for setting up UIs in VR quickly. 20 | */ 21 | 22 | class Text { 23 | 24 | /** 25 | * Create a SoundBoard object 26 | * 27 | * @param {WebGLRendererObject} renderer current renderer 28 | * @param {Number} width texture width 29 | * @param {Number} height texture height 30 | */ 31 | 32 | constructor( renderer, width, height ) { 33 | 34 | this.renderer = renderer; 35 | 36 | this.multiplier = 1; 37 | this.width = width * this.multiplier; 38 | this.height = height * this.multiplier; 39 | 40 | this.canvas = document.createElement( 'canvas' ); 41 | this.ctx = this.canvas.getContext( '2d' ); 42 | 43 | this.canvas.width = this.width; 44 | this.canvas.height = this.height; 45 | 46 | this.texture = new THREE.CanvasTexture( this.canvas ); 47 | this.texture.generateMipMaps = !true; 48 | this.texture.anisotropy = renderer.getMaxAnisotropy(); 49 | this.texture.minFilter = THREE.LinearMipMapLinearFilter; 50 | this.texture.magFilter = THREE.LinearFilter; 51 | this.material = new THREE.RawShaderMaterial( { 52 | uniforms:{ 53 | opacity: { type: 'f', value: 1 }, 54 | map: { type: 't', value: this.texture } 55 | }, 56 | side: THREE.DoubleSide, 57 | transparent: true, 58 | vertexShader: `attribute vec3 position; 59 | attribute vec2 uv; 60 | 61 | uniform mat4 modelViewMatrix; 62 | uniform mat4 projectionMatrix; 63 | 64 | varying vec2 vUv; 65 | 66 | void main() { 67 | 68 | vec4 mVPos = modelViewMatrix * vec4( position, 1.0 ); 69 | 70 | vUv = uv; 71 | gl_Position = projectionMatrix * mVPos; 72 | 73 | }`, 74 | fragmentShader: `precision highp float; 75 | 76 | uniform sampler2D map; 77 | uniform float opacity; 78 | 79 | varying vec2 vUv; 80 | 81 | void main() { 82 | 83 | vec4 c = texture2D( map, vUv ); 84 | c.a *= opacity; 85 | if( c.a == 0. ) discard; 86 | 87 | gl_FragColor = c; 88 | 89 | }`, 90 | wireframe: !true 91 | } ); 92 | let w = width / 512; 93 | let h = height / 512; 94 | this.mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( w, h ), this.material ); 95 | 96 | } 97 | 98 | /** 99 | * Internal method to split sentences 100 | * 101 | * @param {string} str String to fit 102 | */ 103 | 104 | fitSplit ( str ) { 105 | 106 | const maxLength = 40; 107 | const regex = /(\S+)[\W]*/gmi; 108 | let m; 109 | let partial = ''; 110 | let res = []; 111 | 112 | while ((m = regex.exec(str)) !== null) { 113 | 114 | if (m.index === regex.lastIndex) { 115 | regex.lastIndex++; 116 | } 117 | 118 | let p = m[ 0 ]; 119 | if( partial.length + p.length < maxLength ) { 120 | partial += p; 121 | } else { 122 | res.push( partial ); 123 | partial = p; 124 | } 125 | 126 | } 127 | 128 | res.push( partial ); 129 | 130 | return res; 131 | 132 | } 133 | 134 | /** 135 | * Update text with canvas 136 | * 137 | * @param {Object} sentences sentences to draw 138 | */ 139 | 140 | set ( sentences ) { 141 | 142 | if( typeof sentences !== 'object' ) sentences = [ sentences ]; 143 | let splitSentences = []; 144 | sentences.forEach( s => { 145 | splitSentences = splitSentences.concat( this.fitSplit( s ) ); 146 | }) 147 | 148 | const border = 4; 149 | const h = 50 * this.multiplier; 150 | 151 | const fw = this.width; 152 | const fh = this.height; 153 | 154 | this.ctx.clearRect( 0, 0, this.canvas.width, this.canvas.height ); 155 | 156 | this.ctx.textBaseline = 'middle'; 157 | this.ctx.font = `${h}px Roboto`; 158 | 159 | this.ctx.shadowColor = '#000000'; 160 | this.ctx.shadowBlur = border; 161 | this.ctx.shadowOffsetX = 0; 162 | this.ctx.shadowOffsetY = 0; 163 | 164 | const sy = .5 * ( fh - ( splitSentences.length - 1 ) * h ); 165 | this.ctx.textAlign = 'center'; 166 | this.ctx.fillStyle = '#ffffff'; 167 | splitSentences.forEach( ( s, i ) => { 168 | this.ctx.strokeText( s, .5 * fw - border, sy + h * i ); 169 | this.ctx.fillText( s, .5 * fw - border, sy + h * i ); 170 | this.ctx.fillText( s, .5 * fw - border, sy + h * i ); 171 | }); 172 | 173 | this.texture.needsUpdate = true; 174 | 175 | } 176 | } 177 | 178 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Twixt/js/Twixt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 13 | * or implied. See the License for the specific language governing 14 | * permissions and limitations under the License. 15 | */ 16 | 17 | /** 18 | * A very straightforward tweening library, with Promises 19 | */ 20 | 21 | ((() => { 22 | 23 | /** 24 | * Easing equations repository 25 | * TO DO: Add as many methods as necessary 26 | */ 27 | 28 | const Easings = { 29 | 30 | Linear(t) { return t; }, 31 | 32 | InQuint(t) { return t * t * t * t * t; }, 33 | OutQuint(t) { return --t * t * t * t * t + 1; }, 34 | InOutQuint(t) { 35 | if ((t *= 2) < 1) return 0.5 * t * t * t * t * t; 36 | return 0.5 * ((t -= 2) * t * t * t * t + 2); 37 | } 38 | 39 | }; 40 | 41 | class Twixt { 42 | 43 | /** 44 | * Create a Twixt object 45 | */ 46 | 47 | constructor() { 48 | 49 | this.count = 0; 50 | this.values = {} 51 | this.autoUpdate = true; 52 | 53 | this._update = this.update.bind( this ); 54 | this._update(); 55 | 56 | } 57 | 58 | /** 59 | * Create a TwixtValue object 60 | * 61 | * @param {Number} value the original value for the TwixtValue 62 | * @param {String} easing tweening equation (default is Linear) 63 | */ 64 | 65 | create( value, easing ) { 66 | 67 | const v = new TwixtValue( value, easing ); 68 | v.id = this.count; 69 | this.count++; 70 | this.values[ v.id ] = v; 71 | return v; 72 | 73 | } 74 | 75 | /** 76 | * Destroy a TwixtValue object 77 | * 78 | * @param {Object} v the value to be destroyed 79 | */ 80 | 81 | destroy( v ) { 82 | 83 | if( this.values[ v.id ] ) { 84 | delete this.values[ v.id ]; 85 | } 86 | 87 | } 88 | 89 | /** 90 | * Updates all active TwixtValues 91 | * 92 | */ 93 | 94 | update() { 95 | 96 | const time = performance.now(); 97 | 98 | Object.keys( this.values ).forEach( v => { 99 | const value = this.values[ v ]; 100 | this.updateValue( value, time ); 101 | } ); 102 | 103 | if( this.autoUpdate ) requestAnimationFrame( this._update ); 104 | 105 | } 106 | 107 | /** 108 | * Update a single TwixtValue 109 | * 110 | * @param {Object} value the value to update 111 | * @param {Number} time the current time from the update tick 112 | * @param {Number} delay delay value from the value 113 | */ 114 | 115 | updateValue( value, time, delay ) { 116 | 117 | let nValue; 118 | let reached = false; 119 | 120 | if( value.duration === 0 ) { 121 | 122 | nValue = value.target; 123 | reached = true; 124 | 125 | } else { 126 | 127 | const fn = value.easing; 128 | let t = time - value.startTime - value.delayTime; 129 | t /= value.duration; 130 | 131 | t = fn( t ); 132 | 133 | if( t < 0 ) { nValue = value.origin; } 134 | else if( t >= 1 ) { nValue = value.target; reached = true; } 135 | else { 136 | nValue = value.origin + t * ( value.target - value.origin ); 137 | } 138 | 139 | } 140 | 141 | value.value = nValue; 142 | if( reached && value.reached === false ) { 143 | value.reached = true; 144 | if( value.onReached ) { 145 | value.onReached(); 146 | value.onReached = null; 147 | } 148 | } 149 | 150 | } 151 | } 152 | 153 | /** 154 | * A TwixtValue than can be tweened 155 | */ 156 | 157 | class TwixtValue { 158 | 159 | 160 | /** 161 | * Create a single TwixtValue 162 | * 163 | * @param {Object} value original value 164 | * @param {String} easing easing method 165 | */ 166 | 167 | constructor(value, easing) { 168 | 169 | this.value = value || 0; 170 | this.origin = value || 0; 171 | this.target = value || 0; 172 | this.easing = easing ? Easings[ easing ] : Easings.Linear; 173 | this.startTime = 0; 174 | this.delayTime = 0; 175 | this.duration = 0; 176 | this.reached = false; 177 | 178 | } 179 | 180 | /** 181 | * Tween to target value 182 | * 183 | * @param {Number} to target value 184 | * @param {Number} duration tweening duration 185 | * @param {String} easing easing method 186 | * @param {Number} delay starting delay 187 | */ 188 | 189 | to(target, duration, easing, delay ) { 190 | 191 | this.origin = this.value; 192 | this.startTime = performance.now(); 193 | this.delayTime = delay || 0; 194 | this.easing = Easings[ easing ] || this.easing; 195 | this.target = target; 196 | this.duration = duration || 0; 197 | this.reached = false; 198 | 199 | const value = this; 200 | 201 | return new Promise( ( resolve, reject ) => { 202 | value.onReached = resolve; 203 | }); 204 | 205 | } 206 | 207 | } 208 | 209 | window.Twixt = new Twixt(); 210 | 211 | }))(window); 212 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Speak to Go - THREE.TextTexture 7 | 8 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

Text

32 |

33 | 34 | 35 | 36 | 37 | 38 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Twixt/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2017 Google Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-Soundboard/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2017 Google Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2017 Google Inc. 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /CL-LON-SpeakToGo-THREE.TextTexture/third_party/OrbitControls.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author qiao / https://github.com/qiao 3 | * @author mrdoob / http://mrdoob.com 4 | * @author alteredq / http://alteredqualia.com/ 5 | * @author WestLangley / http://github.com/WestLangley 6 | * @author erich666 / http://erichaines.com 7 | */ 8 | 9 | // This set of controls performs orbiting, dollying (zooming), and panning. 10 | // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). 11 | // 12 | // Orbit - left mouse / touch: one finger move 13 | // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish 14 | // Pan - right mouse, or arrow keys / touch: three finger swipe 15 | 16 | THREE.OrbitControls = function ( object, domElement ) { 17 | 18 | this.object = object; 19 | 20 | this.domElement = ( domElement !== undefined ) ? domElement : document; 21 | 22 | // Set to false to disable this control 23 | this.enabled = true; 24 | 25 | // "target" sets the location of focus, where the object orbits around 26 | this.target = new THREE.Vector3(); 27 | 28 | // How far you can dolly in and out ( PerspectiveCamera only ) 29 | this.minDistance = 0; 30 | this.maxDistance = Infinity; 31 | 32 | // How far you can zoom in and out ( OrthographicCamera only ) 33 | this.minZoom = 0; 34 | this.maxZoom = Infinity; 35 | 36 | // How far you can orbit vertically, upper and lower limits. 37 | // Range is 0 to Math.PI radians. 38 | this.minPolarAngle = 0; // radians 39 | this.maxPolarAngle = Math.PI; // radians 40 | 41 | // How far you can orbit horizontally, upper and lower limits. 42 | // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ]. 43 | this.minAzimuthAngle = - Infinity; // radians 44 | this.maxAzimuthAngle = Infinity; // radians 45 | 46 | // Set to true to enable damping (inertia) 47 | // If damping is enabled, you must call controls.update() in your animation loop 48 | this.enableDamping = false; 49 | this.dampingFactor = 0.25; 50 | 51 | // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. 52 | // Set to false to disable zooming 53 | this.enableZoom = true; 54 | this.zoomSpeed = 1.0; 55 | 56 | // Set to false to disable rotating 57 | this.enableRotate = true; 58 | this.rotateSpeed = 1.0; 59 | 60 | // Set to false to disable panning 61 | this.enablePan = true; 62 | this.keyPanSpeed = 7.0; // pixels moved per arrow key push 63 | 64 | // Set to true to automatically rotate around the target 65 | // If auto-rotate is enabled, you must call controls.update() in your animation loop 66 | this.autoRotate = false; 67 | this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60 68 | 69 | // Set to false to disable use of the keys 70 | this.enableKeys = true; 71 | 72 | // The four arrow keys 73 | this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }; 74 | 75 | // Mouse buttons 76 | this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT }; 77 | 78 | // for reset 79 | this.target0 = this.target.clone(); 80 | this.position0 = this.object.position.clone(); 81 | this.zoom0 = this.object.zoom; 82 | 83 | // 84 | // public methods 85 | // 86 | 87 | this.getPolarAngle = function () { 88 | 89 | return spherical.phi; 90 | 91 | }; 92 | 93 | this.getAzimuthalAngle = function () { 94 | 95 | return spherical.theta; 96 | 97 | }; 98 | 99 | this.saveState = function () { 100 | 101 | scope.target0.copy( scope.target ); 102 | scope.position0.copy( scope.object.position ); 103 | scope.zoom0 = scope.object.zoom; 104 | 105 | }; 106 | 107 | this.reset = function () { 108 | 109 | scope.target.copy( scope.target0 ); 110 | scope.object.position.copy( scope.position0 ); 111 | scope.object.zoom = scope.zoom0; 112 | 113 | scope.object.updateProjectionMatrix(); 114 | scope.dispatchEvent( changeEvent ); 115 | 116 | scope.update(); 117 | 118 | state = STATE.NONE; 119 | 120 | }; 121 | 122 | // this method is exposed, but perhaps it would be better if we can make it private... 123 | this.update = function () { 124 | 125 | var offset = new THREE.Vector3(); 126 | 127 | // so camera.up is the orbit axis 128 | var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) ); 129 | var quatInverse = quat.clone().inverse(); 130 | 131 | var lastPosition = new THREE.Vector3(); 132 | var lastQuaternion = new THREE.Quaternion(); 133 | 134 | return function update() { 135 | 136 | var position = scope.object.position; 137 | 138 | offset.copy( position ).sub( scope.target ); 139 | 140 | // rotate offset to "y-axis-is-up" space 141 | offset.applyQuaternion( quat ); 142 | 143 | // angle from z-axis around y-axis 144 | spherical.setFromVector3( offset ); 145 | 146 | if ( scope.autoRotate && state === STATE.NONE ) { 147 | 148 | rotateLeft( getAutoRotationAngle() ); 149 | 150 | } 151 | 152 | spherical.theta += sphericalDelta.theta; 153 | spherical.phi += sphericalDelta.phi; 154 | 155 | // restrict theta to be between desired limits 156 | spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) ); 157 | 158 | // restrict phi to be between desired limits 159 | spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); 160 | 161 | spherical.makeSafe(); 162 | 163 | 164 | spherical.radius *= scale; 165 | 166 | // restrict radius to be between desired limits 167 | spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); 168 | 169 | // move target to panned location 170 | scope.target.add( panOffset ); 171 | 172 | offset.setFromSpherical( spherical ); 173 | 174 | // rotate offset back to "camera-up-vector-is-up" space 175 | offset.applyQuaternion( quatInverse ); 176 | 177 | position.copy( scope.target ).add( offset ); 178 | 179 | scope.object.lookAt( scope.target ); 180 | 181 | if ( scope.enableDamping === true ) { 182 | 183 | sphericalDelta.theta *= ( 1 - scope.dampingFactor ); 184 | sphericalDelta.phi *= ( 1 - scope.dampingFactor ); 185 | 186 | } else { 187 | 188 | sphericalDelta.set( 0, 0, 0 ); 189 | 190 | } 191 | 192 | scale = 1; 193 | panOffset.set( 0, 0, 0 ); 194 | 195 | // update condition is: 196 | // min(camera displacement, camera rotation in radians)^2 > EPS 197 | // using small-angle approximation cos(x/2) = 1 - x^2 / 8 198 | 199 | if ( zoomChanged || 200 | lastPosition.distanceToSquared( scope.object.position ) > EPS || 201 | 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { 202 | 203 | scope.dispatchEvent( changeEvent ); 204 | 205 | lastPosition.copy( scope.object.position ); 206 | lastQuaternion.copy( scope.object.quaternion ); 207 | zoomChanged = false; 208 | 209 | return true; 210 | 211 | } 212 | 213 | return false; 214 | 215 | }; 216 | 217 | }(); 218 | 219 | this.dispose = function () { 220 | 221 | scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false ); 222 | scope.domElement.removeEventListener( 'mousedown', onMouseDown, false ); 223 | scope.domElement.removeEventListener( 'wheel', onMouseWheel, false ); 224 | 225 | scope.domElement.removeEventListener( 'touchstart', onTouchStart, false ); 226 | scope.domElement.removeEventListener( 'touchend', onTouchEnd, false ); 227 | scope.domElement.removeEventListener( 'touchmove', onTouchMove, false ); 228 | 229 | document.removeEventListener( 'mousemove', onMouseMove, false ); 230 | document.removeEventListener( 'mouseup', onMouseUp, false ); 231 | 232 | window.removeEventListener( 'keydown', onKeyDown, false ); 233 | 234 | //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? 235 | 236 | }; 237 | 238 | // 239 | // internals 240 | // 241 | 242 | var scope = this; 243 | 244 | var changeEvent = { type: 'change' }; 245 | var startEvent = { type: 'start' }; 246 | var endEvent = { type: 'end' }; 247 | 248 | var STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 }; 249 | 250 | var state = STATE.NONE; 251 | 252 | var EPS = 0.000001; 253 | 254 | // current position in spherical coordinates 255 | var spherical = new THREE.Spherical(); 256 | var sphericalDelta = new THREE.Spherical(); 257 | 258 | var scale = 1; 259 | var panOffset = new THREE.Vector3(); 260 | var zoomChanged = false; 261 | 262 | var rotateStart = new THREE.Vector2(); 263 | var rotateEnd = new THREE.Vector2(); 264 | var rotateDelta = new THREE.Vector2(); 265 | 266 | var panStart = new THREE.Vector2(); 267 | var panEnd = new THREE.Vector2(); 268 | var panDelta = new THREE.Vector2(); 269 | 270 | var dollyStart = new THREE.Vector2(); 271 | var dollyEnd = new THREE.Vector2(); 272 | var dollyDelta = new THREE.Vector2(); 273 | 274 | function getAutoRotationAngle() { 275 | 276 | return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; 277 | 278 | } 279 | 280 | function getZoomScale() { 281 | 282 | return Math.pow( 0.95, scope.zoomSpeed ); 283 | 284 | } 285 | 286 | function rotateLeft( angle ) { 287 | 288 | sphericalDelta.theta -= angle; 289 | 290 | } 291 | 292 | function rotateUp( angle ) { 293 | 294 | sphericalDelta.phi -= angle; 295 | 296 | } 297 | 298 | var panLeft = function () { 299 | 300 | var v = new THREE.Vector3(); 301 | 302 | return function panLeft( distance, objectMatrix ) { 303 | 304 | v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix 305 | v.multiplyScalar( - distance ); 306 | 307 | panOffset.add( v ); 308 | 309 | }; 310 | 311 | }(); 312 | 313 | var panUp = function () { 314 | 315 | var v = new THREE.Vector3(); 316 | 317 | return function panUp( distance, objectMatrix ) { 318 | 319 | v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix 320 | v.multiplyScalar( distance ); 321 | 322 | panOffset.add( v ); 323 | 324 | }; 325 | 326 | }(); 327 | 328 | // deltaX and deltaY are in pixels; right and down are positive 329 | var pan = function () { 330 | 331 | var offset = new THREE.Vector3(); 332 | 333 | return function pan( deltaX, deltaY ) { 334 | 335 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 336 | 337 | if ( scope.object instanceof THREE.PerspectiveCamera ) { 338 | 339 | // perspective 340 | var position = scope.object.position; 341 | offset.copy( position ).sub( scope.target ); 342 | var targetDistance = offset.length(); 343 | 344 | // half of the fov is center to top of screen 345 | targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); 346 | 347 | // we actually don't use screenWidth, since perspective camera is fixed to screen height 348 | panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); 349 | panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); 350 | 351 | } else if ( scope.object instanceof THREE.OrthographicCamera ) { 352 | 353 | // orthographic 354 | panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); 355 | panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); 356 | 357 | } else { 358 | 359 | // camera neither orthographic nor perspective 360 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); 361 | scope.enablePan = false; 362 | 363 | } 364 | 365 | }; 366 | 367 | }(); 368 | 369 | function dollyIn( dollyScale ) { 370 | 371 | if ( scope.object instanceof THREE.PerspectiveCamera ) { 372 | 373 | scale /= dollyScale; 374 | 375 | } else if ( scope.object instanceof THREE.OrthographicCamera ) { 376 | 377 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); 378 | scope.object.updateProjectionMatrix(); 379 | zoomChanged = true; 380 | 381 | } else { 382 | 383 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); 384 | scope.enableZoom = false; 385 | 386 | } 387 | 388 | } 389 | 390 | function dollyOut( dollyScale ) { 391 | 392 | if ( scope.object instanceof THREE.PerspectiveCamera ) { 393 | 394 | scale *= dollyScale; 395 | 396 | } else if ( scope.object instanceof THREE.OrthographicCamera ) { 397 | 398 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); 399 | scope.object.updateProjectionMatrix(); 400 | zoomChanged = true; 401 | 402 | } else { 403 | 404 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); 405 | scope.enableZoom = false; 406 | 407 | } 408 | 409 | } 410 | 411 | // 412 | // event callbacks - update the object state 413 | // 414 | 415 | function handleMouseDownRotate( event ) { 416 | 417 | //console.log( 'handleMouseDownRotate' ); 418 | 419 | rotateStart.set( event.clientX, event.clientY ); 420 | 421 | } 422 | 423 | function handleMouseDownDolly( event ) { 424 | 425 | //console.log( 'handleMouseDownDolly' ); 426 | 427 | dollyStart.set( event.clientX, event.clientY ); 428 | 429 | } 430 | 431 | function handleMouseDownPan( event ) { 432 | 433 | //console.log( 'handleMouseDownPan' ); 434 | 435 | panStart.set( event.clientX, event.clientY ); 436 | 437 | } 438 | 439 | function handleMouseMoveRotate( event ) { 440 | 441 | //console.log( 'handleMouseMoveRotate' ); 442 | 443 | rotateEnd.set( event.clientX, event.clientY ); 444 | rotateDelta.subVectors( rotateEnd, rotateStart ); 445 | 446 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 447 | 448 | // rotating across whole screen goes 360 degrees around 449 | rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed ); 450 | 451 | // rotating up and down along whole screen attempts to go 360, but limited to 180 452 | rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed ); 453 | 454 | rotateStart.copy( rotateEnd ); 455 | 456 | scope.update(); 457 | 458 | } 459 | 460 | function handleMouseMoveDolly( event ) { 461 | 462 | //console.log( 'handleMouseMoveDolly' ); 463 | 464 | dollyEnd.set( event.clientX, event.clientY ); 465 | 466 | dollyDelta.subVectors( dollyEnd, dollyStart ); 467 | 468 | if ( dollyDelta.y > 0 ) { 469 | 470 | dollyIn( getZoomScale() ); 471 | 472 | } else if ( dollyDelta.y < 0 ) { 473 | 474 | dollyOut( getZoomScale() ); 475 | 476 | } 477 | 478 | dollyStart.copy( dollyEnd ); 479 | 480 | scope.update(); 481 | 482 | } 483 | 484 | function handleMouseMovePan( event ) { 485 | 486 | //console.log( 'handleMouseMovePan' ); 487 | 488 | panEnd.set( event.clientX, event.clientY ); 489 | 490 | panDelta.subVectors( panEnd, panStart ); 491 | 492 | pan( panDelta.x, panDelta.y ); 493 | 494 | panStart.copy( panEnd ); 495 | 496 | scope.update(); 497 | 498 | } 499 | 500 | function handleMouseUp( event ) { 501 | 502 | // console.log( 'handleMouseUp' ); 503 | 504 | } 505 | 506 | function handleMouseWheel( event ) { 507 | 508 | // console.log( 'handleMouseWheel' ); 509 | 510 | if ( event.deltaY < 0 ) { 511 | 512 | dollyOut( getZoomScale() ); 513 | 514 | } else if ( event.deltaY > 0 ) { 515 | 516 | dollyIn( getZoomScale() ); 517 | 518 | } 519 | 520 | scope.update(); 521 | 522 | } 523 | 524 | function handleKeyDown( event ) { 525 | 526 | //console.log( 'handleKeyDown' ); 527 | 528 | switch ( event.keyCode ) { 529 | 530 | case scope.keys.UP: 531 | pan( 0, scope.keyPanSpeed ); 532 | scope.update(); 533 | break; 534 | 535 | case scope.keys.BOTTOM: 536 | pan( 0, - scope.keyPanSpeed ); 537 | scope.update(); 538 | break; 539 | 540 | case scope.keys.LEFT: 541 | pan( scope.keyPanSpeed, 0 ); 542 | scope.update(); 543 | break; 544 | 545 | case scope.keys.RIGHT: 546 | pan( - scope.keyPanSpeed, 0 ); 547 | scope.update(); 548 | break; 549 | 550 | } 551 | 552 | } 553 | 554 | function handleTouchStartRotate( event ) { 555 | 556 | //console.log( 'handleTouchStartRotate' ); 557 | 558 | rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 559 | 560 | } 561 | 562 | function handleTouchStartDolly( event ) { 563 | 564 | //console.log( 'handleTouchStartDolly' ); 565 | 566 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 567 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 568 | 569 | var distance = Math.sqrt( dx * dx + dy * dy ); 570 | 571 | dollyStart.set( 0, distance ); 572 | 573 | } 574 | 575 | function handleTouchStartPan( event ) { 576 | 577 | //console.log( 'handleTouchStartPan' ); 578 | 579 | panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 580 | 581 | } 582 | 583 | function handleTouchMoveRotate( event ) { 584 | 585 | //console.log( 'handleTouchMoveRotate' ); 586 | 587 | rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 588 | rotateDelta.subVectors( rotateEnd, rotateStart ); 589 | 590 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 591 | 592 | // rotating across whole screen goes 360 degrees around 593 | rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed ); 594 | 595 | // rotating up and down along whole screen attempts to go 360, but limited to 180 596 | rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed ); 597 | 598 | rotateStart.copy( rotateEnd ); 599 | 600 | scope.update(); 601 | 602 | } 603 | 604 | function handleTouchMoveDolly( event ) { 605 | 606 | //console.log( 'handleTouchMoveDolly' ); 607 | 608 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 609 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 610 | 611 | var distance = Math.sqrt( dx * dx + dy * dy ); 612 | 613 | dollyEnd.set( 0, distance ); 614 | 615 | dollyDelta.subVectors( dollyEnd, dollyStart ); 616 | 617 | if ( dollyDelta.y > 0 ) { 618 | 619 | dollyOut( getZoomScale() ); 620 | 621 | } else if ( dollyDelta.y < 0 ) { 622 | 623 | dollyIn( getZoomScale() ); 624 | 625 | } 626 | 627 | dollyStart.copy( dollyEnd ); 628 | 629 | scope.update(); 630 | 631 | } 632 | 633 | function handleTouchMovePan( event ) { 634 | 635 | //console.log( 'handleTouchMovePan' ); 636 | 637 | panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 638 | 639 | panDelta.subVectors( panEnd, panStart ); 640 | 641 | pan( panDelta.x, panDelta.y ); 642 | 643 | panStart.copy( panEnd ); 644 | 645 | scope.update(); 646 | 647 | } 648 | 649 | function handleTouchEnd( event ) { 650 | 651 | //console.log( 'handleTouchEnd' ); 652 | 653 | } 654 | 655 | // 656 | // event handlers - FSM: listen for events and reset state 657 | // 658 | 659 | function onMouseDown( event ) { 660 | 661 | if ( scope.enabled === false ) return; 662 | 663 | event.preventDefault(); 664 | 665 | if ( event.button === scope.mouseButtons.ORBIT ) { 666 | 667 | if ( scope.enableRotate === false ) return; 668 | 669 | handleMouseDownRotate( event ); 670 | 671 | state = STATE.ROTATE; 672 | 673 | } else if ( event.button === scope.mouseButtons.ZOOM ) { 674 | 675 | if ( scope.enableZoom === false ) return; 676 | 677 | handleMouseDownDolly( event ); 678 | 679 | state = STATE.DOLLY; 680 | 681 | } else if ( event.button === scope.mouseButtons.PAN ) { 682 | 683 | if ( scope.enablePan === false ) return; 684 | 685 | handleMouseDownPan( event ); 686 | 687 | state = STATE.PAN; 688 | 689 | } 690 | 691 | if ( state !== STATE.NONE ) { 692 | 693 | document.addEventListener( 'mousemove', onMouseMove, false ); 694 | document.addEventListener( 'mouseup', onMouseUp, false ); 695 | 696 | scope.dispatchEvent( startEvent ); 697 | 698 | } 699 | 700 | } 701 | 702 | function onMouseMove( event ) { 703 | 704 | if ( scope.enabled === false ) return; 705 | 706 | event.preventDefault(); 707 | 708 | if ( state === STATE.ROTATE ) { 709 | 710 | if ( scope.enableRotate === false ) return; 711 | 712 | handleMouseMoveRotate( event ); 713 | 714 | } else if ( state === STATE.DOLLY ) { 715 | 716 | if ( scope.enableZoom === false ) return; 717 | 718 | handleMouseMoveDolly( event ); 719 | 720 | } else if ( state === STATE.PAN ) { 721 | 722 | if ( scope.enablePan === false ) return; 723 | 724 | handleMouseMovePan( event ); 725 | 726 | } 727 | 728 | } 729 | 730 | function onMouseUp( event ) { 731 | 732 | if ( scope.enabled === false ) return; 733 | 734 | handleMouseUp( event ); 735 | 736 | document.removeEventListener( 'mousemove', onMouseMove, false ); 737 | document.removeEventListener( 'mouseup', onMouseUp, false ); 738 | 739 | scope.dispatchEvent( endEvent ); 740 | 741 | state = STATE.NONE; 742 | 743 | } 744 | 745 | function onMouseWheel( event ) { 746 | 747 | if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return; 748 | 749 | event.preventDefault(); 750 | event.stopPropagation(); 751 | 752 | handleMouseWheel( event ); 753 | 754 | scope.dispatchEvent( startEvent ); // not sure why these are here... 755 | scope.dispatchEvent( endEvent ); 756 | 757 | } 758 | 759 | function onKeyDown( event ) { 760 | 761 | if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return; 762 | 763 | handleKeyDown( event ); 764 | 765 | } 766 | 767 | function onTouchStart( event ) { 768 | 769 | if ( scope.enabled === false ) return; 770 | 771 | switch ( event.touches.length ) { 772 | 773 | case 1: // one-fingered touch: rotate 774 | 775 | if ( scope.enableRotate === false ) return; 776 | 777 | handleTouchStartRotate( event ); 778 | 779 | state = STATE.TOUCH_ROTATE; 780 | 781 | break; 782 | 783 | case 2: // two-fingered touch: dolly 784 | 785 | if ( scope.enableZoom === false ) return; 786 | 787 | handleTouchStartDolly( event ); 788 | 789 | state = STATE.TOUCH_DOLLY; 790 | 791 | break; 792 | 793 | case 3: // three-fingered touch: pan 794 | 795 | if ( scope.enablePan === false ) return; 796 | 797 | handleTouchStartPan( event ); 798 | 799 | state = STATE.TOUCH_PAN; 800 | 801 | break; 802 | 803 | default: 804 | 805 | state = STATE.NONE; 806 | 807 | } 808 | 809 | if ( state !== STATE.NONE ) { 810 | 811 | scope.dispatchEvent( startEvent ); 812 | 813 | } 814 | 815 | } 816 | 817 | function onTouchMove( event ) { 818 | 819 | if ( scope.enabled === false ) return; 820 | 821 | event.preventDefault(); 822 | event.stopPropagation(); 823 | 824 | switch ( event.touches.length ) { 825 | 826 | case 1: // one-fingered touch: rotate 827 | 828 | if ( scope.enableRotate === false ) return; 829 | if ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?... 830 | 831 | handleTouchMoveRotate( event ); 832 | 833 | break; 834 | 835 | case 2: // two-fingered touch: dolly 836 | 837 | if ( scope.enableZoom === false ) return; 838 | if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?... 839 | 840 | handleTouchMoveDolly( event ); 841 | 842 | break; 843 | 844 | case 3: // three-fingered touch: pan 845 | 846 | if ( scope.enablePan === false ) return; 847 | if ( state !== STATE.TOUCH_PAN ) return; // is this needed?... 848 | 849 | handleTouchMovePan( event ); 850 | 851 | break; 852 | 853 | default: 854 | 855 | state = STATE.NONE; 856 | 857 | } 858 | 859 | } 860 | 861 | function onTouchEnd( event ) { 862 | 863 | if ( scope.enabled === false ) return; 864 | 865 | handleTouchEnd( event ); 866 | 867 | scope.dispatchEvent( endEvent ); 868 | 869 | state = STATE.NONE; 870 | 871 | } 872 | 873 | function onContextMenu( event ) { 874 | 875 | event.preventDefault(); 876 | 877 | } 878 | 879 | // 880 | 881 | scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); 882 | 883 | scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); 884 | scope.domElement.addEventListener( 'wheel', onMouseWheel, false ); 885 | 886 | scope.domElement.addEventListener( 'touchstart', onTouchStart, false ); 887 | scope.domElement.addEventListener( 'touchend', onTouchEnd, false ); 888 | scope.domElement.addEventListener( 'touchmove', onTouchMove, false ); 889 | 890 | window.addEventListener( 'keydown', onKeyDown, false ); 891 | 892 | // force an update at start 893 | 894 | this.update(); 895 | 896 | }; 897 | 898 | THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype ); 899 | THREE.OrbitControls.prototype.constructor = THREE.OrbitControls; 900 | 901 | Object.defineProperties( THREE.OrbitControls.prototype, { 902 | 903 | center: { 904 | 905 | get: function () { 906 | 907 | console.warn( 'THREE.OrbitControls: .center has been renamed to .target' ); 908 | return this.target; 909 | 910 | } 911 | 912 | }, 913 | 914 | // backward compatibility 915 | 916 | noZoom: { 917 | 918 | get: function () { 919 | 920 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); 921 | return ! this.enableZoom; 922 | 923 | }, 924 | 925 | set: function ( value ) { 926 | 927 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); 928 | this.enableZoom = ! value; 929 | 930 | } 931 | 932 | }, 933 | 934 | noRotate: { 935 | 936 | get: function () { 937 | 938 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); 939 | return ! this.enableRotate; 940 | 941 | }, 942 | 943 | set: function ( value ) { 944 | 945 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); 946 | this.enableRotate = ! value; 947 | 948 | } 949 | 950 | }, 951 | 952 | noPan: { 953 | 954 | get: function () { 955 | 956 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); 957 | return ! this.enablePan; 958 | 959 | }, 960 | 961 | set: function ( value ) { 962 | 963 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); 964 | this.enablePan = ! value; 965 | 966 | } 967 | 968 | }, 969 | 970 | noKeys: { 971 | 972 | get: function () { 973 | 974 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); 975 | return ! this.enableKeys; 976 | 977 | }, 978 | 979 | set: function ( value ) { 980 | 981 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); 982 | this.enableKeys = ! value; 983 | 984 | } 985 | 986 | }, 987 | 988 | staticMoving: { 989 | 990 | get: function () { 991 | 992 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); 993 | return ! this.enableDamping; 994 | 995 | }, 996 | 997 | set: function ( value ) { 998 | 999 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); 1000 | this.enableDamping = ! value; 1001 | 1002 | } 1003 | 1004 | }, 1005 | 1006 | dynamicDampingFactor: { 1007 | 1008 | get: function () { 1009 | 1010 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); 1011 | return this.dampingFactor; 1012 | 1013 | }, 1014 | 1015 | set: function ( value ) { 1016 | 1017 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); 1018 | this.dampingFactor = value; 1019 | 1020 | } 1021 | 1022 | } 1023 | 1024 | } ); 1025 | --------------------------------------------------------------------------------