Git Product home page Git Product logo

xplanet's Introduction

X-Planet

苍蝇有复眼,狗狗是色盲,鹰眼堪比高倍镜……在这一颗蓝色星球上,你可曾想过,其他物种看到的世界会是如何不同?

在X-Planet中,玩家可以操控多种动态角色,并以此为第一视角在星球上自由探索。

Demo

探索指南

角色切换: 数字键 1 2 3 ...

前进、后退: WASD/上下左右

跳跃:空格键

视线:鼠标

功能实现

场景搭建

使用React + Three.js搭建三维场景,对场景元素(lights, planet, hero等)进行模块化拆分,理解ref和虚拟dom渲染并构造组件(Scene)

第一人称控件

使用射线检测(Raycaster)模拟重力制作第一人称控件(playerControls)。进入游戏界面后Pointer Lock API锁定指针,通过键盘鼠标事件模拟角色在球体表面移动、跳跃、视线变化,并绑定相机继承该父节点位置和朝向

星球地形

构造buffergeometry,使用柏林噪声(perlin noise / Three.js中称为ImprovedNoise)生成随机地形,以数组材质方式赋以同一几何体多种材质。

搭建树木模型并在星球上随机分布。

角色动画

实现人类、兔子、小鱼等多种角色模型及相应effectComposer,并用Tween.js添加动画效果

兼容性监测

在页面初始状态下进行WebGL兼容性判断,若不兼容则弹窗提示

xplanet's People

Contributors

jujiex avatar

Stargazers

 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.