open in new window

Demos : Real 3D

Code:

<html>
<head>
     <script type="text/javascript" src="http://lib.ivank.net/ivank.js"></script>
     <script type="text/javascript">
          var stage, s;
          
          function Start()
          {
               var request = new XMLHttpRequest();
               request.open("GET", "werewolf.json");
               request.onload = loaded;  request.send();
          }
          function loaded(e) 
          {
               stage = new Stage("c");
               s = new Sprite();  stage.addChild(s); 
               s.x = stage.stageWidth/2; s.y = stage.stageHeight/2; s.z = 1500;
               
               var wolf = new Sprite();  s.addChild(wolf);
               wolf.scaleY = -1; wolf.y = 85;
               
               var m = JSON.parse(e.target.responseText);
               wolf.graphics.beginBitmapFill(new BitmapData("werewolf.jpg"));
               wolf.graphics.drawTriangles3D(m.vertices, m.indices, m.uvt);
               stage.addEventListener(Event.ENTER_FRAME, onEF);
          }
          function onEF(e) { s.rotationY += 0.01*(stage.mouseX - s.x); 
               s.scaleX = s.scaleY = s.scaleZ = 1+stage.mouseY*0.1; }
     </script>
</head>
<body onload="Start();"><canvas id="c"></canvas></body>
</html>