├── README.md ├── game.js ├── game.json ├── js ├── libs │ ├── OrbitControls.js │ ├── symbol.js │ ├── three.min.js │ └── weapp-adapter.js └── main.js ├── models └── indienova-logo.json └── project.config.json /README.md: -------------------------------------------------------------------------------- 1 | ## WeChat mini game load 3D model in three.js 2 | 3 | ## 相应介绍文章 4 | 5 | https://indienova.com/indie-game-development/wechat-mini-game-notes-threejs-load-model-and-interaction/ 6 | 7 | ## 源码目录介绍 8 | ``` 9 | ./js 10 | ├── libs 11 | │ ├── symbol.js // ES6 Symbol简易兼容 12 | │ ├── three.min.js // 原始 three.min.js 90dev 13 | │ ├── OrbitControls.js // 修改过的 OrbitControls 14 | │ └── weapp-adapter.js // 小游戏适配器 15 | └── main.js // 游戏入口主函数 16 | 17 | ``` -------------------------------------------------------------------------------- /game.js: -------------------------------------------------------------------------------- 1 | import './js/libs/weapp-adapter' 2 | import './js/libs/symbol' 3 | 4 | import Main from './js/main' 5 | 6 | new Main() 7 | -------------------------------------------------------------------------------- /game.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceOrientation": "portrait" 3 | } 4 | -------------------------------------------------------------------------------- /js/libs/OrbitControls.js: -------------------------------------------------------------------------------- 1 | var THREE = require('three.min'); 2 | 3 | /** 4 | * @author qiao / https://github.com/qiao 5 | * @author mrdoob / http://mrdoob.com 6 | * @author alteredq / http://alteredqualia.com/ 7 | * @author WestLangley / http://github.com/WestLangley 8 | * @author erich666 / http://erichaines.com 9 | */ 10 | 11 | // This set of controls performs orbiting, dollying (zooming), and panning. 12 | // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). 13 | // 14 | // Orbit - left mouse / touch: one finger move 15 | // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish 16 | // Pan - right mouse, or arrow keys / touch: three finger swipe 17 | 18 | THREE.OrbitControls = function ( object, domElement ) { 19 | 20 | this.object = object; 21 | 22 | this.domElement = ( domElement !== undefined ) ? domElement : document; 23 | 24 | // Set to false to disable this control 25 | this.enabled = true; 26 | 27 | // "target" sets the location of focus, where the object orbits around 28 | this.target = new THREE.Vector3(); 29 | 30 | // How far you can dolly in and out ( PerspectiveCamera only ) 31 | this.minDistance = 0; 32 | this.maxDistance = Infinity; 33 | 34 | // How far you can zoom in and out ( OrthographicCamera only ) 35 | this.minZoom = 0; 36 | this.maxZoom = Infinity; 37 | 38 | // How far you can orbit vertically, upper and lower limits. 39 | // Range is 0 to Math.PI radians. 40 | this.minPolarAngle = 0; // radians 41 | this.maxPolarAngle = Math.PI; // radians 42 | 43 | // How far you can orbit horizontally, upper and lower limits. 44 | // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ]. 45 | this.minAzimuthAngle = - Infinity; // radians 46 | this.maxAzimuthAngle = Infinity; // radians 47 | 48 | // Set to true to enable damping (inertia) 49 | // If damping is enabled, you must call controls.update() in your animation loop 50 | this.enableDamping = false; 51 | this.dampingFactor = 0.25; 52 | 53 | // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. 54 | // Set to false to disable zooming 55 | this.enableZoom = true; 56 | this.zoomSpeed = 1.0; 57 | 58 | // Set to false to disable rotating 59 | this.enableRotate = true; 60 | this.rotateSpeed = 1.0; 61 | 62 | // Set to false to disable panning 63 | this.enablePan = true; 64 | this.keyPanSpeed = 7.0; // pixels moved per arrow key push 65 | 66 | // Set to true to automatically rotate around the target 67 | // If auto-rotate is enabled, you must call controls.update() in your animation loop 68 | this.autoRotate = false; 69 | this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60 70 | 71 | // Set to false to disable use of the keys 72 | this.enableKeys = true; 73 | 74 | // The four arrow keys 75 | this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }; 76 | 77 | // Mouse buttons 78 | this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT }; 79 | 80 | // for reset 81 | this.target0 = this.target.clone(); 82 | this.position0 = this.object.position.clone(); 83 | this.zoom0 = this.object.zoom; 84 | 85 | // 86 | // public methods 87 | // 88 | 89 | this.getPolarAngle = function () { 90 | 91 | return spherical.phi; 92 | 93 | }; 94 | 95 | this.getAzimuthalAngle = function () { 96 | 97 | return spherical.theta; 98 | 99 | }; 100 | 101 | this.saveState = function () { 102 | 103 | scope.target0.copy( scope.target ); 104 | scope.position0.copy( scope.object.position ); 105 | scope.zoom0 = scope.object.zoom; 106 | 107 | }; 108 | 109 | this.reset = function () { 110 | 111 | scope.target.copy( scope.target0 ); 112 | scope.object.position.copy( scope.position0 ); 113 | scope.object.zoom = scope.zoom0; 114 | 115 | scope.object.updateProjectionMatrix(); 116 | scope.dispatchEvent( changeEvent ); 117 | 118 | scope.update(); 119 | 120 | state = STATE.NONE; 121 | 122 | }; 123 | 124 | // this method is exposed, but perhaps it would be better if we can make it private... 125 | this.update = function () { 126 | 127 | var offset = new THREE.Vector3(); 128 | 129 | // so camera.up is the orbit axis 130 | var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) ); 131 | var quatInverse = quat.clone().inverse(); 132 | 133 | var lastPosition = new THREE.Vector3(); 134 | var lastQuaternion = new THREE.Quaternion(); 135 | 136 | return function update() { 137 | 138 | var position = scope.object.position; 139 | 140 | offset.copy( position ).sub( scope.target ); 141 | 142 | // rotate offset to "y-axis-is-up" space 143 | offset.applyQuaternion( quat ); 144 | 145 | // angle from z-axis around y-axis 146 | spherical.setFromVector3( offset ); 147 | 148 | if ( scope.autoRotate && state === STATE.NONE ) { 149 | 150 | rotateLeft( getAutoRotationAngle() ); 151 | 152 | } 153 | 154 | spherical.theta += sphericalDelta.theta; 155 | spherical.phi += sphericalDelta.phi; 156 | 157 | // restrict theta to be between desired limits 158 | spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) ); 159 | 160 | // restrict phi to be between desired limits 161 | spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); 162 | 163 | spherical.makeSafe(); 164 | 165 | 166 | spherical.radius *= scale; 167 | 168 | // restrict radius to be between desired limits 169 | spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); 170 | 171 | // move target to panned location 172 | scope.target.add( panOffset ); 173 | 174 | offset.setFromSpherical( spherical ); 175 | 176 | // rotate offset back to "camera-up-vector-is-up" space 177 | offset.applyQuaternion( quatInverse ); 178 | 179 | position.copy( scope.target ).add( offset ); 180 | 181 | scope.object.lookAt( scope.target ); 182 | 183 | if ( scope.enableDamping === true ) { 184 | 185 | sphericalDelta.theta *= ( 1 - scope.dampingFactor ); 186 | sphericalDelta.phi *= ( 1 - scope.dampingFactor ); 187 | 188 | } else { 189 | 190 | sphericalDelta.set( 0, 0, 0 ); 191 | 192 | } 193 | 194 | scale = 1; 195 | panOffset.set( 0, 0, 0 ); 196 | 197 | // update condition is: 198 | // min(camera displacement, camera rotation in radians)^2 > EPS 199 | // using small-angle approximation cos(x/2) = 1 - x^2 / 8 200 | 201 | if ( zoomChanged || 202 | lastPosition.distanceToSquared( scope.object.position ) > EPS || 203 | 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { 204 | 205 | scope.dispatchEvent( changeEvent ); 206 | 207 | lastPosition.copy( scope.object.position ); 208 | lastQuaternion.copy( scope.object.quaternion ); 209 | zoomChanged = false; 210 | 211 | return true; 212 | 213 | } 214 | 215 | return false; 216 | 217 | }; 218 | 219 | }(); 220 | 221 | this.dispose = function () { 222 | 223 | scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false ); 224 | scope.domElement.removeEventListener( 'mousedown', onMouseDown, false ); 225 | scope.domElement.removeEventListener( 'wheel', onMouseWheel, false ); 226 | 227 | scope.domElement.removeEventListener( 'touchstart', onTouchStart, false ); 228 | scope.domElement.removeEventListener( 'touchend', onTouchEnd, false ); 229 | scope.domElement.removeEventListener( 'touchmove', onTouchMove, false ); 230 | 231 | document.removeEventListener( 'mousemove', onMouseMove, false ); 232 | document.removeEventListener( 'mouseup', onMouseUp, false ); 233 | 234 | window.removeEventListener( 'keydown', onKeyDown, false ); 235 | 236 | //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? 237 | 238 | }; 239 | 240 | // 241 | // internals 242 | // 243 | 244 | var scope = this; 245 | 246 | var changeEvent = { type: 'change' }; 247 | var startEvent = { type: 'start' }; 248 | var endEvent = { type: 'end' }; 249 | 250 | var STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 }; 251 | 252 | var state = STATE.NONE; 253 | 254 | var EPS = 0.000001; 255 | 256 | // current position in spherical coordinates 257 | var spherical = new THREE.Spherical(); 258 | var sphericalDelta = new THREE.Spherical(); 259 | 260 | var scale = 1; 261 | var panOffset = new THREE.Vector3(); 262 | var zoomChanged = false; 263 | 264 | var rotateStart = new THREE.Vector2(); 265 | var rotateEnd = new THREE.Vector2(); 266 | var rotateDelta = new THREE.Vector2(); 267 | 268 | var panStart = new THREE.Vector2(); 269 | var panEnd = new THREE.Vector2(); 270 | var panDelta = new THREE.Vector2(); 271 | 272 | var dollyStart = new THREE.Vector2(); 273 | var dollyEnd = new THREE.Vector2(); 274 | var dollyDelta = new THREE.Vector2(); 275 | 276 | function getAutoRotationAngle() { 277 | 278 | return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; 279 | 280 | } 281 | 282 | function getZoomScale() { 283 | 284 | return Math.pow( 0.95, scope.zoomSpeed ); 285 | 286 | } 287 | 288 | function rotateLeft( angle ) { 289 | 290 | sphericalDelta.theta -= angle; 291 | 292 | } 293 | 294 | function rotateUp( angle ) { 295 | 296 | sphericalDelta.phi -= angle; 297 | 298 | } 299 | 300 | var panLeft = function () { 301 | 302 | var v = new THREE.Vector3(); 303 | 304 | return function panLeft( distance, objectMatrix ) { 305 | 306 | v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix 307 | v.multiplyScalar( - distance ); 308 | 309 | panOffset.add( v ); 310 | 311 | }; 312 | 313 | }(); 314 | 315 | var panUp = function () { 316 | 317 | var v = new THREE.Vector3(); 318 | 319 | return function panUp( distance, objectMatrix ) { 320 | 321 | v.setFromMatrixColumn( objectMatrix, 1 ); // get Y column of objectMatrix 322 | v.multiplyScalar( distance ); 323 | 324 | panOffset.add( v ); 325 | 326 | }; 327 | 328 | }(); 329 | 330 | // deltaX and deltaY are in pixels; right and down are positive 331 | var pan = function () { 332 | 333 | var offset = new THREE.Vector3(); 334 | 335 | return function pan( deltaX, deltaY ) { 336 | 337 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 338 | 339 | if ( scope.object.isPerspectiveCamera ) { 340 | 341 | // perspective 342 | var position = scope.object.position; 343 | offset.copy( position ).sub( scope.target ); 344 | var targetDistance = offset.length(); 345 | 346 | // half of the fov is center to top of screen 347 | targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); 348 | 349 | // we actually don't use screenWidth, since perspective camera is fixed to screen height 350 | panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); 351 | panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); 352 | 353 | } else if ( scope.object.isOrthographicCamera ) { 354 | 355 | // orthographic 356 | panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); 357 | panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); 358 | 359 | } else { 360 | 361 | // camera neither orthographic nor perspective 362 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); 363 | scope.enablePan = false; 364 | 365 | } 366 | 367 | }; 368 | 369 | }(); 370 | 371 | function dollyIn( dollyScale ) { 372 | 373 | if ( scope.object.isPerspectiveCamera ) { 374 | 375 | scale /= dollyScale; 376 | 377 | } else if ( scope.object.isOrthographicCamera ) { 378 | 379 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); 380 | scope.object.updateProjectionMatrix(); 381 | zoomChanged = true; 382 | 383 | } else { 384 | 385 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); 386 | scope.enableZoom = false; 387 | 388 | } 389 | 390 | } 391 | 392 | function dollyOut( dollyScale ) { 393 | 394 | if ( scope.object.isPerspectiveCamera ) { 395 | 396 | scale *= dollyScale; 397 | 398 | } else if ( scope.object.isOrthographicCamera ) { 399 | 400 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); 401 | scope.object.updateProjectionMatrix(); 402 | zoomChanged = true; 403 | 404 | } else { 405 | 406 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); 407 | scope.enableZoom = false; 408 | 409 | } 410 | 411 | } 412 | 413 | // 414 | // event callbacks - update the object state 415 | // 416 | 417 | function handleMouseDownRotate( event ) { 418 | 419 | //console.log( 'handleMouseDownRotate' ); 420 | 421 | rotateStart.set( event.clientX, event.clientY ); 422 | 423 | } 424 | 425 | function handleMouseDownDolly( event ) { 426 | 427 | //console.log( 'handleMouseDownDolly' ); 428 | 429 | dollyStart.set( event.clientX, event.clientY ); 430 | 431 | } 432 | 433 | function handleMouseDownPan( event ) { 434 | 435 | //console.log( 'handleMouseDownPan' ); 436 | 437 | panStart.set( event.clientX, event.clientY ); 438 | 439 | } 440 | 441 | function handleMouseMoveRotate( event ) { 442 | 443 | //console.log( 'handleMouseMoveRotate' ); 444 | 445 | rotateEnd.set( event.clientX, event.clientY ); 446 | rotateDelta.subVectors( rotateEnd, rotateStart ); 447 | 448 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 449 | 450 | // rotating across whole screen goes 360 degrees around 451 | rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed ); 452 | 453 | // rotating up and down along whole screen attempts to go 360, but limited to 180 454 | rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed ); 455 | 456 | rotateStart.copy( rotateEnd ); 457 | 458 | scope.update(); 459 | 460 | } 461 | 462 | function handleMouseMoveDolly( event ) { 463 | 464 | //console.log( 'handleMouseMoveDolly' ); 465 | 466 | dollyEnd.set( event.clientX, event.clientY ); 467 | 468 | dollyDelta.subVectors( dollyEnd, dollyStart ); 469 | 470 | if ( dollyDelta.y > 0 ) { 471 | 472 | dollyIn( getZoomScale() ); 473 | 474 | } else if ( dollyDelta.y < 0 ) { 475 | 476 | dollyOut( getZoomScale() ); 477 | 478 | } 479 | 480 | dollyStart.copy( dollyEnd ); 481 | 482 | scope.update(); 483 | 484 | } 485 | 486 | function handleMouseMovePan( event ) { 487 | 488 | //console.log( 'handleMouseMovePan' ); 489 | 490 | panEnd.set( event.clientX, event.clientY ); 491 | 492 | panDelta.subVectors( panEnd, panStart ); 493 | 494 | pan( panDelta.x, panDelta.y ); 495 | 496 | panStart.copy( panEnd ); 497 | 498 | scope.update(); 499 | 500 | } 501 | 502 | function handleMouseUp( event ) { 503 | 504 | // console.log( 'handleMouseUp' ); 505 | 506 | } 507 | 508 | function handleMouseWheel( event ) { 509 | 510 | // console.log( 'handleMouseWheel' ); 511 | 512 | if ( event.deltaY < 0 ) { 513 | 514 | dollyOut( getZoomScale() ); 515 | 516 | } else if ( event.deltaY > 0 ) { 517 | 518 | dollyIn( getZoomScale() ); 519 | 520 | } 521 | 522 | scope.update(); 523 | 524 | } 525 | 526 | function handleKeyDown( event ) { 527 | 528 | //console.log( 'handleKeyDown' ); 529 | 530 | switch ( event.keyCode ) { 531 | 532 | case scope.keys.UP: 533 | pan( 0, scope.keyPanSpeed ); 534 | scope.update(); 535 | break; 536 | 537 | case scope.keys.BOTTOM: 538 | pan( 0, - scope.keyPanSpeed ); 539 | scope.update(); 540 | break; 541 | 542 | case scope.keys.LEFT: 543 | pan( scope.keyPanSpeed, 0 ); 544 | scope.update(); 545 | break; 546 | 547 | case scope.keys.RIGHT: 548 | pan( - scope.keyPanSpeed, 0 ); 549 | scope.update(); 550 | break; 551 | 552 | } 553 | 554 | } 555 | 556 | function handleTouchStartRotate( event ) { 557 | 558 | //console.log( 'handleTouchStartRotate' ); 559 | 560 | rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 561 | 562 | } 563 | 564 | function handleTouchStartDolly( event ) { 565 | 566 | //console.log( 'handleTouchStartDolly' ); 567 | 568 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 569 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 570 | 571 | var distance = Math.sqrt( dx * dx + dy * dy ); 572 | 573 | dollyStart.set( 0, distance ); 574 | 575 | } 576 | 577 | function handleTouchStartPan( event ) { 578 | 579 | //console.log( 'handleTouchStartPan' ); 580 | 581 | panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 582 | 583 | } 584 | 585 | function handleTouchMoveRotate( event ) { 586 | 587 | //console.log( 'handleTouchMoveRotate' ); 588 | 589 | rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 590 | rotateDelta.subVectors( rotateEnd, rotateStart ); 591 | 592 | var element = scope.domElement === document ? scope.domElement.body : scope.domElement; 593 | 594 | // rotating across whole screen goes 360 degrees around 595 | //rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed ); 596 | rotateLeft( 2 * Math.PI * rotateDelta.x / window.innerWidth * scope.rotateSpeed ); 597 | 598 | // rotating up and down along whole screen attempts to go 360, but limited to 180 599 | //rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed ); 600 | rotateUp( 2 * Math.PI * rotateDelta.y / window.innerHeight * scope.rotateSpeed ); 601 | 602 | rotateStart.copy( rotateEnd ); 603 | 604 | scope.update(); 605 | 606 | } 607 | 608 | function handleTouchMoveDolly( event ) { 609 | 610 | //console.log( 'handleTouchMoveDolly' ); 611 | 612 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; 613 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; 614 | 615 | var distance = Math.sqrt( dx * dx + dy * dy ); 616 | 617 | dollyEnd.set( 0, distance ); 618 | 619 | dollyDelta.subVectors( dollyEnd, dollyStart ); 620 | 621 | if ( dollyDelta.y > 0 ) { 622 | 623 | dollyOut( getZoomScale() ); 624 | 625 | } else if ( dollyDelta.y < 0 ) { 626 | 627 | dollyIn( getZoomScale() ); 628 | 629 | } 630 | 631 | dollyStart.copy( dollyEnd ); 632 | 633 | scope.update(); 634 | 635 | } 636 | 637 | function handleTouchMovePan( event ) { 638 | 639 | //console.log( 'handleTouchMovePan' ); 640 | 641 | panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); 642 | 643 | panDelta.subVectors( panEnd, panStart ); 644 | 645 | pan( panDelta.x, panDelta.y ); 646 | 647 | panStart.copy( panEnd ); 648 | 649 | scope.update(); 650 | 651 | } 652 | 653 | function handleTouchEnd( event ) { 654 | 655 | //console.log( 'handleTouchEnd' ); 656 | 657 | } 658 | 659 | // 660 | // event handlers - FSM: listen for events and reset state 661 | // 662 | 663 | function onMouseDown( event ) { 664 | 665 | if ( scope.enabled === false ) return; 666 | 667 | event.preventDefault(); 668 | 669 | switch ( event.button ) { 670 | 671 | case scope.mouseButtons.ORBIT: 672 | 673 | if ( scope.enableRotate === false ) return; 674 | 675 | handleMouseDownRotate( event ); 676 | 677 | state = STATE.ROTATE; 678 | 679 | break; 680 | 681 | case scope.mouseButtons.ZOOM: 682 | 683 | if ( scope.enableZoom === false ) return; 684 | 685 | handleMouseDownDolly( event ); 686 | 687 | state = STATE.DOLLY; 688 | 689 | break; 690 | 691 | case scope.mouseButtons.PAN: 692 | 693 | if ( scope.enablePan === false ) return; 694 | 695 | handleMouseDownPan( event ); 696 | 697 | state = STATE.PAN; 698 | 699 | break; 700 | 701 | } 702 | 703 | if ( state !== STATE.NONE ) { 704 | 705 | document.addEventListener( 'mousemove', onMouseMove, false ); 706 | document.addEventListener( 'mouseup', onMouseUp, false ); 707 | 708 | scope.dispatchEvent( startEvent ); 709 | 710 | } 711 | 712 | } 713 | 714 | function onMouseMove( event ) { 715 | 716 | if ( scope.enabled === false ) return; 717 | 718 | event.preventDefault(); 719 | 720 | switch ( state ) { 721 | 722 | case STATE.ROTATE: 723 | 724 | if ( scope.enableRotate === false ) return; 725 | 726 | handleMouseMoveRotate( event ); 727 | 728 | break; 729 | 730 | case STATE.DOLLY: 731 | 732 | if ( scope.enableZoom === false ) return; 733 | 734 | handleMouseMoveDolly( event ); 735 | 736 | break; 737 | 738 | case STATE.PAN: 739 | 740 | if ( scope.enablePan === false ) return; 741 | 742 | handleMouseMovePan( event ); 743 | 744 | break; 745 | 746 | } 747 | 748 | } 749 | 750 | function onMouseUp( event ) { 751 | 752 | if ( scope.enabled === false ) return; 753 | 754 | handleMouseUp( event ); 755 | 756 | document.removeEventListener( 'mousemove', onMouseMove, false ); 757 | document.removeEventListener( 'mouseup', onMouseUp, false ); 758 | 759 | scope.dispatchEvent( endEvent ); 760 | 761 | state = STATE.NONE; 762 | 763 | } 764 | 765 | function onMouseWheel( event ) { 766 | 767 | if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return; 768 | 769 | event.preventDefault(); 770 | event.stopPropagation(); 771 | 772 | handleMouseWheel( event ); 773 | 774 | scope.dispatchEvent( startEvent ); // not sure why these are here... 775 | scope.dispatchEvent( endEvent ); 776 | 777 | } 778 | 779 | function onKeyDown( event ) { 780 | 781 | if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return; 782 | 783 | handleKeyDown( event ); 784 | 785 | } 786 | 787 | function onTouchStart( event ) { 788 | 789 | if ( scope.enabled === false ) return; 790 | 791 | switch ( event.touches.length ) { 792 | 793 | case 1: // one-fingered touch: rotate 794 | 795 | if ( scope.enableRotate === false ) return; 796 | 797 | handleTouchStartRotate( event ); 798 | 799 | state = STATE.TOUCH_ROTATE; 800 | 801 | break; 802 | 803 | case 2: // two-fingered touch: dolly 804 | 805 | if ( scope.enableZoom === false ) return; 806 | 807 | handleTouchStartDolly( event ); 808 | 809 | state = STATE.TOUCH_DOLLY; 810 | 811 | break; 812 | 813 | case 3: // three-fingered touch: pan 814 | 815 | if ( scope.enablePan === false ) return; 816 | 817 | handleTouchStartPan( event ); 818 | 819 | state = STATE.TOUCH_PAN; 820 | 821 | break; 822 | 823 | default: 824 | 825 | state = STATE.NONE; 826 | 827 | } 828 | 829 | if ( state !== STATE.NONE ) { 830 | 831 | scope.dispatchEvent( startEvent ); 832 | 833 | } 834 | 835 | } 836 | 837 | function onTouchMove( event ) { 838 | 839 | if ( scope.enabled === false ) return; 840 | 841 | event.preventDefault(); 842 | event.stopPropagation(); 843 | 844 | switch ( event.touches.length ) { 845 | 846 | case 1: // one-fingered touch: rotate 847 | 848 | if ( scope.enableRotate === false ) return; 849 | if ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?... 850 | 851 | handleTouchMoveRotate( event ); 852 | 853 | break; 854 | 855 | case 2: // two-fingered touch: dolly 856 | 857 | if ( scope.enableZoom === false ) return; 858 | if ( state !== STATE.TOUCH_DOLLY ) return; // is this needed?... 859 | 860 | handleTouchMoveDolly( event ); 861 | 862 | break; 863 | 864 | case 3: // three-fingered touch: pan 865 | 866 | if ( scope.enablePan === false ) return; 867 | if ( state !== STATE.TOUCH_PAN ) return; // is this needed?... 868 | 869 | handleTouchMovePan( event ); 870 | 871 | break; 872 | 873 | default: 874 | 875 | state = STATE.NONE; 876 | 877 | } 878 | } 879 | 880 | function onTouchEnd( event ) { 881 | 882 | if ( scope.enabled === false ) return; 883 | 884 | handleTouchEnd( event ); 885 | 886 | scope.dispatchEvent( endEvent ); 887 | 888 | state = STATE.NONE; 889 | 890 | } 891 | 892 | function onContextMenu( event ) { 893 | 894 | if ( scope.enabled === false ) return; 895 | 896 | event.preventDefault(); 897 | 898 | } 899 | 900 | // 901 | 902 | scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); 903 | 904 | scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); 905 | scope.domElement.addEventListener( 'wheel', onMouseWheel, false ); 906 | 907 | scope.domElement.addEventListener( 'touchstart', onTouchStart, false ); 908 | scope.domElement.addEventListener( 'touchend', onTouchEnd, false ); 909 | scope.domElement.addEventListener( 'touchmove', onTouchMove, false ); 910 | 911 | window.addEventListener( 'keydown', onKeyDown, false ); 912 | 913 | // force an update at start 914 | 915 | this.update(); 916 | 917 | }; 918 | 919 | THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype ); 920 | THREE.OrbitControls.prototype.constructor = THREE.OrbitControls; 921 | 922 | Object.defineProperties( THREE.OrbitControls.prototype, { 923 | 924 | center: { 925 | 926 | get: function () { 927 | 928 | console.warn( 'THREE.OrbitControls: .center has been renamed to .target' ); 929 | return this.target; 930 | 931 | } 932 | 933 | }, 934 | 935 | // backward compatibility 936 | 937 | noZoom: { 938 | 939 | get: function () { 940 | 941 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); 942 | return ! this.enableZoom; 943 | 944 | }, 945 | 946 | set: function ( value ) { 947 | 948 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); 949 | this.enableZoom = ! value; 950 | 951 | } 952 | 953 | }, 954 | 955 | noRotate: { 956 | 957 | get: function () { 958 | 959 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); 960 | return ! this.enableRotate; 961 | 962 | }, 963 | 964 | set: function ( value ) { 965 | 966 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); 967 | this.enableRotate = ! value; 968 | 969 | } 970 | 971 | }, 972 | 973 | noPan: { 974 | 975 | get: function () { 976 | 977 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); 978 | return ! this.enablePan; 979 | 980 | }, 981 | 982 | set: function ( value ) { 983 | 984 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); 985 | this.enablePan = ! value; 986 | 987 | } 988 | 989 | }, 990 | 991 | noKeys: { 992 | 993 | get: function () { 994 | 995 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); 996 | return ! this.enableKeys; 997 | 998 | }, 999 | 1000 | set: function ( value ) { 1001 | 1002 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); 1003 | this.enableKeys = ! value; 1004 | 1005 | } 1006 | 1007 | }, 1008 | 1009 | staticMoving: { 1010 | 1011 | get: function () { 1012 | 1013 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); 1014 | return ! this.enableDamping; 1015 | 1016 | }, 1017 | 1018 | set: function ( value ) { 1019 | 1020 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); 1021 | this.enableDamping = ! value; 1022 | 1023 | } 1024 | 1025 | }, 1026 | 1027 | dynamicDampingFactor: { 1028 | 1029 | get: function () { 1030 | 1031 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); 1032 | return this.dampingFactor; 1033 | 1034 | }, 1035 | 1036 | set: function ( value ) { 1037 | 1038 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); 1039 | this.dampingFactor = value; 1040 | 1041 | } 1042 | 1043 | } 1044 | 1045 | } ); 1046 | -------------------------------------------------------------------------------- /js/libs/symbol.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 对于ES6中Symbol的极简兼容 3 | * 方便模拟私有变量 4 | */ 5 | 6 | let Symbol = window.Symbol 7 | let idCounter = 0 8 | 9 | if (!Symbol) { 10 | Symbol = function Symbol(key) { 11 | return `__${key}_${Math.floor(Math.random() * 1e9)}_${++idCounter}__` 12 | } 13 | 14 | Symbol.iterator = Symbol('Symbol.iterator') 15 | } 16 | 17 | window.Symbol = Symbol 18 | -------------------------------------------------------------------------------- /js/libs/weapp-adapter.js: -------------------------------------------------------------------------------- 1 | /******/ 2 | (function(modules) { // webpackBootstrap 3 | /******/ // The module cache 4 | /******/ 5 | var installedModules = {} 6 | 7 | /******/ // The require function 8 | /******/ 9 | function __webpack_require__(moduleId) { 10 | 11 | /******/ // Check if module is in cache 12 | /******/ 13 | if (installedModules[moduleId]) 14 | /******/ 15 | return installedModules[moduleId].exports 16 | 17 | /******/ // Create a new module (and put it into the cache) 18 | /******/ 19 | var module = installedModules[moduleId] = { 20 | /******/ 21 | exports: {}, 22 | /******/ 23 | id: moduleId, 24 | /******/ 25 | loaded: false 26 | /******/ 27 | } 28 | 29 | /******/ // Execute the module function 30 | /******/ 31 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__) 32 | 33 | /******/ // Flag the module as loaded 34 | /******/ 35 | module.loaded = true 36 | 37 | /******/ // Return the exports of the module 38 | /******/ 39 | return module.exports 40 | /******/ 41 | } 42 | 43 | 44 | /******/ // expose the modules object (__webpack_modules__) 45 | /******/ 46 | __webpack_require__.m = modules 47 | 48 | /******/ // expose the module cache 49 | /******/ 50 | __webpack_require__.c = installedModules 51 | 52 | /******/ // __webpack_public_path__ 53 | /******/ 54 | __webpack_require__.p = "" 55 | 56 | /******/ // Load entry module and return exports 57 | /******/ 58 | return __webpack_require__(0) 59 | /******/ 60 | }) 61 | /************************************************************************/ 62 | /******/ 63 | ([ 64 | /* 0 */ 65 | /***/ 66 | (function(module, exports, __webpack_require__) { 67 | 68 | 'use strict' 69 | 70 | var _window2 = __webpack_require__(1) 71 | 72 | var _window = _interopRequireWildcard(_window2) 73 | 74 | function _interopRequireWildcard(obj) { 75 | if (obj && obj.__esModule) { 76 | return obj 77 | } else { 78 | var newObj = {}; 79 | if (obj != null) { 80 | for (var key in obj) { 81 | if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key] 82 | } 83 | } 84 | newObj.default = obj; 85 | return newObj 86 | } 87 | } 88 | 89 | var global = GameGlobal 90 | 91 | function inject() { 92 | _window.addEventListener = _window.canvas.addEventListener = function(type, listener) { 93 | _window.document.addEventListener(type, listener) 94 | } 95 | _window.removeEventListener = _window.canvas.removeEventListener = function(type, listener) { 96 | _window.document.removeEventListener(type, listener) 97 | } 98 | 99 | var _wx$getSystemInfoSync = wx.getSystemInfoSync(), 100 | platform = _wx$getSystemInfoSync.platform 101 | 102 | // 开发者工具无法重定义 window 103 | 104 | 105 | if (typeof __devtoolssubcontext === 'undefined' && platform === 'devtools') { 106 | for (var key in _window) { 107 | var descriptor = Object.getOwnPropertyDescriptor(global, key) 108 | 109 | if (!descriptor || descriptor.configurable === true) { 110 | Object.defineProperty(window, key, { 111 | value: _window[key] 112 | }) 113 | } 114 | } 115 | 116 | for (var _key in _window.document) { 117 | var _descriptor = Object.getOwnPropertyDescriptor(global.document, _key) 118 | 119 | if (!_descriptor || _descriptor.configurable === true) { 120 | Object.defineProperty(global.document, _key, { 121 | value: _window.document[_key] 122 | }) 123 | } 124 | } 125 | window.parent = window 126 | } else { 127 | for (var _key2 in _window) { 128 | global[_key2] = _window[_key2] 129 | } 130 | global.window = _window 131 | window = global 132 | window.top = window.parent = window 133 | } 134 | } 135 | 136 | if (!GameGlobal.__isAdapterInjected) { 137 | GameGlobal.__isAdapterInjected = true 138 | inject() 139 | } 140 | 141 | /***/ 142 | }), 143 | /* 1 */ 144 | /***/ 145 | (function(module, exports, __webpack_require__) { 146 | 147 | 'use strict' 148 | 149 | Object.defineProperty(exports, "__esModule", { 150 | value: true 151 | }) 152 | 153 | exports.cancelAnimationFrame = undefined 154 | exports.requestAnimationFrame = undefined 155 | exports.clearInterval = undefined 156 | exports.clearTimeout = undefined 157 | exports.setInterval = undefined 158 | exports.setTimeout = undefined 159 | exports.canvas = undefined 160 | exports.location = undefined 161 | exports.localStorage = undefined 162 | exports.HTMLElement = undefined 163 | exports.FileReader = undefined 164 | exports.Audio = undefined 165 | exports.Image = undefined 166 | exports.WebSocket = undefined 167 | exports.XMLHttpRequest = undefined 168 | exports.navigator = undefined 169 | exports.document = undefined 170 | 171 | // 小胖.改 172 | exports.TouchEvent = undefined 173 | exports.HTMLAudioElement = undefined 174 | 175 | var _WindowProperties = __webpack_require__(2) 176 | 177 | Object.keys(_WindowProperties).forEach(function(key) { 178 | if (key === "default" || key === "__esModule") return 179 | Object.defineProperty(exports, key, { 180 | enumerable: true, 181 | get: function get() { 182 | return _WindowProperties[key] 183 | } 184 | }) 185 | }) 186 | 187 | var _constructor = __webpack_require__(3) 188 | 189 | Object.keys(_constructor).forEach(function(key) { 190 | if (key === "default" || key === "__esModule") return 191 | Object.defineProperty(exports, key, { 192 | enumerable: true, 193 | get: function get() { 194 | return _constructor[key] 195 | } 196 | }) 197 | }) 198 | 199 | var _Canvas = __webpack_require__(9) 200 | 201 | var _Canvas2 = _interopRequireDefault(_Canvas) 202 | 203 | var _document2 = __webpack_require__(10) 204 | 205 | var _document3 = _interopRequireDefault(_document2) 206 | 207 | var _navigator2 = __webpack_require__(17) 208 | 209 | var _navigator3 = _interopRequireDefault(_navigator2) 210 | 211 | var _XMLHttpRequest2 = __webpack_require__(18) 212 | 213 | var _XMLHttpRequest3 = _interopRequireDefault(_XMLHttpRequest2) 214 | 215 | var _WebSocket2 = __webpack_require__(19) 216 | 217 | var _WebSocket3 = _interopRequireDefault(_WebSocket2) 218 | 219 | var _Image2 = __webpack_require__(11) 220 | 221 | var _Image3 = _interopRequireDefault(_Image2) 222 | 223 | var _Audio2 = __webpack_require__(12) 224 | 225 | var _Audio3 = _interopRequireDefault(_Audio2) 226 | 227 | var _FileReader2 = __webpack_require__(20) 228 | 229 | var _FileReader3 = _interopRequireDefault(_FileReader2) 230 | 231 | var _HTMLElement2 = __webpack_require__(4) 232 | 233 | var _HTMLElement3 = _interopRequireDefault(_HTMLElement2) 234 | 235 | var _localStorage2 = __webpack_require__(21) 236 | 237 | var _localStorage3 = _interopRequireDefault(_localStorage2) 238 | 239 | var _location2 = __webpack_require__(22) 240 | 241 | var _location3 = _interopRequireDefault(_location2) 242 | 243 | // 小胖.改 244 | var _TouchEvent2 = __webpack_require__(16) 245 | var _TouchEvent3 = _interopRequireDefault(_TouchEvent2) 246 | 247 | function _interopRequireDefault(obj) { 248 | return obj && obj.__esModule ? obj : { 249 | default: obj 250 | } 251 | } 252 | 253 | exports.document = _document3.default 254 | exports.navigator = _navigator3.default 255 | exports.XMLHttpRequest = _XMLHttpRequest3.default 256 | exports.WebSocket = _WebSocket3.default 257 | exports.Image = _Image3.default 258 | exports.Audio = _Audio3.default 259 | exports.FileReader = _FileReader3.default 260 | exports.HTMLElement = _HTMLElement3.default 261 | exports.localStorage = _localStorage3.default 262 | exports.location = _location3.default 263 | 264 | // 小胖.改 265 | exports.TouchEvent = _TouchEvent3.default 266 | exports.HTMLAudioElement = _Audio3.HTMLAudioElement 267 | 268 | // 暴露全局的 canvas 269 | // 小胖.改 270 | var canvas = GameGlobal._screencanvas || new _Canvas2.default() 271 | 272 | exports.canvas = canvas 273 | exports.setTimeout = setTimeout 274 | exports.setInterval = setInterval 275 | exports.clearTimeout = clearTimeout 276 | exports.clearInterval = clearInterval 277 | exports.requestAnimationFrame = requestAnimationFrame 278 | exports.cancelAnimationFrame = cancelAnimationFrame 279 | 280 | /***/ 281 | }), 282 | /* 2 */ 283 | /***/ 284 | (function(module, exports) { 285 | 286 | "use strict" 287 | 288 | Object.defineProperty(exports, "__esModule", { 289 | value: true 290 | }) 291 | 292 | var _wx$getSystemInfoSync = wx.getSystemInfoSync(), 293 | screenWidth = _wx$getSystemInfoSync.screenWidth, 294 | screenHeight = _wx$getSystemInfoSync.screenHeight, 295 | devicePixelRatio = _wx$getSystemInfoSync.devicePixelRatio 296 | 297 | var innerWidth = exports.innerWidth = screenWidth 298 | var innerHeight = exports.innerHeight = screenHeight 299 | exports.devicePixelRatio = devicePixelRatio 300 | var screen = exports.screen = { 301 | availWidth: innerWidth, 302 | availHeight: innerHeight 303 | } 304 | var performance = exports.performance = { 305 | now: function now() { 306 | return Date.now() / 1000 307 | } 308 | } 309 | var ontouchstart = exports.ontouchstart = null 310 | var ontouchmove = exports.ontouchmove = null 311 | var ontouchend = exports.ontouchend = null 312 | 313 | /***/ 314 | }), 315 | /* 3 */ 316 | /***/ 317 | (function(module, exports, __webpack_require__) { 318 | 319 | 'use strict' 320 | 321 | Object.defineProperty(exports, "__esModule", { 322 | value: true 323 | }) 324 | 325 | // 小胖.改 326 | exports.HTMLCanvasElement = exports.HTMLImageElement = exports.HTMLVideoElement = undefined 327 | 328 | var _HTMLElement3 = __webpack_require__(4) 329 | 330 | var _HTMLElement4 = _interopRequireDefault(_HTMLElement3) 331 | 332 | function _interopRequireDefault(obj) { 333 | return obj && obj.__esModule ? obj : { 334 | default: obj 335 | } 336 | } 337 | 338 | function _classCallCheck(instance, Constructor) { 339 | if (!(instance instanceof Constructor)) { 340 | throw new TypeError("Cannot call a class as a function") 341 | } 342 | } 343 | 344 | function _possibleConstructorReturn(self, call) { 345 | if (!self) { 346 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 347 | } 348 | return call && (typeof call === "object" || typeof call === "function") ? call : self 349 | } 350 | 351 | function _inherits(subClass, superClass) { 352 | if (typeof superClass !== "function" && superClass !== null) { 353 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 354 | } 355 | subClass.prototype = Object.create(superClass && superClass.prototype, { 356 | constructor: { 357 | value: subClass, 358 | enumerable: false, 359 | writable: true, 360 | configurable: true 361 | } 362 | }); 363 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 364 | } 365 | 366 | // 小胖.改 367 | var HTMLImageElement = exports.HTMLImageElement = function(_HTMLElement) { 368 | var wxImageElement = wx.createImage().constructor; 369 | 370 | return wxImageElement 371 | }(_HTMLElement4.default) 372 | 373 | // 小胖.改 374 | var HTMLCanvasElement = exports.HTMLCanvasElement = function(_HTMLElement2) { 375 | var canvas = GameGlobal._screencanvas || wx.createCanvas(); 376 | GameGlobal._screencanvas = canvas; 377 | var wxCanvasElement = canvas.constructor; 378 | 379 | return wxCanvasElement 380 | }(_HTMLElement4.default) 381 | 382 | // 小胖.改 383 | var HTMLVideoElement = exports.HTMLVideoElement = function(_HTMLElement2) { 384 | _inherits(HTMLVideoElement, _HTMLElement2) 385 | 386 | function HTMLVideoElement() { 387 | _classCallCheck(this, HTMLVideoElement) 388 | 389 | return _possibleConstructorReturn(this, (HTMLVideoElement.__proto__ || Object.getPrototypeOf(HTMLVideoElement)).call(this, 'video')) 390 | } 391 | 392 | return HTMLVideoElement 393 | }(_HTMLElement4.default) 394 | 395 | /***/ 396 | }), 397 | /* 4 */ 398 | /***/ 399 | (function(module, exports, __webpack_require__) { 400 | 401 | 'use strict' 402 | 403 | Object.defineProperty(exports, "__esModule", { 404 | value: true 405 | }) 406 | 407 | var _createClass = function() { 408 | function defineProperties(target, props) { 409 | for (var i = 0; i < props.length; i++) { 410 | var descriptor = props[i]; 411 | descriptor.enumerable = descriptor.enumerable || false; 412 | descriptor.configurable = true; 413 | if ("value" in descriptor) descriptor.writable = true; 414 | Object.defineProperty(target, descriptor.key, descriptor) 415 | } 416 | } 417 | return function(Constructor, protoProps, staticProps) { 418 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 419 | if (staticProps) defineProperties(Constructor, staticProps); 420 | return Constructor 421 | } 422 | }() 423 | 424 | var _Element2 = __webpack_require__(5) 425 | 426 | var _Element3 = _interopRequireDefault(_Element2) 427 | 428 | var _util = __webpack_require__(8) 429 | 430 | var _WindowProperties = __webpack_require__(2) 431 | 432 | function _interopRequireDefault(obj) { 433 | return obj && obj.__esModule ? obj : { 434 | default: obj 435 | } 436 | } 437 | 438 | function _classCallCheck(instance, Constructor) { 439 | if (!(instance instanceof Constructor)) { 440 | throw new TypeError("Cannot call a class as a function") 441 | } 442 | } 443 | 444 | function _possibleConstructorReturn(self, call) { 445 | if (!self) { 446 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 447 | } 448 | return call && (typeof call === "object" || typeof call === "function") ? call : self 449 | } 450 | 451 | function _inherits(subClass, superClass) { 452 | if (typeof superClass !== "function" && superClass !== null) { 453 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 454 | } 455 | subClass.prototype = Object.create(superClass && superClass.prototype, { 456 | constructor: { 457 | value: subClass, 458 | enumerable: false, 459 | writable: true, 460 | configurable: true 461 | } 462 | }); 463 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 464 | } 465 | 466 | var HTMLElement = function(_Element) { 467 | _inherits(HTMLElement, _Element) 468 | 469 | function HTMLElement() { 470 | var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '' 471 | 472 | _classCallCheck(this, HTMLElement) 473 | 474 | var _this = _possibleConstructorReturn(this, (HTMLElement.__proto__ || Object.getPrototypeOf(HTMLElement)).call(this)) 475 | 476 | _this.className = '' 477 | _this.childern = [] 478 | _this.style = { 479 | width: _WindowProperties.innerWidth + 'px', 480 | height: _WindowProperties.innerHeight + 'px' 481 | } 482 | _this.insertBefore = _util.noop 483 | _this.innerHTML = '' 484 | 485 | _this.tagName = tagName.toUpperCase() 486 | return _this 487 | } 488 | 489 | _createClass(HTMLElement, [{ 490 | key: 'setAttribute', 491 | value: function setAttribute(name, value) { 492 | this[name] = value 493 | } 494 | }, { 495 | key: 'getAttribute', 496 | value: function getAttribute(name) { 497 | return this[name] 498 | } 499 | }, { 500 | key: 'getBoundingClientRect', 501 | value: function getBoundingClientRect() { 502 | return { 503 | top: 0, 504 | left: 0, 505 | width: _WindowProperties.innerWidth, 506 | height: _WindowProperties.innerHeight 507 | } 508 | } 509 | }, { 510 | key: 'focus', 511 | value: function focus() {} 512 | }, { 513 | key: 'clientWidth', 514 | get: function get() { 515 | var ret = parseInt(this.style.fontSize, 10) * this.innerHTML.length 516 | 517 | return Number.isNaN(ret) ? 0 : ret 518 | } 519 | }, { 520 | key: 'clientHeight', 521 | get: function get() { 522 | var ret = parseInt(this.style.fontSize, 10) 523 | 524 | return Number.isNaN(ret) ? 0 : ret 525 | } 526 | }]) 527 | 528 | return HTMLElement 529 | }(_Element3.default) 530 | 531 | exports.default = HTMLElement 532 | 533 | /***/ 534 | }), 535 | /* 5 */ 536 | /***/ 537 | (function(module, exports, __webpack_require__) { 538 | 539 | 'use strict' 540 | 541 | Object.defineProperty(exports, "__esModule", { 542 | value: true 543 | }) 544 | 545 | var _Node2 = __webpack_require__(6) 546 | 547 | var _Node3 = _interopRequireDefault(_Node2) 548 | 549 | function _interopRequireDefault(obj) { 550 | return obj && obj.__esModule ? obj : { 551 | default: obj 552 | } 553 | } 554 | 555 | function _classCallCheck(instance, Constructor) { 556 | if (!(instance instanceof Constructor)) { 557 | throw new TypeError("Cannot call a class as a function") 558 | } 559 | } 560 | 561 | function _possibleConstructorReturn(self, call) { 562 | if (!self) { 563 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 564 | } 565 | return call && (typeof call === "object" || typeof call === "function") ? call : self 566 | } 567 | 568 | function _inherits(subClass, superClass) { 569 | if (typeof superClass !== "function" && superClass !== null) { 570 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 571 | } 572 | subClass.prototype = Object.create(superClass && superClass.prototype, { 573 | constructor: { 574 | value: subClass, 575 | enumerable: false, 576 | writable: true, 577 | configurable: true 578 | } 579 | }); 580 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 581 | } 582 | 583 | var ELement = function(_Node) { 584 | _inherits(ELement, _Node) 585 | 586 | function ELement() { 587 | _classCallCheck(this, ELement) 588 | 589 | var _this = _possibleConstructorReturn(this, (ELement.__proto__ || Object.getPrototypeOf(ELement)).call(this)) 590 | 591 | _this.className = '' 592 | _this.children = [] 593 | return _this 594 | } 595 | 596 | return ELement 597 | }(_Node3.default) 598 | 599 | exports.default = ELement 600 | 601 | /***/ 602 | }), 603 | /* 6 */ 604 | /***/ 605 | (function(module, exports, __webpack_require__) { 606 | 607 | 'use strict' 608 | 609 | Object.defineProperty(exports, "__esModule", { 610 | value: true 611 | }) 612 | 613 | var _createClass = function() { 614 | function defineProperties(target, props) { 615 | for (var i = 0; i < props.length; i++) { 616 | var descriptor = props[i]; 617 | descriptor.enumerable = descriptor.enumerable || false; 618 | descriptor.configurable = true; 619 | if ("value" in descriptor) descriptor.writable = true; 620 | Object.defineProperty(target, descriptor.key, descriptor) 621 | } 622 | } 623 | return function(Constructor, protoProps, staticProps) { 624 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 625 | if (staticProps) defineProperties(Constructor, staticProps); 626 | return Constructor 627 | } 628 | }() 629 | 630 | var _EventTarget2 = __webpack_require__(7) 631 | 632 | var _EventTarget3 = _interopRequireDefault(_EventTarget2) 633 | 634 | function _interopRequireDefault(obj) { 635 | return obj && obj.__esModule ? obj : { 636 | default: obj 637 | } 638 | } 639 | 640 | function _classCallCheck(instance, Constructor) { 641 | if (!(instance instanceof Constructor)) { 642 | throw new TypeError("Cannot call a class as a function") 643 | } 644 | } 645 | 646 | function _possibleConstructorReturn(self, call) { 647 | if (!self) { 648 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 649 | } 650 | return call && (typeof call === "object" || typeof call === "function") ? call : self 651 | } 652 | 653 | function _inherits(subClass, superClass) { 654 | if (typeof superClass !== "function" && superClass !== null) { 655 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 656 | } 657 | subClass.prototype = Object.create(superClass && superClass.prototype, { 658 | constructor: { 659 | value: subClass, 660 | enumerable: false, 661 | writable: true, 662 | configurable: true 663 | } 664 | }); 665 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 666 | } 667 | 668 | var Node = function(_EventTarget) { 669 | _inherits(Node, _EventTarget) 670 | 671 | function Node() { 672 | _classCallCheck(this, Node) 673 | 674 | var _this = _possibleConstructorReturn(this, (Node.__proto__ || Object.getPrototypeOf(Node)).call(this)) 675 | 676 | _this.childNodes = [] 677 | return _this 678 | } 679 | 680 | _createClass(Node, [{ 681 | key: 'appendChild', 682 | value: function appendChild(node) { 683 | if (node instanceof Node) { 684 | this.childNodes.push(node) 685 | } else { 686 | throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.') 687 | } 688 | } 689 | }, { 690 | key: 'cloneNode', 691 | value: function cloneNode() { 692 | var copyNode = Object.create(this) 693 | 694 | Object.assign(copyNode, this) 695 | return copyNode 696 | } 697 | }, { 698 | key: 'removeChild', 699 | value: function removeChild(node) { 700 | var index = this.childNodes.findIndex(function(child) { 701 | return child === node 702 | }) 703 | 704 | if (index > -1) { 705 | return this.childNodes.splice(index, 1) 706 | } 707 | return null 708 | } 709 | }]) 710 | 711 | return Node 712 | }(_EventTarget3.default) 713 | 714 | exports.default = Node 715 | 716 | /***/ 717 | }), 718 | /* 7 */ 719 | /***/ 720 | (function(module, exports) { 721 | 722 | 'use strict' 723 | 724 | Object.defineProperty(exports, "__esModule", { 725 | value: true 726 | }) 727 | 728 | var _createClass = function() { 729 | function defineProperties(target, props) { 730 | for (var i = 0; i < props.length; i++) { 731 | var descriptor = props[i]; 732 | descriptor.enumerable = descriptor.enumerable || false; 733 | descriptor.configurable = true; 734 | if ("value" in descriptor) descriptor.writable = true; 735 | Object.defineProperty(target, descriptor.key, descriptor) 736 | } 737 | } 738 | return function(Constructor, protoProps, staticProps) { 739 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 740 | if (staticProps) defineProperties(Constructor, staticProps); 741 | return Constructor 742 | } 743 | }() 744 | 745 | function _classCallCheck(instance, Constructor) { 746 | if (!(instance instanceof Constructor)) { 747 | throw new TypeError("Cannot call a class as a function") 748 | } 749 | } 750 | 751 | var _events = new WeakMap() 752 | 753 | var EventTarget = function() { 754 | function EventTarget() { 755 | _classCallCheck(this, EventTarget) 756 | 757 | _events.set(this, {}) 758 | } 759 | 760 | _createClass(EventTarget, [{ 761 | key: 'addEventListener', 762 | value: function addEventListener(type, listener) { 763 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {} 764 | 765 | var events = _events.get(this) 766 | 767 | if (!events) { 768 | events = {} 769 | _events.set(this, events) 770 | } 771 | if (!events[type]) { 772 | events[type] = [] 773 | } 774 | events[type].push(listener) 775 | 776 | if (options.capture) { 777 | console.warn('EventTarget.addEventListener: options.capture is not implemented.') 778 | } 779 | if (options.once) { 780 | console.warn('EventTarget.addEventListener: options.once is not implemented.') 781 | } 782 | if (options.passive) { 783 | console.warn('EventTarget.addEventListener: options.passive is not implemented.') 784 | } 785 | } 786 | }, { 787 | key: 'removeEventListener', 788 | value: function removeEventListener(type, listener) { 789 | var listeners = _events.get(this)[type] 790 | 791 | if (listeners && listeners.length > 0) { 792 | for (var i = listeners.length; i--; i > 0) { 793 | if (listeners[i] === listener) { 794 | listeners.splice(i, 1) 795 | break 796 | } 797 | } 798 | } 799 | } 800 | }, { 801 | key: 'dispatchEvent', 802 | value: function dispatchEvent() { 803 | var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {} 804 | 805 | var listeners = _events.get(this)[event.type] 806 | 807 | if (listeners) { 808 | for (var i = 0; i < listeners.length; i++) { 809 | listeners[i](event) 810 | } 811 | } 812 | } 813 | }]) 814 | 815 | return EventTarget 816 | }() 817 | 818 | exports.default = EventTarget 819 | 820 | /***/ 821 | }), 822 | /* 8 */ 823 | /***/ 824 | (function(module, exports) { 825 | 826 | "use strict" 827 | 828 | Object.defineProperty(exports, "__esModule", { 829 | value: true 830 | }) 831 | exports.noop = noop 832 | 833 | function noop() {} 834 | 835 | /***/ 836 | }), 837 | /* 9 */ 838 | /***/ 839 | (function(module, exports, __webpack_require__) { 840 | 841 | 'use strict' 842 | 843 | Object.defineProperty(exports, "__esModule", { 844 | value: true 845 | }) 846 | exports.default = Canvas 847 | 848 | var _constructor = __webpack_require__(3) 849 | 850 | var _HTMLElement = __webpack_require__(4) 851 | 852 | var _HTMLElement2 = _interopRequireDefault(_HTMLElement) 853 | 854 | var _document = __webpack_require__(10) 855 | 856 | var _document2 = _interopRequireDefault(_document) 857 | 858 | function _interopRequireDefault(obj) { 859 | return obj && obj.__esModule ? obj : { 860 | default: obj 861 | } 862 | } 863 | 864 | var hasModifiedCanvasPrototype = false 865 | var hasInit2DContextConstructor = false 866 | var hasInitWebGLContextConstructor = false 867 | 868 | function Canvas() { 869 | var canvas = wx.createCanvas() 870 | 871 | canvas.type = 'canvas' 872 | 873 | canvas.__proto__.__proto__ = new _HTMLElement2.default('canvas') 874 | 875 | var _getContext = canvas.getContext 876 | 877 | canvas.getBoundingClientRect = function() { 878 | var ret = { 879 | top: 0, 880 | left: 0, 881 | width: window.innerWidth, 882 | height: window.innerHeight 883 | } 884 | return ret 885 | } 886 | 887 | return canvas 888 | } 889 | 890 | /***/ 891 | }), 892 | /* 10 */ 893 | /***/ 894 | (function(module, exports, __webpack_require__) { 895 | 896 | 'use strict' 897 | 898 | Object.defineProperty(exports, "__esModule", { 899 | value: true 900 | }) 901 | 902 | var _window = __webpack_require__(1) 903 | 904 | var window = _interopRequireWildcard(_window) 905 | 906 | var _HTMLElement = __webpack_require__(4) 907 | 908 | var _HTMLElement2 = _interopRequireDefault(_HTMLElement) 909 | 910 | var _Image = __webpack_require__(11) 911 | 912 | var _Image2 = _interopRequireDefault(_Image) 913 | 914 | var _Audio = __webpack_require__(12) 915 | 916 | var _Audio2 = _interopRequireDefault(_Audio) 917 | 918 | var _Canvas = __webpack_require__(9) 919 | 920 | var _Canvas2 = _interopRequireDefault(_Canvas) 921 | 922 | __webpack_require__(15) 923 | 924 | function _interopRequireDefault(obj) { 925 | return obj && obj.__esModule ? obj : { 926 | default: obj 927 | } 928 | } 929 | 930 | function _interopRequireWildcard(obj) { 931 | if (obj && obj.__esModule) { 932 | return obj 933 | } else { 934 | var newObj = {}; 935 | if (obj != null) { 936 | for (var key in obj) { 937 | if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key] 938 | } 939 | } 940 | newObj.default = obj; 941 | return newObj 942 | } 943 | } 944 | 945 | var events = {} 946 | 947 | var document = { 948 | readyState: 'complete', 949 | visibilityState: 'visible', 950 | documentElement: window, 951 | hidden: false, 952 | style: {}, 953 | location: window.location, 954 | ontouchstart: null, 955 | ontouchmove: null, 956 | ontouchend: null, 957 | 958 | head: new _HTMLElement2.default('head'), 959 | body: new _HTMLElement2.default('body'), 960 | 961 | createElement: function createElement(tagName) { 962 | if (tagName === 'canvas') { 963 | return new _Canvas2.default() 964 | } else if (tagName === 'audio') { 965 | return new _Audio2.default() 966 | } else if (tagName === 'img') { 967 | return new _Image2.default() 968 | } 969 | 970 | return new _HTMLElement2.default(tagName) 971 | }, 972 | createElementNS: function createElement(nameSpace, tagName) { 973 | return this.createElement(tagName) 974 | }, 975 | getElementById: function getElementById(id) { 976 | if (id === window.canvas.id) { 977 | return window.canvas 978 | } 979 | return null 980 | }, 981 | getElementsByTagName: function getElementsByTagName(tagName) { 982 | if (tagName === 'head') { 983 | return [document.head] 984 | } else if (tagName === 'body') { 985 | return [document.body] 986 | } else if (tagName === 'canvas') { 987 | return [window.canvas] 988 | } 989 | return [] 990 | }, 991 | querySelector: function querySelector(query) { 992 | if (query === 'head') { 993 | return document.head 994 | } else if (query === 'body') { 995 | return document.body 996 | } else if (query === 'canvas') { 997 | return window.canvas 998 | } else if (query === '#' + window.canvas.id) { 999 | return window.canvas 1000 | } 1001 | return null 1002 | }, 1003 | querySelectorAll: function querySelectorAll(query) { 1004 | if (query === 'head') { 1005 | return [document.head] 1006 | } else if (query === 'body') { 1007 | return [document.body] 1008 | } else if (query === 'canvas') { 1009 | return [window.canvas] 1010 | } 1011 | return [] 1012 | }, 1013 | addEventListener: function addEventListener(type, listener) { 1014 | if (!events[type]) { 1015 | events[type] = [] 1016 | } 1017 | events[type].push(listener) 1018 | }, 1019 | removeEventListener: function removeEventListener(type, listener) { 1020 | var listeners = events[type] 1021 | 1022 | if (listeners && listeners.length > 0) { 1023 | for (var i = listeners.length; i--; i > 0) { 1024 | if (listeners[i] === listener) { 1025 | listeners.splice(i, 1) 1026 | break 1027 | } 1028 | } 1029 | } 1030 | }, 1031 | dispatchEvent: function dispatchEvent(event) { 1032 | var listeners = events[event.type] 1033 | 1034 | if (listeners) { 1035 | for (var i = 0; i < listeners.length; i++) { 1036 | listeners[i](event) 1037 | } 1038 | } 1039 | } 1040 | } 1041 | 1042 | exports.default = document 1043 | 1044 | /***/ 1045 | }), 1046 | /* 11 */ 1047 | /***/ 1048 | (function(module, exports) { 1049 | 1050 | "use strict" 1051 | 1052 | Object.defineProperty(exports, "__esModule", { 1053 | value: true 1054 | }) 1055 | exports.default = Image 1056 | 1057 | function Image() { 1058 | var image = wx.createImage() 1059 | 1060 | return image 1061 | } 1062 | 1063 | /***/ 1064 | }), 1065 | /* 12 */ 1066 | /***/ 1067 | (function(module, exports, __webpack_require__) { 1068 | 1069 | 'use strict' 1070 | 1071 | Object.defineProperty(exports, "__esModule", { 1072 | value: true 1073 | }) 1074 | 1075 | var _createClass = function() { 1076 | function defineProperties(target, props) { 1077 | for (var i = 0; i < props.length; i++) { 1078 | var descriptor = props[i]; 1079 | descriptor.enumerable = descriptor.enumerable || false; 1080 | descriptor.configurable = true; 1081 | if ("value" in descriptor) descriptor.writable = true; 1082 | Object.defineProperty(target, descriptor.key, descriptor) 1083 | } 1084 | } 1085 | return function(Constructor, protoProps, staticProps) { 1086 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 1087 | if (staticProps) defineProperties(Constructor, staticProps); 1088 | return Constructor 1089 | } 1090 | }() 1091 | 1092 | var _HTMLAudioElement2 = __webpack_require__(13) 1093 | 1094 | var _HTMLAudioElement3 = _interopRequireDefault(_HTMLAudioElement2) 1095 | 1096 | function _interopRequireDefault(obj) { 1097 | return obj && obj.__esModule ? obj : { 1098 | default: obj 1099 | } 1100 | } 1101 | 1102 | function _classCallCheck(instance, Constructor) { 1103 | if (!(instance instanceof Constructor)) { 1104 | throw new TypeError("Cannot call a class as a function") 1105 | } 1106 | } 1107 | 1108 | function _possibleConstructorReturn(self, call) { 1109 | if (!self) { 1110 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 1111 | } 1112 | return call && (typeof call === "object" || typeof call === "function") ? call : self 1113 | } 1114 | 1115 | function _inherits(subClass, superClass) { 1116 | if (typeof superClass !== "function" && superClass !== null) { 1117 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 1118 | } 1119 | subClass.prototype = Object.create(superClass && superClass.prototype, { 1120 | constructor: { 1121 | value: subClass, 1122 | enumerable: false, 1123 | writable: true, 1124 | configurable: true 1125 | } 1126 | }); 1127 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 1128 | } 1129 | 1130 | var HAVE_NOTHING = 0 1131 | var HAVE_METADATA = 1 1132 | var HAVE_CURRENT_DATA = 2 1133 | var HAVE_FUTURE_DATA = 3 1134 | var HAVE_ENOUGH_DATA = 4 1135 | 1136 | var _innerAudioContext = new WeakMap() 1137 | var _src = new WeakMap() 1138 | var _loop = new WeakMap() 1139 | var _autoplay = new WeakMap() 1140 | 1141 | var Audio = function(_HTMLAudioElement) { 1142 | _inherits(Audio, _HTMLAudioElement) 1143 | 1144 | function Audio(url) { 1145 | _classCallCheck(this, Audio) 1146 | 1147 | var _this = _possibleConstructorReturn(this, (Audio.__proto__ || Object.getPrototypeOf(Audio)).call(this)) 1148 | 1149 | _this.HAVE_NOTHING = HAVE_NOTHING 1150 | _this.HAVE_METADATA = HAVE_METADATA 1151 | _this.HAVE_CURRENT_DATA = HAVE_CURRENT_DATA 1152 | _this.HAVE_FUTURE_DATA = HAVE_FUTURE_DATA 1153 | _this.HAVE_ENOUGH_DATA = HAVE_ENOUGH_DATA 1154 | _this.readyState = HAVE_NOTHING 1155 | 1156 | 1157 | _src.set(_this, '') 1158 | 1159 | var innerAudioContext = wx.createInnerAudioContext() 1160 | 1161 | _innerAudioContext.set(_this, innerAudioContext) 1162 | 1163 | innerAudioContext.onCanplay(function() { 1164 | _this.dispatchEvent({ 1165 | type: 'load' 1166 | }) 1167 | _this.dispatchEvent({ 1168 | type: 'loadend' 1169 | }) 1170 | _this.dispatchEvent({ 1171 | type: 'canplay' 1172 | }) 1173 | _this.dispatchEvent({ 1174 | type: 'canplaythrough' 1175 | }) 1176 | _this.dispatchEvent({ 1177 | type: 'loadedmetadata' 1178 | }) 1179 | _this.readyState = HAVE_CURRENT_DATA 1180 | }) 1181 | innerAudioContext.onPlay(function() { 1182 | _this.dispatchEvent({ 1183 | type: 'play' 1184 | }) 1185 | }) 1186 | innerAudioContext.onPause(function() { 1187 | _this.dispatchEvent({ 1188 | type: 'pause' 1189 | }) 1190 | }) 1191 | innerAudioContext.onEnded(function() { 1192 | _this.dispatchEvent({ 1193 | type: 'ended' 1194 | }) 1195 | _this.readyState = HAVE_ENOUGH_DATA 1196 | }) 1197 | innerAudioContext.onError(function() { 1198 | _this.dispatchEvent({ 1199 | type: 'error' 1200 | }) 1201 | }) 1202 | 1203 | if (url) { 1204 | _innerAudioContext.get(_this).src = url 1205 | } 1206 | return _this 1207 | } 1208 | 1209 | _createClass(Audio, [{ 1210 | key: 'load', 1211 | value: function load() { 1212 | console.warn('HTMLAudioElement.load() is not implemented.') 1213 | } 1214 | }, { 1215 | key: 'play', 1216 | value: function play() { 1217 | _innerAudioContext.get(this).play() 1218 | } 1219 | }, { 1220 | key: 'pause', 1221 | value: function pause() { 1222 | _innerAudioContext.get(this).pause() 1223 | } 1224 | }, { 1225 | key: 'canPlayType', 1226 | value: function canPlayType() { 1227 | var mediaType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '' 1228 | 1229 | if (typeof mediaType !== 'string') { 1230 | return '' 1231 | } 1232 | 1233 | if (mediaType.indexOf('audio/mpeg') > -1 || mediaType.indexOf('audio/mp4')) { 1234 | return 'probably' 1235 | } 1236 | return '' 1237 | } 1238 | }, { 1239 | key: 'cloneNode', 1240 | value: function cloneNode() { 1241 | var newAudio = new Audio() 1242 | newAudio.loop = _innerAudioContext.get(this).loop 1243 | newAudio.autoplay = _innerAudioContext.get(this).loop 1244 | newAudio.src = this.src 1245 | return newAudio 1246 | } 1247 | }, { 1248 | key: 'currentTime', 1249 | get: function get() { 1250 | return _innerAudioContext.get(this).currentTime 1251 | }, 1252 | set: function set(value) { 1253 | _innerAudioContext.get(this).seek(value) 1254 | } 1255 | }, { 1256 | key: 'src', 1257 | get: function get() { 1258 | return _src.get(this) 1259 | }, 1260 | set: function set(value) { 1261 | _src.set(this, value) 1262 | _innerAudioContext.get(this).src = value 1263 | } 1264 | }, { 1265 | key: 'loop', 1266 | get: function get() { 1267 | return _innerAudioContext.get(this).loop 1268 | }, 1269 | set: function set(value) { 1270 | _innerAudioContext.get(this).loop = value 1271 | } 1272 | }, { 1273 | key: 'autoplay', 1274 | get: function get() { 1275 | return _innerAudioContext.get(this).autoplay 1276 | }, 1277 | set: function set(value) { 1278 | _innerAudioContext.get(this).autoplay = value 1279 | } 1280 | }, { 1281 | key: 'paused', 1282 | get: function get() { 1283 | return _innerAudioContext.get(this).paused 1284 | } 1285 | }]) 1286 | 1287 | return Audio 1288 | }(_HTMLAudioElement3.default) 1289 | 1290 | exports.default = Audio 1291 | exports.HTMLAudioElement = _HTMLAudioElement3.default 1292 | 1293 | /***/ 1294 | }), 1295 | /* 13 */ 1296 | /***/ 1297 | (function(module, exports, __webpack_require__) { 1298 | 1299 | 'use strict' 1300 | 1301 | Object.defineProperty(exports, "__esModule", { 1302 | value: true 1303 | }) 1304 | 1305 | var _HTMLMediaElement2 = __webpack_require__(14) 1306 | 1307 | var _HTMLMediaElement3 = _interopRequireDefault(_HTMLMediaElement2) 1308 | 1309 | function _interopRequireDefault(obj) { 1310 | return obj && obj.__esModule ? obj : { 1311 | default: obj 1312 | } 1313 | } 1314 | 1315 | function _classCallCheck(instance, Constructor) { 1316 | if (!(instance instanceof Constructor)) { 1317 | throw new TypeError("Cannot call a class as a function") 1318 | } 1319 | } 1320 | 1321 | function _possibleConstructorReturn(self, call) { 1322 | if (!self) { 1323 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 1324 | } 1325 | return call && (typeof call === "object" || typeof call === "function") ? call : self 1326 | } 1327 | 1328 | function _inherits(subClass, superClass) { 1329 | if (typeof superClass !== "function" && superClass !== null) { 1330 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 1331 | } 1332 | subClass.prototype = Object.create(superClass && superClass.prototype, { 1333 | constructor: { 1334 | value: subClass, 1335 | enumerable: false, 1336 | writable: true, 1337 | configurable: true 1338 | } 1339 | }); 1340 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 1341 | } 1342 | 1343 | var HTMLAudioElement = function(_HTMLMediaElement) { 1344 | _inherits(HTMLAudioElement, _HTMLMediaElement) 1345 | 1346 | function HTMLAudioElement() { 1347 | _classCallCheck(this, HTMLAudioElement) 1348 | 1349 | return _possibleConstructorReturn(this, (HTMLAudioElement.__proto__ || Object.getPrototypeOf(HTMLAudioElement)).call(this, 'audio')) 1350 | } 1351 | 1352 | return HTMLAudioElement 1353 | }(_HTMLMediaElement3.default) 1354 | 1355 | exports.default = HTMLAudioElement 1356 | 1357 | /***/ 1358 | }), 1359 | /* 14 */ 1360 | /***/ 1361 | (function(module, exports, __webpack_require__) { 1362 | 1363 | 'use strict' 1364 | 1365 | Object.defineProperty(exports, "__esModule", { 1366 | value: true 1367 | }) 1368 | 1369 | var _createClass = function() { 1370 | function defineProperties(target, props) { 1371 | for (var i = 0; i < props.length; i++) { 1372 | var descriptor = props[i]; 1373 | descriptor.enumerable = descriptor.enumerable || false; 1374 | descriptor.configurable = true; 1375 | if ("value" in descriptor) descriptor.writable = true; 1376 | Object.defineProperty(target, descriptor.key, descriptor) 1377 | } 1378 | } 1379 | return function(Constructor, protoProps, staticProps) { 1380 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 1381 | if (staticProps) defineProperties(Constructor, staticProps); 1382 | return Constructor 1383 | } 1384 | }() 1385 | 1386 | var _HTMLElement2 = __webpack_require__(4) 1387 | 1388 | var _HTMLElement3 = _interopRequireDefault(_HTMLElement2) 1389 | 1390 | function _interopRequireDefault(obj) { 1391 | return obj && obj.__esModule ? obj : { 1392 | default: obj 1393 | } 1394 | } 1395 | 1396 | function _classCallCheck(instance, Constructor) { 1397 | if (!(instance instanceof Constructor)) { 1398 | throw new TypeError("Cannot call a class as a function") 1399 | } 1400 | } 1401 | 1402 | function _possibleConstructorReturn(self, call) { 1403 | if (!self) { 1404 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called") 1405 | } 1406 | return call && (typeof call === "object" || typeof call === "function") ? call : self 1407 | } 1408 | 1409 | function _inherits(subClass, superClass) { 1410 | if (typeof superClass !== "function" && superClass !== null) { 1411 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass) 1412 | } 1413 | subClass.prototype = Object.create(superClass && superClass.prototype, { 1414 | constructor: { 1415 | value: subClass, 1416 | enumerable: false, 1417 | writable: true, 1418 | configurable: true 1419 | } 1420 | }); 1421 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass 1422 | } 1423 | 1424 | var HTMLMediaElement = function(_HTMLElement) { 1425 | _inherits(HTMLMediaElement, _HTMLElement) 1426 | 1427 | function HTMLMediaElement(type) { 1428 | _classCallCheck(this, HTMLMediaElement) 1429 | 1430 | return _possibleConstructorReturn(this, (HTMLMediaElement.__proto__ || Object.getPrototypeOf(HTMLMediaElement)).call(this, type)) 1431 | } 1432 | 1433 | _createClass(HTMLMediaElement, [{ 1434 | key: 'addTextTrack', 1435 | value: function addTextTrack() {} 1436 | }, { 1437 | key: 'captureStream', 1438 | value: function captureStream() {} 1439 | }, { 1440 | key: 'fastSeek', 1441 | value: function fastSeek() {} 1442 | }, { 1443 | key: 'load', 1444 | value: function load() {} 1445 | }, { 1446 | key: 'pause', 1447 | value: function pause() {} 1448 | }, { 1449 | key: 'play', 1450 | value: function play() {} 1451 | }]) 1452 | 1453 | return HTMLMediaElement 1454 | }(_HTMLElement3.default) 1455 | 1456 | exports.default = HTMLMediaElement 1457 | 1458 | /***/ 1459 | }), 1460 | /* 15 */ 1461 | /***/ 1462 | (function(module, exports, __webpack_require__) { 1463 | 1464 | 'use strict' 1465 | 1466 | __webpack_require__(16) 1467 | 1468 | /***/ 1469 | }), 1470 | /* 16 */ 1471 | /***/ 1472 | (function(module, exports, __webpack_require__) { 1473 | 1474 | 'use strict' 1475 | 1476 | // 小胖.改 1477 | Object.defineProperty(exports, "__esModule", { 1478 | value: true 1479 | }) 1480 | 1481 | var _window = __webpack_require__(1) 1482 | 1483 | var window = _interopRequireWildcard(_window) 1484 | 1485 | var _document = __webpack_require__(10) 1486 | 1487 | var _document2 = _interopRequireDefault(_document) 1488 | 1489 | var _util = __webpack_require__(8) 1490 | 1491 | function _interopRequireDefault(obj) { 1492 | return obj && obj.__esModule ? obj : { 1493 | default: obj 1494 | } 1495 | } 1496 | 1497 | function _interopRequireWildcard(obj) { 1498 | if (obj && obj.__esModule) { 1499 | return obj 1500 | } else { 1501 | var newObj = {}; 1502 | if (obj != null) { 1503 | for (var key in obj) { 1504 | if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key] 1505 | } 1506 | } 1507 | newObj.default = obj; 1508 | return newObj 1509 | } 1510 | } 1511 | 1512 | function _classCallCheck(instance, Constructor) { 1513 | if (!(instance instanceof Constructor)) { 1514 | throw new TypeError("Cannot call a class as a function") 1515 | } 1516 | } 1517 | 1518 | var TouchEvent = function TouchEvent(type) { 1519 | _classCallCheck(this, TouchEvent) 1520 | 1521 | this.target = window.canvas 1522 | this.currentTarget = window.canvas 1523 | this.touches = [] 1524 | this.targetTouches = [] 1525 | this.changedTouches = [] 1526 | this.preventDefault = _util.noop 1527 | this.stopPropagation = _util.noop 1528 | 1529 | this.type = type 1530 | } 1531 | 1532 | function touchEventHandlerFactory(type) { 1533 | return function(event) { 1534 | var touchEvent = new TouchEvent(type) 1535 | touchEvent.touches = event.touches 1536 | touchEvent.targetTouches = Array.prototype.slice.call(event.touches) 1537 | touchEvent.changedTouches = event.changedTouches 1538 | touchEvent.timeStamp = event.timeStamp 1539 | _document2.default.dispatchEvent(touchEvent) 1540 | } 1541 | } 1542 | 1543 | wx.onTouchStart(touchEventHandlerFactory('touchstart')) 1544 | wx.onTouchMove(touchEventHandlerFactory('touchmove')) 1545 | wx.onTouchEnd(touchEventHandlerFactory('touchend')) 1546 | wx.onTouchCancel(touchEventHandlerFactory('touchcancel')) 1547 | 1548 | // 小胖.改 1549 | exports.default = TouchEvent; 1550 | 1551 | /***/ 1552 | }), 1553 | /* 17 */ 1554 | /***/ 1555 | (function(module, exports, __webpack_require__) { 1556 | 1557 | 'use strict' 1558 | 1559 | Object.defineProperty(exports, "__esModule", { 1560 | value: true 1561 | }) 1562 | 1563 | var _util = __webpack_require__(8) 1564 | 1565 | // TODO 需要 wx.getSystemInfo 获取更详细信息 1566 | var _wx$getSystemInfoSync = wx.getSystemInfoSync(), 1567 | platform = _wx$getSystemInfoSync.platform 1568 | 1569 | var navigator = { 1570 | platform: platform, 1571 | language: 'zh-cn', 1572 | appVersion: '5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1', 1573 | userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 MicroMessenger/6.6.0 MiniGame NetType/WIFI Language/zh_CN', 1574 | onLine: true, // TODO 用 wx.getNetworkStateChange 和 wx.onNetworkStateChange 来返回真实的状态 1575 | 1576 | // TODO 用 wx.getLocation 来封装 geolocation 1577 | geolocation: { 1578 | getCurrentPosition: _util.noop, 1579 | watchPosition: _util.noop, 1580 | clearWatch: _util.noop 1581 | } 1582 | } 1583 | 1584 | exports.default = navigator 1585 | 1586 | /***/ 1587 | }), 1588 | /* 18 */ 1589 | /***/ 1590 | (function(module, exports) { 1591 | 1592 | 'use strict' 1593 | 1594 | Object.defineProperty(exports, "__esModule", { 1595 | value: true 1596 | }) 1597 | 1598 | var _createClass = function() { 1599 | function defineProperties(target, props) { 1600 | for (var i = 0; i < props.length; i++) { 1601 | var descriptor = props[i]; 1602 | descriptor.enumerable = descriptor.enumerable || false; 1603 | descriptor.configurable = true; 1604 | if ("value" in descriptor) descriptor.writable = true; 1605 | Object.defineProperty(target, descriptor.key, descriptor) 1606 | } 1607 | } 1608 | return function(Constructor, protoProps, staticProps) { 1609 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 1610 | if (staticProps) defineProperties(Constructor, staticProps); 1611 | return Constructor 1612 | } 1613 | }() 1614 | 1615 | function _classCallCheck(instance, Constructor) { 1616 | if (!(instance instanceof Constructor)) { 1617 | throw new TypeError("Cannot call a class as a function") 1618 | } 1619 | } 1620 | 1621 | var _url = new WeakMap() 1622 | var _method = new WeakMap() 1623 | var _requestHeader = new WeakMap() 1624 | var _responseHeader = new WeakMap() 1625 | var _requestTask = new WeakMap() 1626 | 1627 | function _triggerEvent(type) { 1628 | if (typeof this['on' + type] === 'function') { 1629 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 1630 | args[_key - 1] = arguments[_key] 1631 | } 1632 | 1633 | this['on' + type].apply(this, args) 1634 | } 1635 | } 1636 | 1637 | function _changeReadyState(readyState) { 1638 | this.readyState = readyState 1639 | _triggerEvent.call(this, 'readystatechange') 1640 | } 1641 | 1642 | var XMLHttpRequest = function() { 1643 | // TODO 没法模拟 HEADERS_RECEIVED 和 LOADING 两个状态 1644 | function XMLHttpRequest() { 1645 | _classCallCheck(this, XMLHttpRequest) 1646 | 1647 | this.onabort = null 1648 | this.onerror = null 1649 | this.onload = null 1650 | this.onloadstart = null 1651 | this.onprogress = null 1652 | this.ontimeout = null 1653 | this.onloadend = null 1654 | this.onreadystatechange = null 1655 | this.readyState = 0 1656 | this.response = null 1657 | this.responseText = null 1658 | this.responseType = '' 1659 | this.responseXML = null 1660 | this.status = 0 1661 | this.statusText = '' 1662 | this.upload = {} 1663 | this.withCredentials = false 1664 | 1665 | _requestHeader.set(this, { 1666 | 'content-type': 'application/x-www-form-urlencoded' 1667 | }) 1668 | _responseHeader.set(this, {}) 1669 | } 1670 | 1671 | /* 1672 | * TODO 这一批事件应该是在 XMLHttpRequestEventTarget.prototype 上面的 1673 | */ 1674 | 1675 | _createClass(XMLHttpRequest, [{ 1676 | key: 'abort', 1677 | value: function abort() { 1678 | var myRequestTask = _requestTask.get(this) 1679 | 1680 | if (myRequestTask) { 1681 | myRequestTask.abort() 1682 | } 1683 | } 1684 | }, { 1685 | key: 'getAllResponseHeaders', 1686 | value: function getAllResponseHeaders() { 1687 | var responseHeader = _responseHeader.get(this) 1688 | 1689 | return Object.keys(responseHeader).map(function(header) { 1690 | return header + ': ' + responseHeader[header] 1691 | }).join('\n') 1692 | } 1693 | }, { 1694 | key: 'getResponseHeader', 1695 | value: function getResponseHeader(header) { 1696 | return _responseHeader.get(this)[header] 1697 | } 1698 | }, { 1699 | key: 'open', 1700 | value: function open(method, url /* async, user, password 这几个参数在小程序内不支持*/ ) { 1701 | _method.set(this, method) 1702 | _url.set(this, url) 1703 | _changeReadyState.call(this, XMLHttpRequest.OPENED) 1704 | } 1705 | }, { 1706 | key: 'overrideMimeType', 1707 | value: function overrideMimeType() {} 1708 | }, { 1709 | key: 'send', 1710 | value: function send() { 1711 | var _this = this 1712 | 1713 | var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '' 1714 | 1715 | if (this.readyState !== XMLHttpRequest.OPENED) { 1716 | throw new Error("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.") 1717 | } else { 1718 | wx.request({ 1719 | data: data, 1720 | url: _url.get(this), 1721 | method: _method.get(this), 1722 | header: _requestHeader.get(this), 1723 | responseType: this.responseType, 1724 | success: function success(_ref) { 1725 | var data = _ref.data, 1726 | statusCode = _ref.statusCode, 1727 | header = _ref.header 1728 | 1729 | if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) { 1730 | try { 1731 | data = JSON.stringify(data) 1732 | } catch (e) { 1733 | data = data 1734 | } 1735 | } 1736 | 1737 | _this.status = statusCode 1738 | _responseHeader.set(_this, header) 1739 | _triggerEvent.call(_this, 'loadstart') 1740 | _changeReadyState.call(_this, XMLHttpRequest.HEADERS_RECEIVED) 1741 | _changeReadyState.call(_this, XMLHttpRequest.LOADING) 1742 | 1743 | _this.response = data 1744 | 1745 | if (data instanceof ArrayBuffer) { 1746 | _this.responseText = '' 1747 | var bytes = new Uint8Array(data) 1748 | var len = bytes.byteLength 1749 | 1750 | for (var i = 0; i < len; i++) { 1751 | _this.responseText += String.fromCharCode(bytes[i]) 1752 | } 1753 | } else { 1754 | _this.responseText = data 1755 | } 1756 | _changeReadyState.call(_this, XMLHttpRequest.DONE) 1757 | _triggerEvent.call(_this, 'load') 1758 | _triggerEvent.call(_this, 'loadend') 1759 | }, 1760 | fail: function fail(_ref2) { 1761 | var errMsg = _ref2.errMsg 1762 | 1763 | // TODO 规范错误 1764 | if (errMsg.indexOf('abort') !== -1) { 1765 | _triggerEvent.call(_this, 'abort') 1766 | } else { 1767 | _triggerEvent.call(_this, 'error', errMsg) 1768 | } 1769 | _triggerEvent.call(_this, 'loadend') 1770 | } 1771 | }) 1772 | } 1773 | } 1774 | }, { 1775 | key: 'setRequestHeader', 1776 | value: function setRequestHeader(header, value) { 1777 | var myHeader = _requestHeader.get(this) 1778 | 1779 | myHeader[header] = value 1780 | _requestHeader.set(this, myHeader) 1781 | } 1782 | }, 1783 | { 1784 | key: 'addEventListener', 1785 | value: function addEventListener(type, listener) { 1786 | if (typeof listener === 'function') { 1787 | let event = { target: this } 1788 | let that = this 1789 | this['on' + type] = function () { 1790 | listener.call(that, event) 1791 | } 1792 | } 1793 | } 1794 | } 1795 | 1796 | ]) 1797 | 1798 | return XMLHttpRequest 1799 | }() 1800 | 1801 | XMLHttpRequest.UNSEND = 0 1802 | XMLHttpRequest.OPENED = 1 1803 | XMLHttpRequest.HEADERS_RECEIVED = 2 1804 | XMLHttpRequest.LOADING = 3 1805 | XMLHttpRequest.DONE = 4 1806 | exports.default = XMLHttpRequest 1807 | 1808 | /***/ 1809 | }), 1810 | /* 19 */ 1811 | /***/ 1812 | (function(module, exports) { 1813 | 1814 | 'use strict' 1815 | 1816 | Object.defineProperty(exports, "__esModule", { 1817 | value: true 1818 | }) 1819 | 1820 | var _createClass = function() { 1821 | function defineProperties(target, props) { 1822 | for (var i = 0; i < props.length; i++) { 1823 | var descriptor = props[i]; 1824 | descriptor.enumerable = descriptor.enumerable || false; 1825 | descriptor.configurable = true; 1826 | if ("value" in descriptor) descriptor.writable = true; 1827 | Object.defineProperty(target, descriptor.key, descriptor) 1828 | } 1829 | } 1830 | return function(Constructor, protoProps, staticProps) { 1831 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 1832 | if (staticProps) defineProperties(Constructor, staticProps); 1833 | return Constructor 1834 | } 1835 | }() 1836 | 1837 | function _classCallCheck(instance, Constructor) { 1838 | if (!(instance instanceof Constructor)) { 1839 | throw new TypeError("Cannot call a class as a function") 1840 | } 1841 | } 1842 | 1843 | var _socketTask = new WeakMap() 1844 | 1845 | var WebSocket = function() { 1846 | // TODO 更新 binaryType 1847 | // The connection is in the process of closing. 1848 | // The connection is not yet open. 1849 | function WebSocket(url) { 1850 | var _this = this 1851 | 1852 | var protocols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [] 1853 | 1854 | _classCallCheck(this, WebSocket) 1855 | 1856 | this.binaryType = '' 1857 | this.bufferedAmount = 0 1858 | this.extensions = '' 1859 | this.onclose = null 1860 | this.onerror = null 1861 | this.onmessage = null 1862 | this.onopen = null 1863 | this.protocol = '' 1864 | this.readyState = 3 1865 | 1866 | if (typeof url !== 'string' || !/(^ws:\/\/)|(^wss:\/\/)/.test(url)) { 1867 | throw new TypeError('Failed to construct \'WebSocket\': The URL \'' + url + '\' is invalid') 1868 | } 1869 | 1870 | this.url = url 1871 | this.readyState = WebSocket.CONNECTING 1872 | 1873 | var socketTask = wx.connectSocket({ 1874 | url: url, 1875 | protocols: Array.isArray(protocols) ? protocols : [protocols] 1876 | }) 1877 | 1878 | _socketTask.set(this, socketTask) 1879 | 1880 | socketTask.onClose(function(res) { 1881 | _this.readyState = WebSocket.CLOSED 1882 | if (typeof _this.onclose === 'function') { 1883 | _this.onclose(res) 1884 | } 1885 | }) 1886 | 1887 | socketTask.onMessage(function(res) { 1888 | if (typeof _this.onmessage === 'function') { 1889 | _this.onmessage(res) 1890 | } 1891 | }) 1892 | 1893 | socketTask.onOpen(function() { 1894 | _this.readyState = WebSocket.OPEN 1895 | if (typeof _this.onopen === 'function') { 1896 | _this.onopen() 1897 | } 1898 | }) 1899 | 1900 | socketTask.onError(function(res) { 1901 | if (typeof _this.onerror === 'function') { 1902 | _this.onerror(new Error(res.errMsg)) 1903 | } 1904 | }) 1905 | 1906 | return this 1907 | } // TODO 小程序内目前获取不到,实际上需要根据服务器选择的 sub-protocol 返回 1908 | // TODO 更新 bufferedAmount 1909 | // The connection is closed or couldn't be opened. 1910 | 1911 | // The connection is open and ready to communicate. 1912 | 1913 | 1914 | _createClass(WebSocket, [{ 1915 | key: 'close', 1916 | value: function close(code, reason) { 1917 | this.readyState = WebSocket.CLOSING 1918 | var socketTask = _socketTask.get(this) 1919 | 1920 | socketTask.close({ 1921 | code: code, 1922 | reason: reason 1923 | }) 1924 | } 1925 | }, { 1926 | key: 'send', 1927 | value: function send(data) { 1928 | if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) { 1929 | throw new TypeError('Failed to send message: The data ' + data + ' is invalid') 1930 | } 1931 | 1932 | var socketTask = _socketTask.get(this) 1933 | 1934 | socketTask.send({ 1935 | data: data 1936 | }) 1937 | } 1938 | }]) 1939 | 1940 | return WebSocket 1941 | }() 1942 | 1943 | WebSocket.CONNECTING = 0 1944 | WebSocket.OPEN = 1 1945 | WebSocket.CLOSING = 2 1946 | WebSocket.CLOSED = 3 1947 | exports.default = WebSocket 1948 | 1949 | /***/ 1950 | }), 1951 | /* 20 */ 1952 | /***/ 1953 | (function(module, exports) { 1954 | 1955 | "use strict" 1956 | 1957 | Object.defineProperty(exports, "__esModule", { 1958 | value: true 1959 | }) 1960 | 1961 | function _classCallCheck(instance, Constructor) { 1962 | if (!(instance instanceof Constructor)) { 1963 | throw new TypeError("Cannot call a class as a function") 1964 | } 1965 | } 1966 | 1967 | /* 1968 | * TODO 使用 wx.readFile 来封装 FileReader 1969 | */ 1970 | var FileReader = function FileReader() { 1971 | _classCallCheck(this, FileReader) 1972 | } 1973 | 1974 | exports.default = FileReader 1975 | 1976 | /***/ 1977 | }), 1978 | /* 21 */ 1979 | /***/ 1980 | (function(module, exports) { 1981 | 1982 | "use strict" 1983 | 1984 | Object.defineProperty(exports, "__esModule", { 1985 | value: true 1986 | }) 1987 | var localStorage = { 1988 | get length() { 1989 | var _wx$getStorageInfoSyn = wx.getStorageInfoSync(), 1990 | keys = _wx$getStorageInfoSyn.keys 1991 | 1992 | return keys.length 1993 | }, 1994 | 1995 | key: function key(n) { 1996 | var _wx$getStorageInfoSyn2 = wx.getStorageInfoSync(), 1997 | keys = _wx$getStorageInfoSyn2.keys 1998 | 1999 | return keys[n] 2000 | }, 2001 | getItem: function getItem(key) { 2002 | return wx.getStorageSync(key) 2003 | }, 2004 | setItem: function setItem(key, value) { 2005 | return wx.setStorageSync(key, value) 2006 | }, 2007 | removeItem: function removeItem(key) { 2008 | wx.removeStorageSync(key) 2009 | }, 2010 | clear: function clear() { 2011 | wx.clearStorageSync() 2012 | } 2013 | } 2014 | 2015 | exports.default = localStorage 2016 | 2017 | /***/ 2018 | }), 2019 | /* 22 */ 2020 | /***/ 2021 | (function(module, exports) { 2022 | 2023 | 'use strict' 2024 | 2025 | Object.defineProperty(exports, "__esModule", { 2026 | value: true 2027 | }) 2028 | var location = { 2029 | href: 'game.js', 2030 | reload: function reload() {} 2031 | } 2032 | 2033 | exports.default = location 2034 | 2035 | /***/ 2036 | }) 2037 | /******/ 2038 | ]) 2039 | -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- 1 | import * as THREE from 'libs/three.min' 2 | require('libs/OrbitControls') 3 | 4 | // 此处可以改为您的 json 文件地址 5 | const model = "https://indienova.com/farm/files/indienova-logo.json" 6 | 7 | let ctx = canvas.getContext('webgl', { antialias: true, preserveDrawingBuffer: true }) 8 | 9 | let scene 10 | let renderer 11 | let camera 12 | let controls 13 | let mesh = undefined 14 | 15 | let preLoadDone = false; 16 | 17 | /** 18 | * 游戏主函数 19 | */ 20 | export default class Main { 21 | constructor() { 22 | // 初始化 23 | scene = new THREE.Scene() 24 | renderer = new THREE.WebGLRenderer({ context: ctx, canvas:canvas }) 25 | 26 | const winWidth = window.innerWidth 27 | const winHeight = window.innerHeight 28 | const cameraAspect = winWidth / winHeight 29 | 30 | renderer.setSize(winWidth, winHeight) 31 | renderer.setPixelRatio(window.devicePixelRatio) 32 | 33 | console.log("屏幕尺寸: " + winWidth + " x " + winHeight) 34 | 35 | camera = new THREE.PerspectiveCamera(75, cameraAspect, 10, 100000) 36 | camera.position.z = 1000 37 | 38 | // 模型载入处理 39 | let modelLoader = new THREE.JSONLoader() 40 | modelLoader.load(model, 41 | function(geometry, materials){ 42 | mesh = new THREE.Mesh(geometry, materials[0]) 43 | mesh.scale.set(1000, 1000, 1000) 44 | mesh.rotation.x = 1.5 45 | scene.add(mesh) 46 | console.log('模型载入完成') 47 | 48 | /* 允许渲染模型 */ 49 | preLoadDone = true 50 | }, 51 | // onProgress callback 52 | function (xhr) { 53 | console.log( (xhr.loaded / xhr.total * 100) + '% 已载入' ) 54 | }, 55 | // onError callback 56 | function(err) { 57 | console.log('载入出错', err.target.status) 58 | } 59 | ); 60 | 61 | // 添加环境光 62 | let ambientLight = new THREE.AmbientLight(0x999999) 63 | scene.add(ambientLight) 64 | 65 | // 添加投射光 66 | var directionalLight = new THREE.DirectionalLight(0xcccccc); 67 | directionalLight.position.set(0, 1200, 1000).normalize(); 68 | scene.add(directionalLight); 69 | 70 | // 添加手势控制 71 | controls = new THREE.OrbitControls(camera); 72 | 73 | this.loop() 74 | } 75 | 76 | /** 77 | * 逻辑更新主函数 78 | */ 79 | update() { 80 | // 更新代码 81 | if (preLoadDone) { 82 | } 83 | } 84 | 85 | /** 86 | * canvas 重绘函数 87 | * 每一帧重新绘制所有的需要展示的元素 88 | */ 89 | render() { 90 | if (preLoadDone) { 91 | if (mesh != undefined) 92 | mesh.rotation.z += 0.001 93 | renderer.render(scene, camera) 94 | } 95 | } 96 | 97 | // 实现帧循环 98 | loop() { 99 | this.update() 100 | this.render() 101 | 102 | window.requestAnimationFrame( 103 | this.loop.bind(this), 104 | canvas 105 | ) 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /models/indienova-logo.json: -------------------------------------------------------------------------------- 1 | { 2 | "metadata":{ 3 | "materials":1, 4 | "vertices":339, 5 | "faces":634, 6 | "type":"Geometry", 7 | "version":3, 8 | "generator":"io_three" 9 | }, 10 | "faces":[2,105,104,103,0,2,105,103,102,0,2,106,105,102,0,2,106,102,101,0,2,106,101,122,0,2,158,106,159,0,2,159,106,122,0,2,160,159,122,0,2,106,158,157,0,2,161,160,122,0,2,106,157,156,0,2,106,156,155,0,2,162,161,122,0,2,107,106,155,0,2,163,162,122,0,2,163,122,121,0,2,107,155,154,0,2,164,163,121,0,2,164,121,120,0,2,107,154,153,0,2,165,164,120,0,2,107,153,152,0,2,165,120,119,0,2,166,165,119,0,2,107,152,151,0,2,166,119,118,0,2,145,166,118,0,2,107,151,150,0,2,146,145,118,0,2,147,146,118,0,2,107,150,149,0,2,148,147,118,0,2,107,149,148,0,2,107,148,118,0,2,4,3,2,0,2,5,4,2,0,2,5,2,1,0,2,6,5,1,0,2,6,1,0,0,2,107,118,137,0,2,138,137,118,0,2,107,137,136,0,2,139,138,118,0,2,107,136,135,0,2,140,139,118,0,2,6,0,27,0,2,107,135,134,0,2,108,107,134,0,2,141,140,118,0,2,108,134,133,0,2,6,27,26,0,2,142,141,118,0,2,109,108,133,0,2,109,133,132,0,2,6,26,25,0,2,143,142,118,0,2,110,109,132,0,2,110,132,131,0,2,144,143,118,0,2,6,25,89,0,2,89,25,24,0,2,110,131,130,0,2,88,6,89,0,2,111,110,130,0,2,90,89,24,0,2,91,90,24,0,2,6,88,87,0,2,123,144,118,0,2,92,91,24,0,2,6,87,86,0,2,111,130,129,0,2,93,92,24,0,2,6,86,85,0,2,93,24,23,0,2,6,85,84,0,2,94,93,23,0,2,123,118,117,0,2,111,129,128,0,2,124,123,117,0,2,6,84,83,0,2,7,6,71,0,2,71,6,83,0,2,125,124,117,0,2,112,111,128,0,2,112,128,127,0,2,126,125,117,0,2,112,127,126,0,2,112,126,117,0,2,95,94,96,0,2,96,94,23,0,2,7,71,70,0,2,72,71,83,0,2,73,72,83,0,2,74,73,83,0,2,75,74,83,0,2,76,75,83,0,2,77,76,83,0,2,78,77,83,0,2,79,78,83,0,2,80,79,83,0,2,81,80,83,0,2,82,81,83,0,2,97,96,23,0,2,8,7,70,0,2,98,97,23,0,2,8,70,69,0,2,99,98,23,0,2,8,69,68,0,2,100,99,23,0,2,8,68,67,0,2,28,100,23,0,2,8,67,66,0,2,8,66,53,0,2,28,23,22,0,2,29,28,22,0,2,9,8,53,0,2,9,53,52,0,2,30,29,22,0,2,112,117,116,0,2,9,52,51,0,2,31,30,22,0,2,113,112,116,0,2,9,51,50,0,2,32,31,22,0,2,113,116,115,0,2,9,50,49,0,2,33,32,22,0,2,114,113,115,0,2,9,49,48,0,2,34,33,22,0,2,9,48,47,0,2,9,47,46,0,2,36,35,34,0,2,36,34,22,0,2,36,22,21,0,2,10,9,46,0,2,10,46,45,0,2,37,36,21,0,2,10,45,44,0,2,38,37,21,0,2,11,10,44,0,2,11,44,43,0,2,39,38,21,0,2,11,43,42,0,2,40,39,21,0,2,11,42,41,0,2,41,40,21,0,2,11,41,21,0,2,12,11,21,0,2,13,12,21,0,2,14,13,21,0,2,15,14,21,0,2,15,21,20,0,2,15,20,19,0,2,16,15,19,0,2,16,19,18,0,2,17,16,18,0,2,270,268,269,0,2,271,268,270,0,2,271,267,268,0,2,272,267,271,0,2,272,292,267,0,2,330,331,272,0,2,331,292,272,0,2,332,292,331,0,2,272,329,330,0,2,333,292,332,0,2,272,328,329,0,2,334,292,333,0,2,272,327,328,0,2,273,327,272,0,2,334,291,292,0,2,273,326,327,0,2,335,291,334,0,2,335,290,291,0,2,273,325,326,0,2,336,290,335,0,2,336,289,290,0,2,273,324,325,0,2,337,289,336,0,2,273,323,324,0,2,338,289,337,0,2,338,288,289,0,2,273,322,323,0,2,316,288,338,0,2,317,288,316,0,2,273,321,322,0,2,318,288,317,0,2,318,287,288,0,2,273,320,321,0,2,319,287,318,0,2,273,319,320,0,2,273,287,319,0,2,171,169,170,0,2,172,169,171,0,2,172,168,169,0,2,173,168,172,0,2,174,168,173,0,2,174,167,168,0,2,273,308,287,0,2,273,307,308,0,2,273,306,307,0,2,309,287,308,0,2,274,306,273,0,2,274,305,306,0,2,310,287,309,0,2,310,286,287,0,2,174,195,167,0,2,274,304,305,0,2,275,304,274,0,2,311,286,310,0,2,275,303,304,0,2,174,194,195,0,2,312,286,311,0,2,276,303,275,0,2,276,302,303,0,2,174,193,194,0,2,313,286,312,0,2,277,302,276,0,2,277,301,302,0,2,314,286,313,0,2,174,255,193,0,2,255,192,193,0,2,277,300,301,0,2,254,255,174,0,2,256,192,255,0,2,278,300,277,0,2,257,192,256,0,2,174,253,254,0,2,315,286,314,0,2,258,192,257,0,2,174,252,253,0,2,278,299,300,0,2,259,192,258,0,2,174,251,252,0,2,259,191,192,0,2,293,286,315,0,2,279,299,278,0,2,260,191,259,0,2,174,250,251,0,2,293,285,286,0,2,279,298,299,0,2,294,285,293,0,2,174,249,250,0,2,175,237,174,0,2,237,249,174,0,2,279,297,298,0,2,280,297,279,0,2,295,285,294,0,2,280,296,297,0,2,296,285,295,0,2,280,285,296,0,2,261,262,260,0,2,262,191,260,0,2,175,236,237,0,2,238,249,237,0,2,239,249,238,0,2,240,249,239,0,2,241,249,240,0,2,242,249,241,0,2,243,249,242,0,2,244,249,243,0,2,245,249,244,0,2,246,249,245,0,2,247,249,246,0,2,248,249,247,0,2,176,236,175,0,2,263,191,262,0,2,176,235,236,0,2,264,191,263,0,2,176,234,235,0,2,265,191,264,0,2,176,233,234,0,2,266,191,265,0,2,176,220,233,0,2,196,191,266,0,2,196,190,191,0,2,176,219,220,0,2,177,219,176,0,2,177,218,219,0,2,197,190,196,0,2,281,285,280,0,2,177,217,218,0,2,198,190,197,0,2,281,284,285,0,2,177,216,217,0,2,199,190,198,0,2,282,284,281,0,2,177,215,216,0,2,200,190,199,0,2,282,283,284,0,2,201,190,200,0,2,201,189,190,0,2,177,214,215,0,2,177,213,214,0,2,203,201,202,0,2,203,189,201,0,2,178,213,177,0,2,178,212,213,0,2,204,189,203,0,2,178,211,212,0,2,205,189,204,0,2,179,211,178,0,2,179,210,211,0,2,206,189,205,0,2,179,209,210,0,2,207,189,206,0,2,208,189,207,0,2,179,208,209,0,2,179,189,208,0,2,180,189,179,0,2,181,189,180,0,2,182,189,181,0,2,183,189,182,0,2,183,188,189,0,2,183,187,188,0,2,184,187,183,0,2,184,186,187,0,2,185,186,184,0,2,95,262,261,0,2,118,287,286,0,2,5,173,172,0,2,78,245,244,0,2,45,213,212,0,2,151,323,322,0,2,97,263,262,0,2,22,191,190,0,2,152,324,323,0,2,114,283,282,0,2,79,246,245,0,2,46,214,213,0,2,37,205,204,0,2,36,204,203,0,2,80,247,246,0,2,115,284,283,0,2,161,334,333,0,2,47,215,214,0,2,42,210,209,0,2,52,219,218,0,2,28,196,266,0,2,124,294,293,0,2,51,218,217,0,2,100,266,265,0,2,81,248,247,0,2,112,281,280,0,2,27,167,195,0,2,118,288,287,0,2,109,277,276,0,2,121,291,290,0,2,89,256,255,0,2,119,289,288,0,2,2,170,169,0,2,53,220,219,0,2,5,174,173,0,2,113,282,281,0,2,40,208,207,0,2,41,209,208,0,2,4,172,171,0,2,127,297,296,0,2,125,295,294,0,2,163,336,335,0,2,111,280,279,0,2,93,260,259,0,2,126,296,295,0,2,18,187,186,0,2,19,188,187,0,2,83,250,249,0,2,88,255,254,0,2,164,337,336,0,2,92,259,258,0,2,166,316,338,0,2,110,278,277,0,2,157,330,329,0,2,0,168,167,0,2,21,189,188,0,2,35,203,202,0,2,6,175,174,0,2,123,293,315,0,2,165,338,337,0,2,50,217,216,0,2,120,290,289,0,2,86,253,252,0,2,133,304,303,0,2,122,292,291,0,2,30,198,197,0,2,29,197,196,0,2,34,202,201,0,2,1,169,168,0,2,87,254,253,0,2,3,171,170,0,2,49,216,215,0,2,67,234,233,0,2,32,200,199,0,2,14,183,182,0,2,76,243,242,0,2,26,195,194,0,2,106,272,271,0,2,148,320,319,0,2,143,314,313,0,2,105,271,270,0,2,25,194,193,0,2,31,199,198,0,2,8,177,176,0,2,68,235,234,0,2,77,244,243,0,2,131,302,301,0,2,145,317,316,0,2,85,252,251,0,2,90,257,256,0,2,108,276,275,0,2,69,236,235,0,2,107,275,274,0,2,159,332,331,0,2,72,239,238,0,2,74,241,240,0,2,9,178,177,0,2,7,176,175,0,2,150,322,321,0,2,75,242,241,0,2,155,328,327,0,2,106,273,272,0,2,132,303,302,0,2,155,327,326,0,2,158,331,330,0,2,84,251,250,0,2,13,182,181,0,2,156,329,328,0,2,136,307,306,0,2,162,335,334,0,2,111,279,278,0,2,107,274,273,0,2,134,305,304,0,2,122,267,292,0,2,11,180,179,0,2,24,193,192,0,2,142,313,312,0,2,144,315,314,0,2,146,318,317,0,2,140,311,310,0,2,73,240,239,0,2,128,299,298,0,2,66,233,220,0,2,147,319,318,0,2,102,268,267,0,2,98,264,263,0,2,70,237,236,0,2,154,326,325,0,2,10,179,178,0,2,16,185,184,0,2,139,310,309,0,2,117,286,285,0,2,103,269,268,0,2,138,309,308,0,2,12,181,180,0,2,44,212,211,0,2,130,301,300,0,2,104,270,269,0,2,38,206,205,0,2,71,238,237,0,2,43,211,210,0,2,141,312,311,0,2,129,300,299,0,2,23,192,191,0,2,137,308,307,0,2,153,325,324,0,2,39,207,206,0,2,33,201,200,0,2,99,265,264,0,2,94,261,260,0,2,149,321,320,0,2,91,258,257,0,2,160,333,332,0,2,135,306,305,0,2,15,184,183,0,2,128,298,297,0,2,22,190,189,0,2,82,249,248,0,2,17,186,185,0,2,116,285,284,0,2,152,153,324,0,2,95,96,262,0,2,96,97,262,0,2,114,115,283,0,2,78,79,245,0,2,135,136,306,0,2,97,98,263,0,2,118,119,288,0,2,22,23,191,0,2,79,80,246,0,2,119,120,289,0,2,113,114,282,0,2,112,113,281,0,2,46,47,214,0,2,37,38,205,0,2,105,106,271,0,2,36,37,204,0,2,80,81,247,0,2,47,48,215,0,2,42,43,210,0,2,52,53,219,0,2,51,52,218,0,2,100,28,266,0,2,81,82,248,0,2,27,0,167,0,2,109,110,277,0,2,125,126,295,0,2,93,94,260,0,2,2,3,170,0,2,5,6,174,0,2,40,41,208,0,2,4,5,172,0,2,41,42,209,0,2,163,164,336,0,2,111,112,280,0,2,89,90,256,0,2,18,19,187,0,2,19,20,188,0,2,120,121,290,0,2,123,124,293,0,2,127,128,297,0,2,83,84,250,0,2,88,89,255,0,2,164,165,337,0,2,28,29,196,0,2,92,93,259,0,2,166,145,316,0,2,110,111,278,0,2,157,158,330,0,2,0,1,168,0,2,126,127,296,0,2,124,125,294,0,2,35,36,203,0,2,6,7,175,0,2,20,21,188,0,2,121,122,291,0,2,165,166,338,0,2,50,51,217,0,2,86,87,253,0,2,133,134,304,0,2,30,31,198,0,2,29,30,197,0,2,34,35,202,0,2,1,2,169,0,2,87,88,254,0,2,3,4,171,0,2,49,50,216,0,2,67,68,234,0,2,32,33,200,0,2,14,15,183,0,2,76,77,243,0,2,26,27,195,0,2,148,149,320,0,2,143,144,314,0,2,104,105,270,0,2,25,26,194,0,2,31,32,199,0,2,8,9,177,0,2,68,69,235,0,2,77,78,244,0,2,131,132,302,0,2,145,146,317,0,2,85,86,252,0,2,90,91,257,0,2,108,109,276,0,2,69,70,236,0,2,107,108,275,0,2,159,160,332,0,2,72,73,239,0,2,74,75,241,0,2,9,10,178,0,2,7,8,176,0,2,75,76,242,0,2,155,156,328,0,2,106,107,273,0,2,132,133,303,0,2,158,159,331,0,2,84,85,251,0,2,13,14,182,0,2,156,157,329,0,2,53,66,220,0,2,162,163,335,0,2,154,155,326,0,2,134,135,305,0,2,122,101,267,0,2,150,151,322,0,2,11,12,180,0,2,24,25,193,0,2,45,46,213,0,2,142,143,313,0,2,144,123,315,0,2,146,147,318,0,2,140,141,311,0,2,116,117,285,0,2,73,74,240,0,2,128,129,299,0,2,66,67,233,0,2,147,148,319,0,2,101,102,267,0,2,98,99,264,0,2,70,71,237,0,2,136,137,307,0,2,48,49,215,0,2,10,11,179,0,2,16,17,185,0,2,103,104,269,0,2,117,118,286,0,2,138,139,309,0,2,12,13,181,0,2,44,45,212,0,2,130,131,301,0,2,38,39,206,0,2,102,103,268,0,2,71,72,238,0,2,43,44,211,0,2,141,142,312,0,2,129,130,300,0,2,153,154,325,0,2,23,24,192,0,2,139,140,310,0,2,39,40,207,0,2,161,162,334,0,2,33,34,201,0,2,99,100,265,0,2,94,95,261,0,2,137,138,308,0,2,149,150,321,0,2,91,92,258,0,2,160,161,333,0,2,115,116,284,0,2,15,16,184,0,2,151,152,323,0,2,21,22,189,0,2,82,83,249,0,2,17,18,186,0], 11 | "vertices":[0.215407,-2.11508e-09,-0.0483874,0.161695,-4.43847e-09,-0.10154,0.147759,-4.73332e-09,-0.108286,0.134695,-4.83712e-09,-0.110661,0.121479,-4.79381e-09,-0.10967,0.103551,-4.48931e-09,-0.102703,0.00278674,-1.26232e-10,-0.00288786,-0.03785,1.64968e-09,0.0377402,-0.058155,2.53705e-09,0.058041,-0.0973791,4.25774e-09,0.0974058,-0.104411,4.7404e-09,0.108448,-0.108465,5.296e-09,0.121158,-0.109158,5.87425e-09,0.134387,-0.106484,6.44309e-09,0.147401,-0.0993236,7.04928e-09,0.161269,-0.0453799,9.4258e-09,0.215637,-0.0296655,9.76739e-09,0.223452,-0.0166019,9.87119e-09,0.225827,-0.003386,9.82788e-09,0.224836,0.0092488,9.63769e-09,0.220485,0.0196495,9.33582e-09,0.213579,0.0793564,6.73138e-09,0.153996,0.145461,3.84246e-09,0.0879053,0.217335,6.90115e-10,0.015788,0.224869,1.97838e-11,0.0004526,0.22723,-5.52178e-10,-0.0126324,0.226244,-1.13042e-09,-0.0258609,0.221918,-1.68237e-09,-0.0384881,0.120889,2.41044e-09,0.0551444,0.120486,2.70729e-09,0.0619356,0.118661,2.92807e-09,0.0669864,0.11564,3.11857e-09,0.0713445,0.111627,3.26952e-09,0.0747978,0.106834,3.37185e-09,0.0771389,0.101762,3.41616e-09,0.0781527,0.0797528,3.41639e-09,0.078158,0.0795348,4.47183e-09,0.102303,0.0775019,4.72679e-09,0.108136,0.0744813,4.91729e-09,0.112495,0.0704688,5.06824e-09,0.115948,0.0656753,5.17057e-09,0.118289,0.0588213,5.22023e-09,0.119425,0.0522206,5.16371e-09,0.118132,0.0474886,5.05673e-09,0.115684,0.0435557,4.90191e-09,0.112143,0.0399709,4.6512e-09,0.106407,0.0385994,4.37825e-09,0.100163,0.0385941,3.41639e-09,0.078158,0.0157878,3.41198e-09,0.0780571,0.0110619,3.36498e-09,0.0769818,0.00632994,3.258e-09,0.0745345,0.002397,3.10318e-09,0.0709926,-0.000526169,2.9096e-09,0.0665639,-0.00254128,2.62255e-09,0.059997,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00256456,2.51703e-09,0.057583,-0.00213912,2.32677e-09,0.0532304,-0.000313682,2.106e-09,0.0481796,0.00270697,1.9155e-09,0.0438215,0.00671948,1.76455e-09,0.0403682,0.0129109,1.64075e-09,0.037536,0.0180148,1.61767e-09,0.037008,0.0182887,1.61767e-09,0.037008,0.0190628,1.61767e-09,0.037008,0.0202657,1.61767e-09,0.037008,0.0218258,1.61767e-09,0.037008,0.0236717,1.61767e-09,0.037008,0.0257321,1.61767e-09,0.037008,0.0279353,1.61767e-09,0.037008,0.03021,1.61767e-09,0.037008,0.0324846,1.61767e-09,0.037008,0.0346879,1.61767e-09,0.037008,0.0367482,1.61767e-09,0.037008,0.0385941,1.61767e-09,0.037008,0.0388121,5.62242e-10,0.0128626,0.040845,3.07273e-10,0.00702958,0.0438657,1.16774e-10,0.00267147,0.0478781,-3.4175e-11,-0.000781832,0.0526717,-1.36506e-10,-0.0031229,0.0595257,-1.86164e-10,-0.00425893,0.0661264,-1.29639e-10,-0.00296579,0.0708583,-2.2662e-11,-0.000518446,0.0747913,1.32157e-10,0.0030234,0.0783761,3.82865e-10,0.00875893,0.0797476,6.55818e-10,0.0150034,0.0797528,1.61767e-09,0.037008,0.102664,1.62165e-09,0.0370991,0.107285,1.66626e-09,0.0381195,0.112016,1.77208e-09,0.0405405,0.115949,1.92666e-09,0.0440769,0.118872,2.12095e-09,0.0485217,0.0166043,-1.07436e-08,-0.245784,0.00636778,-1.10255e-08,-0.252233,-0.00628571,-1.12018e-08,-0.256267,-0.0194551,-1.12319e-08,-0.256957,-0.0324106,-1.11156e-08,-0.254296,-0.047317,-1.07734e-08,-0.246468,-0.245558,-2.10948e-09,-0.0482593,-0.25327,-1.43091e-09,-0.0327353,-0.255634,-8.62682e-10,-0.0197359,-0.254647,-2.8784e-10,-0.00658501,-0.247713,4.9195e-10,0.0112545,-0.192081,2.96078e-09,0.0677347,-0.17644,3.30077e-09,0.0755128,-0.163438,3.40409e-09,0.0778765,-0.150284,3.36098e-09,0.0768902,-0.137709,3.17168e-09,0.0725596,-0.127078,2.86196e-09,0.0654741,0.0692483,-5.72012e-09,-0.130861,0.0769801,-6.40017e-09,-0.146419,0.0793443,-6.9684e-09,-0.159418,0.0783577,-7.54325e-09,-0.172569,0.071423,-8.32304e-09,-0.190409,-0.127854,3.91829e-10,0.00896401,-0.138037,7.8761e-10,0.0180184,-0.147731,9.87733e-10,0.0225967,-0.158108,1.07072e-09,0.0244953,-0.168603,1.03609e-09,0.023703,-0.181304,8.27971e-10,0.0189418,-0.191597,4.40112e-10,0.0100686,-0.197501,4.03198e-11,0.00092241,-0.200743,-4.02302e-10,-0.00920361,-0.201296,-8.62344e-10,-0.0197281,-0.199158,-1.31448e-09,-0.0300718,-0.194339,-1.73356e-09,-0.0396593,-0.184676,-2.17943e-09,-0.0498594,-0.1728,-2.43678e-09,-0.0557471,-0.162401,-2.5198e-09,-0.0576462,-0.151892,-2.48514e-09,-0.0568533,-0.139198,-2.27685e-09,-0.0520883,-0.128928,-1.8876e-09,-0.0431832,-0.123052,-1.48988e-09,-0.0340845,-0.119811,-1.04825e-09,-0.0239811,-0.119257,-5.89075e-10,-0.0134765,-0.121395,-1.37187e-10,-0.00313847,0.0155362,-5.8704e-09,-0.134299,0.0071101,-5.5558e-09,-0.127102,-0.00260432,-5.35562e-09,-0.122522,-0.0130039,-5.27261e-09,-0.120623,-0.0235129,-5.30727e-09,-0.121416,-0.0362063,-5.51555e-09,-0.126181,-0.04842,-6.00156e-09,-0.1373,-0.0543081,-6.51961e-09,-0.149151,-0.0562071,-6.9731e-09,-0.159526,-0.0554147,-7.43173e-09,-0.170018,-0.0506525,-7.98679e-09,-0.182716,-0.0417775,-8.43661e-09,-0.193007,-0.0326293,-8.69462e-09,-0.19891,-0.0225012,-8.83631e-09,-0.202151,-0.0119743,-8.86051e-09,-0.202705,-0.00162845,-8.76705e-09,-0.200567,0.0104324,-8.48513e-09,-0.194117,0.0194346,-8.03985e-09,-0.18393,0.023997,-7.61605e-09,-0.174235,0.0259011,-7.16248e-09,-0.163858,0.0251261,-6.70383e-09,-0.153366,0.0216665,-6.26492e-09,-0.143325,0.215998,0.0556634,-0.0476627,0.162754,0.0556634,-0.100753,0.148883,0.0556634,-0.107913,0.135867,0.0556634,-0.110586,0.122635,0.0556634,-0.109893,0.109922,0.0556634,-0.10584,0.0996371,0.0556634,-0.0993608,0.0133732,0.0556634,-0.013472,-0.03785,0.0556634,0.0377402,-0.058155,0.0556634,0.058041,-0.0969822,0.0556635,0.0969717,-0.10389,0.0556635,0.10737,-0.108241,0.0556635,0.120002,-0.109233,0.0556635,0.133215,-0.106857,0.0556635,0.146276,-0.100111,0.0556635,0.16021,-0.0459025,0.0556635,0.215127,-0.0307903,0.0556635,0.223079,-0.0177739,0.0556635,0.225752,-0.00454214,0.0556635,0.225059,0.00817111,0.0556635,0.221006,0.019508,0.0556635,0.213763,0.0849231,0.0556635,0.14843,0.155943,0.0556634,0.0774258,0.216783,0.0556635,0.016404,0.224498,0.0556635,0.00157882,0.227156,0.0556635,-0.0114592,0.226467,0.0556635,-0.0247047,0.222437,0.0556635,-0.0374124,0.120887,0.0556635,0.0600029,0.118873,0.0556635,0.066564,0.11595,0.0556635,0.0709926,0.112017,0.0556635,0.0745344,0.107285,0.0556635,0.0769818,0.101964,0.0556635,0.0781518,0.0797528,0.0556634,0.078158,0.0796117,0.0556635,0.101783,0.0777144,0.0556635,0.107714,0.0747913,0.0556635,0.112143,0.0708584,0.0556635,0.115684,0.0661264,0.0556635,0.118132,0.0608137,0.0556635,0.119285,0.0540696,0.0556635,0.11878,0.0478781,0.0556635,0.115948,0.0438657,0.0556635,0.112495,0.040845,0.0556635,0.108136,0.038612,0.0556635,0.101501,0.0385941,0.0556634,0.078158,0.0137451,0.0556635,0.077896,0.00671949,0.0556635,0.0747978,0.00270697,0.0556635,0.0713445,-0.000313681,0.0556635,0.0669864,-0.00213912,0.0556635,0.0619356,-0.00254128,0.0556635,0.0551691,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.00256456,0.0556634,0.057583,-0.000526173,0.0556635,0.0486021,0.00239701,0.0556635,0.0441734,0.00632993,0.0556635,0.0406316,0.0122511,0.0556635,0.0377177,0.0180148,0.0556634,0.037008,0.0182887,0.0556634,0.037008,0.0190628,0.0556634,0.037008,0.0202657,0.0556634,0.037008,0.0218258,0.0556634,0.037008,0.0236717,0.0556634,0.037008,0.0257321,0.0556634,0.037008,0.0279353,0.0556634,0.037008,0.03021,0.0556634,0.037008,0.0324846,0.0556634,0.037008,0.0346879,0.0556634,0.037008,0.0367482,0.0556634,0.037008,0.0385941,0.0556634,0.037008,0.0387352,0.0556635,0.013383,0.0406325,0.0556635,0.00745207,0.0435557,0.0556635,0.00302341,0.0474886,0.0556635,-0.00051844,0.0522206,0.0556635,-0.0029658,0.0575332,0.0556635,-0.00411929,0.0642774,0.0556635,-0.00361405,0.0704688,0.0556635,-0.000781842,0.0744813,0.0556635,0.00267147,0.0775019,0.0556635,0.00702958,0.0797349,0.0556635,0.0136649,0.0797528,0.0556634,0.037008,0.104692,0.0556635,0.0372499,0.111627,0.0556635,0.0402785,0.115639,0.0556635,0.0437245,0.118659,0.0556635,0.0480968,0.120485,0.0556635,0.0531837,0.0150763,0.0556634,-0.24717,0.00127025,0.0556634,-0.254296,-0.0116853,0.0556634,-0.256957,-0.0248547,0.0556634,-0.256267,-0.0375081,0.0556634,-0.252233,-0.0488794,0.0556634,-0.24496,-0.240627,0.0556634,-0.0532982,-0.246902,0.0556634,-0.045869,-0.252899,0.0556635,-0.0338545,-0.25556,0.0556635,-0.0209021,-0.25487,0.0556635,-0.00773557,-0.250835,0.0556635,0.0049155,-0.244385,0.0556635,0.0151497,-0.19447,0.0556635,0.065391,-0.18373,0.0556635,0.0725596,-0.171155,0.0556635,0.0768902,-0.158001,0.0556635,0.0778765,-0.144998,0.0556635,0.0755128,-0.129581,0.0556635,0.0678688,-0.0482632,0.0556634,-0.0132796,0.00527894,0.0556634,-0.0668104,0.071423,0.0556634,-0.133864,0.0783577,0.0556634,-0.151704,0.0793443,0.0556634,-0.164854,0.0769801,0.0556634,-0.177854,0.070265,0.0556634,-0.191722,-0.132876,0.0556635,0.0140819,-0.141906,0.0556635,0.0202242,-0.151951,0.0556635,0.023703,-0.162445,0.0556635,0.0244953,-0.172822,0.0556635,0.0225967,-0.182517,0.0556635,0.0180184,-0.190942,0.0556635,0.0108179,-0.197083,0.0556635,0.00178176,-0.200564,0.0556635,-0.00828317,-0.201356,0.0556635,-0.0187962,-0.199456,0.0556635,-0.0291781,-0.194876,0.0556635,-0.0388531,-0.187638,0.0556634,-0.0472651,-0.178638,0.0556634,-0.0533739,-0.168571,0.0556634,-0.0568538,-0.155587,0.0556634,-0.0575811,-0.142709,0.0556634,-0.0537905,-0.131614,0.0556634,-0.0462715,-0.123469,0.0556635,-0.0349423,-0.11999,0.0556635,-0.0248997,-0.119197,0.0556635,-0.0144073,-0.121096,0.0556635,-0.00403272,-0.125676,0.0556635,0.00566008,0.0161906,0.0556634,-0.135048,0.00792058,0.0556634,-0.127638,-0.00170808,0.0556634,-0.12282,-0.0120713,0.0556634,-0.120683,-0.0225937,0.0556634,-0.121237,-0.0326954,0.0556634,-0.124479,-0.0437905,0.0556634,-0.131998,-0.0519351,0.0556634,-0.143327,-0.0554147,0.0556634,-0.15337,-0.0562071,0.0556634,-0.163862,-0.0543081,0.0556634,-0.174237,-0.0497289,0.0556634,-0.18393,-0.042527,0.0556634,-0.192352,-0.0334888,0.0556634,-0.198492,-0.0234219,0.0556634,-0.201972,-0.0129065,0.0556634,-0.202765,-0.00252234,0.0556634,-0.200865,0.00715487,0.0556634,-0.196286,0.0172564,0.0556634,-0.187251,0.0236994,0.0556634,-0.175129,0.0258405,0.0556634,-0.164789,0.0253033,0.0556634,-0.154284,0.0220823,0.0556634,-0.144182], 12 | "materials":[{ 13 | "opacity":1, 14 | "wireframe":false, 15 | "visible":true, 16 | "transparent":false, 17 | "depthWrite":true, 18 | "doubleSided":false, 19 | "blending":1, 20 | "colorSpecular":[0.5,0.5,0.5], 21 | "DbgColor":15658734, 22 | "specularCoef":50, 23 | "DbgName":"indienova-red", 24 | "colorDiffuse":[0.8,0.056313,0.0347153], 25 | "depthTest":true, 26 | "shading":"phong", 27 | "colorEmissive":[0,0,0], 28 | "DbgIndex":0 29 | }] 30 | } -------------------------------------------------------------------------------- /project.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "项目配置文件。", 3 | "setting": { 4 | "urlCheck": false, 5 | "es6": true, 6 | "postcss": true, 7 | "minified": true, 8 | "newFeature": true 9 | }, 10 | "compileType": "game", 11 | "libVersion": "game", 12 | "appid": "touristappid", 13 | "projectname": "ModelDemo_push", 14 | "isGameTourist": true, 15 | "condition": { 16 | "search": { 17 | "current": -1, 18 | "list": [] 19 | }, 20 | "conversation": { 21 | "current": -1, 22 | "list": [] 23 | }, 24 | "game": { 25 | "currentL": -1, 26 | "list": [] 27 | }, 28 | "miniprogram": { 29 | "current": -1, 30 | "list": [] 31 | } 32 | } 33 | } --------------------------------------------------------------------------------