ES6中导出类
import * as THREE from '../libs/three.js'
window.THREE=THREE
import game from './game/game.js'
class Main {
constructor(){
}
static init(){ //使用static
game.init()
}
}
export default Main //直接导出Main
// 入口
import './libs/weapp-adapter.js'
import Main from './src/main.js'
Main.init() //直接使用
export camera from './camera'
export scene from './scene'
import {scene} from '../scene/index' //通过export导出的,需要用import加{}导入,export default则不需要
bindTouchEvent(){
canvas.addEventListener('touchstart',this.touchStartCallback)
canvas.addEventListener('touchend',this.touchEndCallback)
}
removeTouchEvent(){
canvas.removeEventListener('touchstart',this.touchStartCallback)
canvas.removeEventListener('touchend',this.touchEndCallback)
}
touchStartCallback = (e) => {
console.log('touch start callback')
this.bottle.rotate()
}
touchEndCallback = (e) => {
console.log('touch end callback')
}
绑定点击屏幕事件后需要用这种函数形式,才能调用到bottle下的rotate函数