在Angular2中使用three.js
发布时间:2020-12-17 17:58:44 所属栏目:安全 来源:网络整理
导读:我试图将three.js场景集成到一个有角度的2页.我是Angular 2和 javascript的初学者,我在script.html中包含了脚本标签中的three.js文件,即在scene.component.ts文件中我有这样的代码… //scene.component.tsimport { Component } from 'angular2/core';import
我试图将three.js场景集成到一个有角度的2页.我是Angular 2和
javascript的初学者,我在script.html中包含了脚本标签中的three.js文件,即在scene.component.ts文件中我有这样的代码…
//scene.component.ts import { Component } from 'angular2/core'; import { THREE } from 'three-js/three'; @Component({ selector: 'ps-scene',templateUrl: 'app/webgl/scene.component.html' }) export class SceneComponent{ scene = new THREE.Scene(); } /////////////// 问题在于显示 – 从’three-js / three’导入{THREE}; 它与’angular2 / core’位于相同的目录路径中 提前致谢. 解决方法
你使用角度cli?
如果是这样,请不要忘记在typings.d文件中添加引用: declare module 'three'; https://github.com/angular/angular-cli#3rd-party-library-installation 3rd Party Library Installation Simply install your library via npm install lib-name --save and import it in your code. If the library does not include typings,you can install them using npm: npm install d3 --save npm install @types/d3 --save-dev If the library doesn't have typings available at @types/,you can still use it by manually adding typings for it: // in src/typings.d.ts declare module 'typeless-package'; // in src/app/app.component.ts import * as typelessPackage from 'typeless-package'; typelessPackage.method(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |