本文整理汇总了TypeScript中THREE.Scene.setRotationFromEuler方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Scene.setRotationFromEuler方法的具体用法?TypeScript Scene.setRotationFromEuler怎么用?TypeScript Scene.setRotationFromEuler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Scene
的用法示例。
在下文中一共展示了Scene.setRotationFromEuler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: animate
function animate(time: number) {
animationId = requestAnimationFrame(animate);
if (previousTime != null) {
const elapsedTime = time - previousTime;
accumulatedTime = Math.min(accumulatedTime + elapsedTime, maxAccumulatedTime);
}
previousTime = time;
const ticks = Math.floor(accumulatedTime / clientTickDuration);
accumulatedTime -= ticks * clientTickDuration;
if (pub != null && pub.match == null) {
sceneAngleY += Math.PI / 640;
} else {
if (Math.abs(sceneAngleY) > 0.1) sceneAngleY = lerp(sceneAngleY, 0, 0.15);
else sceneAngleY = 0;
}
if (sceneAngleY > Math.PI) sceneAngleY -= Math.PI * 2;
scene.setRotationFromEuler(tmpEuler.set(0, sceneAngleY, 0));
let width = canvas.parentElement.clientWidth;
let height = canvas.parentElement.clientHeight;
if (width > height * 4 / 3) width = height * 4 / 3;
if (height > width * 3 / 4) height = width * 3 / 4;
canvas.width = width;
canvas.height = height;
camera.updateProjectionMatrix();
threeRenderer.setSize(canvas.width, canvas.height, false);
threeRenderer.render(scene, camera);
input.gather();
if (input.hasJustPressedLeftTrigger) { socket.emit("throwBall"); }
for (const playerId in modelsById) {
const model = modelsById[playerId];
const { avatar } = players.byId[playerId];
const hasBall = pub.ball.playerId === playerId;
model.nametag.setRotationFromEuler(tmpEuler.set(0, -sceneAngleY, 0));
if (playerId === myPlayerId) {
for (let i = 0; i < ticks; i++) input.predict(pub.match != null, pub.ball.playerId === myPlayerId, ballThrownTimer > 0);
model.root.position.set(input.prediction.x, 0, input.prediction.z);
model.body.setRotationFromEuler(tmpEuler.set(0, -input.prediction.angleY, 0));
model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, input.prediction.catching || hasBall ? input.prediction.angleX : -Math.PI * 0.4));
} else {
// TODO: Lerp between previous and current!
model.root.position.set(avatar.x, 0, avatar.z);
model.body.setRotationFromEuler(tmpEuler.set(0, -avatar.angleY, 0));
model.shoulders.setRotationFromEuler(tmpEuler.set(0, 0, avatar.catching || hasBall ? avatar.angleX : -Math.PI * 0.4));
}
model.root.position.y = shared.getAvatarY(avatar.jump);
}
if (pub != null && pub.ball.playerId == null) {
ballModel.position.set(pub.ball.x, pub.ball.y, pub.ball.z);
ballMarker.position.set(pub.ball.x, 0.01, pub.ball.z);
}
}