three.js - 在组件内部的Aframe中导入threejs代码
问题描述
我正在尝试使用threejs 代码创建框架组件。如何在a-frame组件中集成threejs模块?请指导我,我正在努力寻找解决方案。我正在尝试将其集成到我的组件中
<script type="module">
AFRAME.registerComponent('navigation-controls', {
init: function(){
let el = this.el;
import * as THREE from 'https://raw.githubusercontent.com/mrdoob/three.js/dev/build/three.module.js'
import { IndoorControls } from 'https://raw.githack.com/wobushijiujiu/three.js/dev/examples/jsm/controls/IndoorControls.js';
// tried this using outside of the component if was not working there also
let scene = document.querySelector("a-scene");
let camera = scene.camera;
let renderer = scene.renderer;
let groundControls = new IndoorControls( camera, renderer.domElement );
console.log(groundControls); //this is showing error - IndoorControls not found
}
});
解决方案
A-Frame 原生包含 Three.js,因此 THREE 对象是全局可用的,无需包含其他任何内容。
推荐阅读
- javascript - 为什么我的数组在发布请求后返回未定义?
- reactjs - 有没有办法将功能代码拆分到另一个文件或组件?
- php - 使用令牌访问 Passport 授权路由
- python - 在树莓派 4 上使用 2 个触摸屏
- typescript - 从库中增加类型声明
- dart - Dart 将字符串转换为数组,然后比较两个数组
- python - Python:如何在抓取时保持登录状态?
- c++ - 为什么我的程序在第一次运行时写入文件,但在以后运行同一程序时却没有?
- c - ISO 'for' 作用域 [-fpermissive] 的“错误] 名称查找 'N' 究竟是什么”?
- c#-4.0 - 如何使用 itextsharp 将两个 pdfPtable 数据放在不同的页面中?