猫史档案馆


寻人一起创做地图

用户:恒哥8866恒哥8866查看:0 回复:1 评论:0 创建时间:2024-08-24T16:42:38


寻找代码师*2  建筑师*1   建模师*2   音乐师*2 可以的话来https://dao3.fun/edit/b6ae4f2682e6af0c6fa0?p=125d5024bf9喵87f9806f86e3577ce18申请                                    谢谢!!!  


回复

上一页1 页 / 共 1下一页
code猫的code猫的

<!DOCTYPEh喵l> <h喵llang="en"> <head> <metacharset="UTF-8"> <metaname="viewport"content="width=device-width,initial-scale=1.0"> <title>3D地图示例</title> <style> body{margin:0;} canvas{display:block;} </style> </head> <body> <scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> <script> //创建场景 constscene=newTHREE.Scene(); constcamera=newTHREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,0.1,1000); constrenderer=newTHREE.WebGLRenderer({antialias:true}); renderer.setSize(window.innerWidth,window.innerHeight); document.body.appendChild(renderer.domElement); //创建地面 constgeometry=newTHREE.PlaneGeometry(100,100,32); cons喵aterial=newTHREE.MeshBasicMaterial({color:0x00ff00}); constground=newTHREE.Mesh(geometry,material); ground.rotation.x=-Math.PI/2;//让地面水平 scene.add(ground); //添加一些立方体作为建筑物 functioncreateBuilding(x,z){ constbuildingGeometry=newTHREE.BoxGeometry(1,Math.random()*5+1,1); constbuildingMaterial=newTHREE.MeshBasicMaterial({color:0x0000ff}); constbuilding=newTHREE.Mesh(buildingGeometry,buildingMaterial); building.position.set(x,building.geometry.parameters.height/2,z); scene.add(building); } //创建多个建筑物 for(leti=-40;i<40;i+=5){ for(letj=-40;j<40;j+=5){ createBuilding(i,j); } } //设置相机位置 camera.position.set(0,20,50); camera.lookAt(0,0,0); //渲染场景 functionanimate(){ requestAnimationFrame(animate); renderer.render(scene,camera); } animate(); //处理窗口大小变化 window.addEventListener('resize',()=>{ camera.aspect=window.innerWidth/window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth,window.innerHeight); }); </script> </body> </h喵l>

点赞0


评论