forked from michaljaz/webmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerInInventory.coffee
More file actions
48 lines (45 loc) · 1.41 KB
/
PlayerInInventory.coffee
File metadata and controls
48 lines (45 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as THREE from 'three'
class PlayerInInventory
constructor:(game)->
@game=game
@renderer=new THREE.WebGLRenderer {
canvas:@game.pcanvas
PixelRatio:window.devicePixelRatio
}
@scene=new THREE.Scene
@scene.background = new THREE.Color "black"
light = new THREE.AmbientLight( 0xffffff )
@scene.add( light );
player=@game.al.get "player"
playerTex=@game.al.get "playerTex"
playerTex.magFilter=THREE.NearestFilter;
player.children[0].material.map=playerTex;
@scene.add( player )
@camera = new THREE.PerspectiveCamera 70, 140/204, 0.1, 1000
@camera.rotation.order="YXZ"
@camera.position.z = 210
@camera.position.y = 120
$(window).mousemove (z)->
xoff=z.pageX-window.innerWidth/2+112
yoff=z.pageY-window.innerHeight/2+170
left=xoff/(window.innerWidth/2-112)
right=xoff/(window.innerWidth/2+112)
top=yoff/(window.innerHeight/2-170)
bottom=yoff/(window.innerHeight/2+170)
wych_x=Math.PI/3
wych_y=Math.PI/4
if xoff>0
player.rotation.y=wych_x*right
else
player.rotation.y=wych_x*left
if yoff>0
player.children[1].children[0].children[2].children[0].children[0].rotation.x=wych_y*bottom
else
player.children[1].children[0].children[2].children[0].children[0].rotation.x=wych_y*top
render:()->
@renderer.render @scene, @camera
show:()->
@game.pcanvas.style.display="block"
hide:()->
@game.pcanvas.style.display="none"
export {PlayerInInventory}