From 4df80d057702cc2fd1a608183896f6669929e744 Mon Sep 17 00:00:00 2001 From: 2912401452 <2912401452@qq.com> Date: Mon, 27 Sep 2021 16:15:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E6=A0=B8=E5=BF=83=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=A7=BB=E9=99=A4=20threejs=20=E7=9A=84=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/src/services/layer/ILayerService.ts | 17 ++++++++--------- packages/three/src/core/threeRender.ts | 9 --------- packages/three/src/index.ts | 3 +-- stories/3D_Model/Components/amap2_three.tsx | 4 ++-- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/core/src/services/layer/ILayerService.ts b/packages/core/src/services/layer/ILayerService.ts index 9784312ba1..3c0cb2ade3 100644 --- a/packages/core/src/services/layer/ILayerService.ts +++ b/packages/core/src/services/layer/ILayerService.ts @@ -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; /** * 地球模式相关的方法 diff --git a/packages/three/src/core/threeRender.ts b/packages/three/src/core/threeRender.ts index bf20995350..97ebc6f33d 100644 --- a/packages/three/src/core/threeRender.ts +++ b/packages/three/src/core/threeRender.ts @@ -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, diff --git a/packages/three/src/index.ts b/packages/three/src/index.ts index 706814c559..9bbbcb6a51 100644 --- a/packages/three/src/index.ts +++ b/packages/three/src/index.ts @@ -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 }; diff --git a/stories/3D_Model/Components/amap2_three.tsx b/stories/3D_Model/Components/amap2_three.tsx index acdff94612..a8588b2cde 100644 --- a/stories/3D_Model/Components/amap2_three.tsx +++ b/stories/3D_Model/Components/amap2_three.tsx @@ -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);