|
9 | 9 | background-color: #000000; |
10 | 10 | margin: 0px; |
11 | 11 | overflow: hidden; |
| 12 | + touch-action: none; |
12 | 13 | } |
13 | 14 |
|
14 | 15 | #info { |
|
78 | 79 | renderer.setSize( window.innerWidth, window.innerHeight ); |
79 | 80 | container.appendChild( renderer.domElement ); |
80 | 81 |
|
81 | | - document.addEventListener( 'mousedown', onDocumentMouseDown, false ); |
82 | | - document.addEventListener( 'mousemove', onDocumentMouseMove, false ); |
83 | | - document.addEventListener( 'mouseup', onDocumentMouseUp, false ); |
| 82 | + document.addEventListener( 'mousedown', onPointerStart, false ); |
| 83 | + document.addEventListener( 'mousemove', onPointerMove, false ); |
| 84 | + document.addEventListener( 'mouseup', onPointerUp, false ); |
| 85 | + |
84 | 86 | document.addEventListener( 'wheel', onDocumentMouseWheel, false ); |
85 | 87 |
|
| 88 | + document.addEventListener( 'touchstart', onPointerStart, false ); |
| 89 | + document.addEventListener( 'touchmove', onPointerMove, false ); |
| 90 | + document.addEventListener( 'touchend', onPointerUp, false ); |
| 91 | + |
86 | 92 | // |
87 | 93 |
|
88 | 94 | document.addEventListener( 'dragover', function ( event ) { |
|
136 | 142 |
|
137 | 143 | } |
138 | 144 |
|
139 | | - function onDocumentMouseDown( event ) { |
| 145 | + function onPointerStart( event ) { |
140 | 146 |
|
141 | 147 | event.preventDefault(); |
142 | 148 |
|
143 | 149 | isUserInteracting = true; |
144 | 150 |
|
145 | | - onMouseDownMouseX = event.clientX; |
146 | | - onMouseDownMouseY = event.clientY; |
| 151 | + var clientX = event.clientX || event.touches[ 0 ].clientX; |
| 152 | + var clientY = event.clientY || event.touches[ 0 ].clientY; |
| 153 | + |
| 154 | + onMouseDownMouseX = clientX; |
| 155 | + onMouseDownMouseY = clientY; |
147 | 156 |
|
148 | 157 | onMouseDownLon = lon; |
149 | 158 | onMouseDownLat = lat; |
150 | 159 |
|
151 | 160 | } |
152 | 161 |
|
153 | | - function onDocumentMouseMove( event ) { |
| 162 | + function onPointerMove( event ) { |
154 | 163 |
|
155 | 164 | if ( isUserInteracting === true ) { |
156 | 165 |
|
157 | | - lon = ( onMouseDownMouseX - event.clientX ) * 0.1 + onMouseDownLon; |
158 | | - lat = ( event.clientY - onMouseDownMouseY ) * 0.1 + onMouseDownLat; |
| 166 | + var clientX = event.clientX || event.touches[ 0 ].clientX; |
| 167 | + var clientY = event.clientY || event.touches[ 0 ].clientY; |
| 168 | + |
| 169 | + lon = ( onMouseDownMouseX - clientX ) * 0.1 + onMouseDownLon; |
| 170 | + lat = ( clientY - onMouseDownMouseY ) * 0.1 + onMouseDownLat; |
159 | 171 |
|
160 | 172 | } |
161 | 173 |
|
162 | 174 | } |
163 | 175 |
|
164 | | - function onDocumentMouseUp( event ) { |
| 176 | + function onPointerUp( event ) { |
165 | 177 |
|
166 | 178 | isUserInteracting = false; |
167 | 179 |
|
|
202 | 214 |
|
203 | 215 | camera.lookAt( camera.target ); |
204 | 216 |
|
205 | | - /* |
206 | | - // distortion |
207 | | - camera.position.copy( camera.target ).negate(); |
208 | | - */ |
209 | | - |
210 | 217 | renderer.render( scene, camera ); |
211 | 218 |
|
212 | 219 | } |
|
0 commit comments