Changes between Version 3 and Version 4 of threejs


Ignore:
Timestamp:
Oct 12, 2013, 11:13:08 PM (7 years ago)
Author:
Leon Kos
Comment:

dodaj JS izpis

Legend:

Unmodified
Added
Removed
Modified
  • threejs

    v3 v4  
    11
    2 == Threejs model ==
     2== Osnovni three.js model ==
     3Naslednji primer je [http://threejs.org/docs/#Manual/Introduction/Creating_a_scene osnovni primer scene]
     4predelan za canvas, ki ni celozaslonski ampak le del okna.
     5
    36{{{
    47#!html
     
    3336</canvas>
    3437}}}
     38
     39{{{
     40#!javascript
     41<script src="https://rawgithub.com/mrdoob/three.js/master/build/three.min.js"></script>
     42<script type="text/javascript">
     43function initScene()
     44  {
     45  var scene = new THREE.Scene();
     46  var canvas = document.getElementById("myCanvas");
     47  var camera = new THREE.PerspectiveCamera(75, canvas.offsetWidth/canvas.offsetHeight, 0.1, 1000);
     48  var renderer = new THREE.WebGLRenderer({canvas: canvas});
     49  renderer.setSize(canvas.offsetWidth, canvas.offsetHeight);
     50  var geometry = new THREE.CubeGeometry(2,2,2);
     51  var material = new THREE.MeshBasicMaterial({color: 0xfa0a0a});
     52  var cube = new THREE.Mesh(geometry, material);
     53  scene.add(cube); camera.position.z = 5;
     54  var render = function () {
     55       requestAnimationFrame(render);
     56       cube.rotation.x += 0.01;
     57       cube.rotation.y += 0.01;
     58       renderer.render(scene, camera);
     59  };
     60  render();
     61
     62
     63window.onload = window.onresize = function() {
     64     initScene();
     65}
     66</script>
     67<canvas id="myCanvas" width="400" height="300" style="background: lightgrey; float:right;">
     68  Your browser does not support the HTML5 canvas tag.
     69</canvas>
     70}}}