javascript - 如何在反应中获得带有a-frame的旋转度数
问题描述
我正在使用 A 帧来可视化 VR,并且我正在尝试从相机中获取旋转度数,因为我需要向观众展示视角。我看到了这个命令:
Ent.object3D.rotation.set(
THREE.Math.degToRad(15),
THREE.Math.degToRad(30),
THREE.Math.degToRad(90)
);
Ent.object3D.rotation.x += Math.PI;
Ent.el.getAttribute("rotation")
console.log(THREE)
THREE
但是当我 console.log 它时,反应似乎不可能得到。
我的组件是这样的:
import "aframe";
import { Entity, Scene } from "aframe-react";
import React, { useState, useEffect, useRef } from "react";
import * as THREE from "three";
require("aframe");
require("aframe-video-controls");
const VRphoto = ({ BackgroundVR, config, rotation }) => {
// With three.js
const Ent = useRef(null)
const A = (
<Entity
ref={Ent}
primitive="a-sky"
scale={{ x: -0.9 }}
src={require(`../assets/images/vr/${BackgroundVR}`)}
enabled
camera
look-controls
rotation={rotation}
// rotation="0 0 0"
/>
);
Ent.object3D.rotation.set(
THREE.Math.degToRad(15),
THREE.Math.degToRad(30),
THREE.Math.degToRad(90)
);
Ent.object3D.rotation.x += Math.PI;
Ent.el.getAttribute("rotation")
console.log(THREE)
return (
<Scene loading-screen="dotsColor: #ef2d5e; backgroundColor: #000000;">
{A}
</Scene>
);
};
export default VRphoto;
解决方案
推荐阅读
- python - 如何打印一个单词,但在每个新行之后都会添加一个字母
- java - 我的 Jar 是被双击的,还是从命令行启动的?
- c# - 无法隐式转换类型“Microsoft.AspNetCore.Mvc.BadRequestObjectResult”
- javascript - 导出函数是否会创建函数的单例?
- javascript - 粘性标题和纯 css 视差问题
- ruby-on-rails - 如何为 Ruby 哈希实现分页
- jquery - jQuery:获取对象内对象的成员数
- ios - Firebase iOS com.apple.avfoundation.playerlayer.configuration 崩溃?
- sql-server - 用户登录失败(Microsoft SQL Server,错误:4064)
- apache-spark - 如何使 pyspark DAG 并行运行