Home > front end >  Beginners. THREE JS plane map, can't run, o great god the way
Beginners. THREE JS plane map, can't run, o great god the way

Time:11-30

Code is
 




01.01 Basic skeleton< Example;/title> <br/><meta charset="utf-8"/& gt; <br/><The script type="text/javascript" charset="utf-8" SRC="https://bbs.csdn.net/libs/three/three.js" & gt; </script> <br/><The script type="text/javascript" charset="utf-8" SRC="https://bbs.csdn.net/libs/three/controls/TrackballControls.js" & gt; </script> <br/><The script type="text/javascript" SRC="https://bbs.csdn.net/src/chapter-01/test.js" & gt; </script> <br/><link rel="stylesheet" href="https://bbs.csdn.net/css/default.css" & gt; <br/></head> <br/><br/><body> <br/><! - Div which will hold the Output - & gt; <br/><Div id="webgl - output" & gt; </div> <br/><br/><! - the Javascript code that runs our Three. Js examples - & gt; <br/><br/></body> <br/><br/></html> <br/></pre> <br/><br/><pre> <br/>The function the init () {<br/>Var stats=initStats (); <br/><br/>//create a scene, that will hold all our elements to the as objects, cameras and towns. <br/>Var scene=new THREE. Scene (); <br/><br/>//create a camera, which defines the where we 'r e & ats. <br/>Var camera=new THREE. PerspectiveCamera (45, window. InnerWidth/window. InnerHeight, 0.1, 1000); <br/><br/>//create a render and set the size <br/>Var the renderer=new THREE. WebGLRenderer (); <br/><br/>The renderer. SetClearColor (new THREE Color (0 x000000)); <br/>The renderer. SetSize (window. InnerWidth window. The innerHeight); <br/>The renderer. ShadowMap. Enabled=true; <br/><br/>//show axes in the screen <br/>Var axes=new THREE. AxesHelper (20); <br/>Scene. The add (axes); <br/>Var planeGeometry=new THREE. PlaneGeometry (50, 10, 1, 1); <br/>//image loader <br/>Var ImageLoader=new THREE. ImageLoader (); <br/>//callback function load method, according to the image path, return the elements of an HTML img object <br/>ImageLoader. Load ('../SRC/chapter - 01/image/6. PNG ', function (img) {<br/>//image object as a parameter, create a Texture object Texture <br/>Var texture=new THREE. Texture (img); <br/>//the next time you use the texture triggered update <br/>Texture. NeedsUpdate=true; <br/>Var material=new THREE. MeshLambertMaterial ({<br/>The map: texture,//set the texture map <br/>}); <br/>Var mesh=new THREE. Mesh (planeGeometry, material);//Mesh object Mesh <br/>Scene. The add (mesh);//grid model is added to the scenario <br/>}); <br/>} <br/></pre> <br/><br/>Through local access http://localhost:8081/src/chapter-01/test.html after a blank <br/>Don't seem to run </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/89891.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/89891.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/89890.html'>Small white inquired, formData out to background value to none.</a></div> <div class="detail-arr-right">Next:<a href='/frontend/89892.html'>Is there a CSS style besides Dreamweaver any software add panel</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=JavaScript' target='_blank'>JavaScript</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>