0
点赞
收藏
分享

微信扫一扫

typescript全局注入THREE


将THREE注入global
​​​src/global.d.ts​

/*
* @Author: hongbin
* @Date: 2022-10-21 08:49:42
* @LastEditors: hongbin
* @LastEditTime: 2022-10-21 10:30:58
* @Description:全局类型 需要
*/

declare let THREE;

declare var Hong;

declare type ignore = any;

interface Window {
THREE: typeof THREE;
render: (v?: number) => void;
renderer: THREE.WebGLRenderer;
gui: GUI;
//鼠标滚轮事件
onmousewheel: ((e: { wheelDelta: number }) => void) | null;

}
//鼠标滚轮事件
interface Document {
onmousewheel: ((e: { wheelDelta: number }) => void) | null;
}

初始化全局变量

/*
* @Author: hongbin
* @Date: 2022-10-21 09:33:54
* @LastEditors: hongbin
* @LastEditTime: 2022-10-21 10:28:12
* @Description:初始化全局变量
*/
import * as THREE from "three";

export const initGlobalVariable = () => {
window.THREE = THREE;
};

初始化

import { initGlobalVariable } from "./GlobalVariable";
initGlobalVariable();

就可以 全局调用 THREE 对象


举报

相关推荐

0 条评论