Hello Babylonjs

Babylonjs真的很酷!

初始视角问题

找了好久,不知道怎么设定初始的观测角度,感觉就是调整camera的参数。仔细读了好几遍,原来就是通过。
https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction#arc-rotate-camera

const camera = new ArcRotateCamera(
  'camera',
  0,
  Math.PI / 3,
  20,
  new Vector3(0, 0, 0)
);
//camera.setPosition(new Vector3(0, 20, 20));

alpha设为0beta设为Math.PI/3,即180度的1/3,即60度。注意!如果调用了setPosition方法,将会覆盖原有的alphabeta值。

坐标系问题

babylonjs的坐标系是左手系,即Z轴是从屏幕外指向屏幕里。
GroundMesh默认是XZ平面,需要将GroundMesh沿X轴逆时针翻转90度。

const ground = MeshBuilder.CreateGround('ground', {
  width: 5,
  height: 5,
});
ground.rotation.x = -Math.PI / 2;

光源问题

使用DirectionalLight,光是从光源位置,即position位置指向direction位置。

const light = new DirectionalLight('dLight', new Vector3(0, 0, 10));
light.position = new Vector3(0, 0, -10);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值