js也能写3D游戏?

js也能写3D游戏?看完这本书《3DGameProgramingforKids》之后,发现3D游戏的学习,也可以使用javascript来写的。先要上这个网站https://threejs.org,然后下载它的three.js源码放到一个目录,比如js。然后放入这段代码: Myfirstthree.jsapp body{margin:0;} canvas{w

大家好,又见面了,我是你们的朋友全栈君。

看完这本《3D Game Programing for Kids》之后,发现3D游戏的学习,也可以使用javascript来写的。

先要上这个网站https://threejs.org,然后下载它的three.js源码放到一个目录,比如js。

然后放入这段代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset=utf-8>
		<title>My first three.js app</title>
		<style>
			body { margin: 0; }
			canvas { width: 100%; height: 100% }
		</style>
	</head>
	<body>
		<script src="js/three.js"></script>
		<script>
			var scene = new THREE.Scene();
			var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );

			var renderer = new THREE.WebGLRenderer();
			renderer.setSize( window.innerWidth, window.innerHeight );
			document.body.appendChild( renderer.domElement );

			var geometry = new THREE.BoxGeometry( 1, 1, 1 );
			var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
			var cube = new THREE.Mesh( geometry, material );
			scene.add( cube );

			camera.position.z = 5;

			var animate = function () {
				requestAnimationFrame( animate );

				cube.rotation.x += 0.1;
				cube.rotation.y += 0.1;

				renderer.render(scene, camera);
			};

			animate();
		</script>
	</body>
</html>

保存之后,再使用CHROME浏览器打开,就可以看到下面的画面:

js也能写3D游戏?



Python游戏开发入门

你也能动手修改C编译器

纸牌游戏开发

http://edu.csdn.net/course/detail/5538 

五子棋游戏开发

http://edu.csdn.net/course/detail/5487
RPG游戏从入门到精通
http://edu.csdn.net/course/detail/5246
WiX安装工具的使用
http://edu.csdn.net/course/detail/5207
俄罗斯方块游戏开发
http://edu.csdn.net/course/detail/5110
boost库入门基础
http://edu.csdn.net/course/detail/5029
Arduino入门基础
http://edu.csdn.net/course/detail/4931
Unity5.x游戏基础入门
http://edu.csdn.net/course/detail/4810
TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
C++标准模板库从入门到精通 
http://edu.csdn.net/course/detail/3324
跟老菜鸟学C++
http://edu.csdn.net/course/detail/2901
跟老菜鸟学python
http://edu.csdn.net/course/detail/2592
在VC2015里学会使用tinyxml库
http://edu.csdn.net/course/detail/2590
在Windows下SVN的版本管理与实战 
http://edu.csdn.net/course/detail/2579
Visual Studio 2015开发C++程序的基本使用 
http://edu.csdn.net/course/detail/2570
在VC2015里使用protobuf协议
http://edu.csdn.net/course/detail/2582
在VC2015里学会使用MySQL数据库
http://edu.csdn.net/course/detail/2672

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141384.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Waiting for another flutter command to release the startup lock…

    Waiting for another flutter command to release the startup lock…

    2021年10月1日
    40
  • python多线程tomorrow的使用

    python多线程tomorrow的使用安装pipinstalltomorrow使用:在需要多线程执行的方法上打上注解@threads(2)即可@threads(5)defmethod_001(i):print(i)if__name__==’__main__’:foriinrange(0,100):method_001(i)报错:async关键字冲突,这是python3才会报的错。解决:修改方法名…

    2025年5月23日
    0
  • soft thresholding and hard thresholding

    soft thresholding and hard thresholding今天在看MichaelElad大牛的论文《OntheRoleofSparseandRedundantRepresentationsinImageProcessing》中,看到了softthresholding和hardthresholding这两个概念,很是不明白,所以上网查了一些资料,先把网上查的东西贴出来讨论下。网上资料大体是说这是指两类的函数,分别

    2022年6月8日
    56
  • 用原子操作实现无锁编程[通俗易懂]

    用原子操作实现无锁编程[通俗易懂]假设我们要维护一个全局的线程安全的int类型变量count,下面这两行代码都是很危险的:count++;count+=n;我们知道,高级语言中的一条语句,并不是一个原子操作.比如一个最简单的自增操作就分为三步: 1.从缓存取到寄存器2.在寄存器加13.存入缓存。多个线程访问同一块内存时,需要加锁来保证访问操作是互斥的. 所以,我

    2022年5月27日
    44
  • Linux系统-tcpdump常用抓包命令

    Linux系统-tcpdump常用抓包命令linux,tcpdump

    2022年5月21日
    53
  • log4cpp深度封装[通俗易懂]

    log4cpp深度封装[通俗易懂]简介关于log4cpp的介绍与好处就不再赘言了,百度一搜一大把。主要是对于log4cpp的使用如果不封装一下,感觉还是挺麻烦的,例如不少函数名挺长的。所以自己动手把它的日常使用进行了封装,可以让使用log4cpp就像调用一句printf()函数一样简单快捷。封装目标不需要用一次就调用一次getInstance,只需要在main文件中引入一次即可封装成需要使用时只需简短的一举logError(“s

    2022年7月13日
    11

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号