| 562 | |
| 563 | |
| 564 | == Teksture == |
| 565 | Naredimo podlago za naš model tako, da mrežo naredimo kar v JSC3D in nanjo prilepimo teksturo. |
| 566 | Namesto trikotnikov bomo podali kar štirikotnik. Teksturo trave pripnemo na stran. |
| 567 | {{{ |
| 568 | #!javascript |
| 569 | viewer.setParameter('RenderMode', 'texture'); |
| 570 | ///... |
| 571 | pod = new JSC3D.Mesh(); |
| 572 | pod.isDoubleSided = false; w = 1000; h = -50; |
| 573 | pod.vertexBuffer = [-w, -w, h, w, -w, h, w, w, h, -w, w, h]; |
| 574 | pod.indexBuffer = [0, 1, 2, 3, -1]; |
| 575 | pod.texCoordBuffer = [0, 0, 1, 0, 1, 1, 0, 1]; |
| 576 | pod.texCoordIndexBuffer = [0,1,2,3,-1]; |
| 577 | pod.init(); |
| 578 | var tex = new JSC3D.Texture; |
| 579 | tex.onready = function() { |
| 580 | pod.setTexture(this); |
| 581 | viewer.update(); |
| 582 | }; |
| 583 | tex.createFromUrl('/vaje/raw-attachment/wiki/PythonOcc/elbow/Grass_by_jaqx_textures.jpg'); |
| 584 | theScene.addChild(pod); |
| 585 | viewer.update(); |
| 586 | }}} |