three.js 微信小游戏
最近在 https://classroom.udacity.com/courses/cs291 学习了一些 3D 引擎和 three.js 的知识
把 three.js 弄到微信小游戏里,先随便跑一跑
最终效果:

代码结构如下:

(先忽略 audio 和 images, 这里先不用)
game.js 代码
import './js/libs/weapp-adapter'
import './js/libs/symbol'
import * as THREE from './js/engine/three.min'
let scene = new THREE.Scene()
let camera = new THREE.PerspectiveCamera(45, canvas.width/canvas.height, 1, 1000)
camera.position.z = 16
camera.lookAt(scene.position)
let renderer = new THREE.WebGLRenderer({ context: canvas.getContext('webgl') }) // { canvas: canvas }
renderer.setSize(canvas.width, canvas.height)
// renderer.setClearColor(new THREE.Color(0xAAAAAA))
let spotLight = new THREE.SpotLight(0xffffff)
spotLight.position.set(10, 10, 10)
scene.add(spotLight)
let geo = new THREE.BoxGeometry(4, 4, 4);
let material = new THREE.MeshPhongMaterial({ shininess: 40, color: 0xad0000, specular: 0x808080 });
let cube = new THREE.Mesh(geo, material);
scene.add(cube);
function loop()
{
requestAnimationFrame(loop)
cube.rotation.x += 0.1
cube.rotation.y += 0.1
// cube.rotation.z += 0.1
renderer.render(scene, camera)
}
function start()
{
let fps = 60
wx.setPreferredFramesPerSecond(fps)
requestAnimationFrame(loop)
}
start()
three.js 微信小游戏的更多相关文章
- pixi.js 微信小游戏 入手
pixi是什么?一款h5游戏引擎 优点:简单简洁性能第一 缺点:大多数用的国产三大引擎,pixi资料少,工具少, 为什么学,装逼 用pixi开发小游戏行吗? 行.但要简单处理下 下载官网上的 weap ...
- 微信小游戏 demo 飞机大战 代码分析(四)(enemy.js, bullet.js, index.js)
微信小游戏 demo 飞机大战 代码分析(四)(enemy.js, bullet.js, index.js) 微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞 ...
- 微信小游戏 demo 飞机大战 代码分析 (三)(spirit.js, animation.js)
微信小游戏 demo 飞机大战 代码分析(三)(spirit.js, animation.js) 微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞机大战 代码 ...
- 微信小游戏 demo 飞机大战 代码分析 (二)(databus.js)
微信小游戏 demo 飞机大战 代码分析(二)(databus.js) 微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞机大战 代码分析(三)(spirit. ...
- 微信小游戏 demo 飞机大战 代码分析 (一)(game.js, main.js)
微信小游戏 demo 飞机大战 代码分析(一)(main.js) 微信小游戏 demo 飞机大战 代码分析(二)(databus.js) 微信小游戏 demo 飞机大战 代码分析(三)(spirit. ...
- 【转】利用 three.js 开发微信小游戏的尝试
前言 这是一次利用 three.js 开发微信小游戏的尝试,并不能算作是教程,只能算是一篇笔记吧. 微信 WeChat 6.6.1 开始引入了微信小游戏,初期上线了一批质量相当不错的小游戏.我在查阅各 ...
- 微信小游戏开发之四:使用three.js引擎
一.前言 微信小游戏中最魔性的'跳一跳'就是基于three.js 引擎开发的 源码放到github上了:GitHub地址 请自行下载. 二.下载 three.min.js 打开页面,复制代码到本地 ...
- 微信小游戏的本地缓存和清除的使用 (text.js image.js file-util.js)
参考: 微信小游戏,文件系统 UpdateManager-小游戏 一.Egret提供的本地缓存工具类( 备注:新版本进行了修改,并增加了sound.js等) 在微信小游戏项目中,Egret提供了fil ...
- 微信小游戏 Three.js UI 2D text 简单方案
在微信小游戏中使用 THREE.js 引擎,没有合适的 UI 库可用,只能自己动手.图片啥的都还好,text 不好弄.text 要计算 width 和 height,不然事件响应范围不对. funct ...
随机推荐
- Springboot 热部署问题。亲测可用。
本人开发使用的是Mac系统,windows应该类似.主要是 spring-boot-devtools的使用 参考:mac下的idea设置,是不是有疑问,既然别人写好了,为啥你还要再来一次,因为我使用了 ...
- php 处理上百万条的数据库如何提高处理查询速度
1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...
- 【原】The Linux Command Line - Workiing with commands
● type – Indicate how a command name is interpreted● which – Display which executable program will b ...
- Linux下NFS的搭建与配置
一.简介 1.NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布. 2.NFS可实现Linux系统之间的文件 ...
- Django_Form验证(二),ajax验证
还是一个简单的html提交页面,ajax提交就不需要form表单了: <p><input id="a" type="text" name=&q ...
- linux下配置redis4.0.2主从复制以及高可用
一.环境 三台服务器分别为: 172.28.18.75/172.28.18.103/172.28.18.104 在三台服务器上分别部署一个redis节点以及一个sentinel节点 二.主从复制配置 ...
- cdnbest如何在站点里开启强制缓存
在站点设置中如下图设置: 强制缓存有两种方式,一种是文件类型,一种是url方式
- 在网站中使用UEditor富文本编辑器
UEditor是由百度WEB前端研发部开发的所见即所得的开源富文本编辑器,具有轻量.可定制.用户体验优秀等特点. 官网链接 进入到下载页面,选择相应的版本下载 这里我们使用ASP.NET开发,所以选择 ...
- FortiGate路由模式--静态地址线路上网配置
1.需求:外网接口使用专线,由运营商分配指定的静态地址,内网为192.168.1.0/24网段,实现基本上网功能. 运营商分配ip地址:202.1.1.10,网关地址:202.1.1.9, DNS:2 ...
- 373. Find K Pairs with Smallest Sums 找出求和和最小的k组数
[抄题]: You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. D ...