|
@@ -38,11 +38,11 @@ export default class App {
|
|
|
this.bindEvents()
|
|
|
setTimeout(() => this.bindSocketEvents(), 1000)
|
|
|
|
|
|
- document.getElementById("enterBtn").onclick = () => {
|
|
|
- document.getElementById("houseTexture").play();
|
|
|
- document.getElementById("houseTextureReverse").play();
|
|
|
- document.getElementById("mask").style.zIndex = "-10000"
|
|
|
- }
|
|
|
+ // document.getElementById("enterBtn").onclick = () => {
|
|
|
+ // document.getElementById("houseTexture").play();
|
|
|
+ // document.getElementById("houseTextureReverse").play();
|
|
|
+ // document.getElementById("mask").style.zIndex = "-10000"
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
init() {
|
|
@@ -127,72 +127,72 @@ export default class App {
|
|
|
|
|
|
bindEvents() {
|
|
|
|
|
|
- let ray = new BABYLON.Ray(new BABYLON.Vector3(0,0,0), new BABYLON.Vector3(0,0,1), 50);
|
|
|
-
|
|
|
- document.getElementById("renderCanvas").addEventListener("click", (pointerInfo) => {
|
|
|
- if(this.mouseMoving) return
|
|
|
- // console.error("click")
|
|
|
- let pickPoint = this.screenToWorld({x: pointerInfo.x, y: pointerInfo.y})
|
|
|
- ray.origin = pickPoint
|
|
|
- ray.direction = BABYLON.Vector3.Normalize( this.cameraController.camera.position.clone().subtract(pickPoint) )
|
|
|
- let pickInfo = ray.intersectsMeshes(this.house)[0];
|
|
|
- if(pickInfo.hit && this.house.indexOf(pickInfo.pickedMesh)) {
|
|
|
- this.charactorManager.clickHouse()
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- document.getElementById("renderCanvas").addEventListener("pointerdown", (pointerInfo) => {
|
|
|
- console.error("down")
|
|
|
- this.cameraController.startMouseRotate({event: pointerInfo})
|
|
|
- this.mouseMoving = false
|
|
|
- })
|
|
|
-
|
|
|
- document.getElementById("renderCanvas").addEventListener("pointerup", (pointerInfo) => {
|
|
|
- this.cameraController.endMouseRotate()
|
|
|
- // console.error("up")
|
|
|
- })
|
|
|
-
|
|
|
- document.getElementById("renderCanvas").addEventListener("pointermove", (pointerInfo) => {
|
|
|
- if(this.cameraController.lastFramePoint) {
|
|
|
- // console.error("move")
|
|
|
- this.cameraController.mouseRotating({event: pointerInfo})
|
|
|
- this.mouseMoving = true
|
|
|
- }
|
|
|
- })
|
|
|
+ // let ray = new BABYLON.Ray(new BABYLON.Vector3(0,0,0), new BABYLON.Vector3(0,0,1), 50);
|
|
|
+
|
|
|
+ // document.getElementById("renderCanvas").addEventListener("click", (pointerInfo) => {
|
|
|
+ // if(this.mouseMoving) return
|
|
|
+ // // console.error("click")
|
|
|
+ // let pickPoint = this.screenToWorld({x: pointerInfo.x, y: pointerInfo.y})
|
|
|
+ // ray.origin = pickPoint
|
|
|
+ // ray.direction = BABYLON.Vector3.Normalize( this.cameraController.camera.position.clone().subtract(pickPoint) )
|
|
|
+ // let pickInfo = ray.intersectsMeshes(this.house)[0];
|
|
|
+ // if(pickInfo.hit && this.house.indexOf(pickInfo.pickedMesh)) {
|
|
|
+ // this.charactorManager.clickHouse()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+
|
|
|
+ // document.getElementById("renderCanvas").addEventListener("pointerdown", (pointerInfo) => {
|
|
|
+ // console.error("down")
|
|
|
+ // this.cameraController.startMouseRotate({event: pointerInfo})
|
|
|
+ // this.mouseMoving = false
|
|
|
+ // })
|
|
|
+
|
|
|
+ // document.getElementById("renderCanvas").addEventListener("pointerup", (pointerInfo) => {
|
|
|
+ // this.cameraController.endMouseRotate()
|
|
|
+ // // console.error("up")
|
|
|
+ // })
|
|
|
+
|
|
|
+ // document.getElementById("renderCanvas").addEventListener("pointermove", (pointerInfo) => {
|
|
|
+ // if(this.cameraController.lastFramePoint) {
|
|
|
+ // // console.error("move")
|
|
|
+ // this.cameraController.mouseRotating({event: pointerInfo})
|
|
|
+ // this.mouseMoving = true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
|
|
|
- // this.scene.onPointerObservable.add((pointerInfo) => {
|
|
|
+ this.scene.onPointerObservable.add((pointerInfo) => {
|
|
|
|
|
|
- // switch (pointerInfo.type) {
|
|
|
- // case BABYLON.PointerEventTypes.POINTERDOWN:
|
|
|
- // this.cameraController.startMouseRotate(pointerInfo)
|
|
|
- // break;
|
|
|
+ switch (pointerInfo.type) {
|
|
|
+ case BABYLON.PointerEventTypes.POINTERDOWN:
|
|
|
+ this.cameraController.startMouseRotate(pointerInfo)
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERUP:
|
|
|
- // this.cameraController.endMouseRotate()
|
|
|
- // break;
|
|
|
+ case BABYLON.PointerEventTypes.POINTERUP:
|
|
|
+ this.cameraController.endMouseRotate()
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERMOVE:
|
|
|
- // if(this.cameraController.lastFramePoint)
|
|
|
- // this.cameraController.mouseRotating(pointerInfo)
|
|
|
- // break;
|
|
|
+ case BABYLON.PointerEventTypes.POINTERMOVE:
|
|
|
+ if(this.cameraController.lastFramePoint)
|
|
|
+ this.cameraController.mouseRotating(pointerInfo)
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERWHEEL:
|
|
|
- // break;
|
|
|
+ case BABYLON.PointerEventTypes.POINTERWHEEL:
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERPICK:
|
|
|
- // break;
|
|
|
+ case BABYLON.PointerEventTypes.POINTERPICK:
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERTAP:
|
|
|
- // if(pointerInfo.pickInfo.hit && this.house.indexOf(pointerInfo.pickInfo.pickedMesh)) {
|
|
|
- // this.charactorManager.clickHouse()
|
|
|
- // }
|
|
|
- // break;
|
|
|
+ case BABYLON.PointerEventTypes.POINTERTAP:
|
|
|
+ if(pointerInfo.pickInfo.hit && this.house.indexOf(pointerInfo.pickInfo.pickedMesh)) {
|
|
|
+ this.charactorManager.clickHouse()
|
|
|
+ }
|
|
|
+ break;
|
|
|
|
|
|
- // case BABYLON.PointerEventTypes.POINTERDOUBLETAP:
|
|
|
- // break;
|
|
|
- // }
|
|
|
+ case BABYLON.PointerEventTypes.POINTERDOUBLETAP:
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- // });
|
|
|
+ });
|
|
|
|
|
|
this.scene.onBeforeAnimationsObservable.add(() => {
|
|
|
|