0

When I look at Notch's minecraft demo here - I can drag on the viewport with my trackpad and have the perspective shift.

When I look at David Nolen's ClojureScript version of the demo here - this does not occur. (But it is very impressive).

My question is: How is this handling input events? (Is there some special js trick?)

For example - when I look at this code - I see:

document.addEventListener('touchstart', this.onTouch.bind(this), false);
document.addEventListener('touchmove', this.onTouch.bind(this), false);
document.addEventListener('touchend', this.onTouchEnd.bind(this), false);

EDIT: Some have questioned this behaviour and said they can't reproduce it using a mouse. Fair enough - I can't reproduce it with mouse clicks either. I recorded a video of me dragging the viewport using my trackpad.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • 1
    Are you sure? When I click and drag on the viewport nothing happens. The camera just moves in a predefined clockwise oval sort of path—dictated, I think, by the `xRot` and `yRot` values defined at the top of `renderMinecraft`. – Jordan Running Jun 19 '14 at 22:46
  • Thanks @Jordan - that's helpful feedback. I've clarified the question and added a video of the behaviour. I'm keen for your input. – hawkeye Jun 20 '14 at 12:03
  • Oh, I see. You're just scrolling the iframe. I could reproduce it with a two-finger drag on OS X as well as grabbing and moving the scrollbar. If you make the iframe bigger than the canvas it stops working. It works on the ClojureScript version as well if you make the window narrow enough that you can scroll left and right. Looking at the source I'm not sure what's going on, and I don't have enough experience with canvas to know, but it seems like the POV is based on the center of the viewport rather than the center of the canvas. Sorry I can't be more helpful. – Jordan Running Jun 20 '14 at 15:13

0 Answers0