![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
Threejs
工作中使用threejs遇到的问题。
IkeShy_Zz
要在一年内学会OpenGl。
展开
-
threejs 将屏幕坐标转换成3d中的坐标。
threejs 将屏幕坐标转换成3d中的坐标。原创 2021-04-12 11:32:05 · 3207 阅读 · 3 评论 -
Threejs 通过 THREE.Box3 实现碰撞检测
根据官方文档:https://threejs.org/docs/#api/en/math/Box3.intersectsSphereClass 1: 我需要操作的物体protected init () { // 创建一个正方体 let geometry = new THREE.BoxGeometry(0.1, 0.025, 0.05, 1, 1, 1); let material = new THREE.MeshPhongMaterial( { color: 0x000000, tran.原创 2021-02-09 18:46:47 · 5135 阅读 · 0 评论 -
如何从TypeScript项目调用没有@types的JavaScript库
项目用需要用到碰撞检测,找到一个Threejs的物理引擎库 APE但是它是JavaScript版本,没有提供@types ,而我的项目是TypeScript的,在index.html 中 加入<script type="text/javascript" src="/static/APE.Rigid.min.js"></script>后在代码中调用APE 显示未定义。 这时 可以 加入declare const APE: any;这将告诉编译器变量APE存在,并且...原创 2021-02-09 11:57:26 · 754 阅读 · 0 评论 -
Threejs 通过 Raycaster 进行物体碰撞检测
参考:http://www.wukai.me/2015/12/28/threejs-collision/1:创建Raycaster, 设置摄像机。this.rayCaster = new THREE.Raycaster();this.rayCaster.camera = camera;2:this.spaceShip 是玩家操作的类,我创建了一个专门用于检测碰撞的THREE.BoxGeometrythis.stoneList 是 需要被检测碰撞的物体 从屏幕里向外飞出...原创 2021-02-03 11:57:08 · 1797 阅读 · 1 评论 -
Threejs 通过摄像机检测物体是否超过屏幕边界
private isAllowMove (pos: THREE.Vector3) { let flag = true; let position = pos; let tempV = position.applyMatrix4(this.camera.matrixWorldInverse).applyMatrix4(this.camera.projectionMatrix); if ((Math.abs(tempV.x) > 1) || (Math.abs(temp.原创 2021-02-03 11:45:55 · 1060 阅读 · 0 评论