feat: 在核心模块移除 threejs 的引用

This commit is contained in:
2912401452 2021-09-27 16:15:54 +08:00
parent 1b87bacf11
commit 4df80d0577
4 changed files with 11 additions and 22 deletions

View File

@ -1,7 +1,6 @@
// @ts-ignore
import { SyncBailHook, SyncHook, SyncWaterfallHook } from '@antv/async-hook';
import { Container } from 'inversify';
import { AnimationMixer, Matrix4, Object3D } from 'three';
import Clock from '../../utils/clock';
import { ISceneConfig } from '../config/IConfigService';
import { IMapService } from '../map/IMapService';
@ -235,35 +234,35 @@ export interface ILayer {
altitude: number,
rotation: [number, number, number],
scale: [number, number, number],
): Matrix4;
): any;
// 获取对应地图的经纬度平移矩阵
getTranslateMatrix?(lnglat: ILngLat, altitude?: number): Matrix4;
getTranslateMatrix?(lnglat: ILngLat, altitude?: number): any;
// 设置模型对应地图在经纬度和高度方向的平移
applyObjectLngLat?(
object: Object3D,
object: any,
lnglat: ILngLat,
altitude?: number,
): void;
// 根据经纬度设置模型对应地图的平移
setObjectLngLat?(object: Object3D, lnglat: ILngLat, altitude?: number): void;
setObjectLngLat?(object: any, lnglat: ILngLat, altitude?: number): void;
// 返回物体在场景中的经纬度
getObjectLngLat?(object: Object3D): ILngLat;
getObjectLngLat?(object: any): ILngLat;
// 将经纬度转为 three 世界坐标
lnglatToCoord?(lnglat: ILngLat): ILngLat;
// 设置网格适配到地图坐标系
adjustMeshToMap?(object: Object3D): void;
adjustMeshToMap?(object: any): void;
// 设置网格的缩放 (主要是抹平 mapbox 底图时的差异,若是高德底图则可以直接设置网格的 scale 属性/方法)
setMeshScale?(object: Object3D, x: number, y: number, z: number): void;
setMeshScale?(object: any, x: number, y: number, z: number): void;
// 增加加载模型的动画混合器
addAnimateMixer?(mixer: AnimationMixer): void;
addAnimateMixer?(mixer: any): void;
/**
*

View File

@ -1,13 +1,4 @@
import { Scene } from '@antv/l7-scene';
import {
AnimationMixer,
Camera,
Matrix4,
PCFSoftShadowMap,
PerspectiveCamera,
Scene as ThreeScene,
WebGLRenderer,
} from 'three';
import {
IThreeRenderService,
ThreeRenderService,

View File

@ -1,5 +1,4 @@
import { Object3D } from 'three';
import ThreeLayer from './core/baseLayer';
// import { IThreeJSLayer } from './core/IThreeJSLayer';
import ThreeRender from './core/threeRender';
export { ThreeLayer, ThreeRender, Object3D };
export { ThreeLayer, ThreeRender };

View File

@ -1,7 +1,7 @@
// @ts-ignore
import { Scene } from '@antv/l7';
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
import { ThreeLayer, ThreeRender, Object3D } from '@antv/l7-three';
import { ThreeLayer, ThreeRender } from '@antv/l7-three';
import * as React from 'react';
// import { DirectionalLight, Scene as ThreeScene } from 'three';
import * as THREE from 'three';
@ -57,7 +57,7 @@ export default class GlTFThreeJSDemo extends React.Component {
'https://gw.alipayobjects.com/os/bmw-prod/3ca0a546-92d8-4ba0-a89c-017c218d5bea.gltf',
(gltf) => {
// @ts-ignore
const model: Object3D = gltf.scene;
const model = gltf.scene;
layer.getSource().data.dataArray.forEach(({ coordinates }) => {
layer.adjustMeshToMap(model);