threejs在mapbox中无法展示以及threejs和l7图层展示冲突问题的修复 #2832
Closed
Soundmark
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
通过查看 l7-three 支持 mapbox 底图 #2438 的实现思路,发现和mapbox官方的实现有所差异
mapbox官方实现:
目前l7的实现:
可以发现目前是没有进行旋转和缩放的,我测试如果我将旋转和缩放逻辑加上去,threejs图层就可以正常展示了。但是使用过程中又发现另一个问题,无法设置threejs图层的位置,所有threejs图层都会渲染到地图center的位置,之后我又将l7的实现修改,将threejs图层的旋转缩放偏移交给每一个mesh自己去做,这样就能正常展示以及设置位置
const mercatorMatrix = new Matrix4().fromArray( // @ts-ignore this.mapService.map.transform.customLayerMatrix(), ); - this.camera.projectionMatrix = mercatorMatrix.multiply(this.cameraTransform); + this.camera.projectionMatrix = mercatorMatrix;但是这样做会出现另一个问题,就是在mapbox中是用threejs和其他地图不一样了,想看看是否有更好的处理方式。
这个问题在任何地图都会出现,如果threejs和l7图层都添加进了场景,会只有threejs图层展示,l7图层消失了,经过调试发现是threejs渲染时将gl状态改变了,并且没有恢复,做了一个gl状态缓存处理就可以正常展示
Soundmark@59fad24
Beta Was this translation helpful? Give feedback.
All reactions