[英]How do I create global variables I can use across my modules?
I import scene from file sceneSetup.js
into initFloor1.js
and get error ReferenceError: scene is not defined
Can't find solution of this issue and can't understand if it is the issue of javascript or Threejs我将场景从文件sceneSetup.js
导入initFloor1.js
并得到错误 ReferenceError: scene is not defined
找不到此问题的解决方案,无法理解是 javascript 还是 Threejs 的问题
sceneSetup.js:场景设置.js:
export let camera, controls, renderer, labelRenderer, renderer3D, arrow, label, scene;
initFloor1.js: initFloor1.js:
import * as THREE from 'three';
import { camera, controls, renderer, labelRenderer, renderer3D, arrow, label, scene } from './../sceneSetup.js'
export function initFloor1() {
scene = new THREE.Scene();
My project folder:我的项目文件夹:
|- src
| |- 3d-scene
| |- sceneSetup.js
| |- Floor1
| |- initFloor1.js
Use window.variableName
to declare in central place and then you can access across the site.使用window.variableName
在中心位置声明,然后您可以跨站点访问。
window.camera=null;
window.controls=null;
etc.等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.