Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L7集成threejs,onAddMeshs方法中提供的scene.add()添加three中Line2类型线失败 #2031

Open
wang-yuandong opened this issue Nov 9, 2023 · 5 comments
Assignees
Labels

Comments

@wang-yuandong
Copy link

wang-yuandong commented Nov 9, 2023

问题描述

L7集成threejs,ThreeLayer的onAddMeshs方法中提供的scene.add()添加three中Line2类型线失败,并报错
image

重现链接

https://codesandbox.io/p/sandbox/cranky-mcclintock-z4ps9z?file=%2Fsrc%2Fcomponents%2FTestLine.vue%3A1%2C1

重现步骤

预期行为

TestL7Line文件和TestLine文件引用同一个ccreateLineWithLine2方法,L7地图中线未出现,期望出现一条自地图中心119高度至左下方的线(由于世界坐标为0,0,0,所以另一端点较远,未在屏幕展示,可参考createLineWithLineBasic方法)

平台

  • 操作系统: macOS
  • 网页浏览器: Google Chrome 119.0.6045.105
  • threejs: 0.115.0
  • @antv/l7: ^2.19.6
  • @antv/l7-three: ^2.19.6

屏幕截图或视频(可选)

threejs:
image

L7 with threejs:
image

补充说明(可选)

No response

Copy link
Contributor

github-actions bot commented Nov 9, 2023

Hi @wang-yuandong, Please star this repo if you find it useful! Thanks ⭐!
你好 @wang-yuandong。如果该仓库对你有用,可以 star 一下,感谢你的 ⭐!

Copy link
Contributor

github-actions bot commented Nov 9, 2023

hi @wang-yuandong, welcome!

@zhnny
Copy link
Contributor

zhnny commented Dec 11, 2023

Three.js中的Line2对象在L7的绘制中存在问题,下图中的红色线条和蓝色圆形物体(分别是Line对象和Line2对象),其实Positions是相同的
image

const geometry = new LineGeometry();
geometry.setPositions(positions);
const matLine = new LineMaterial({
    color: 0x0000ff,
    linewidth: 0.1,
});
const line = new Line2(geometry, matLine);
line.computeLineDistances();
line.scale.set(1, 1, 1);
layer.setObjectLngLat(line, [center.lng + 0.01, center.lat], 0);
threeScene.add(line);

// THREE.Line ( THREE.BufferGeometry, THREE.LineBasicMaterial ) - rendered with gl.LINE_STRIP
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3));
const matLineBasic = new THREE.LineBasicMaterial({
    color: 0xff0000,
    linewidth: 6
});
const line1 = new THREE.Line(geo, matLineBasic);
line1.computeLineDistances();
layer.setObjectLngLat(line1, [center.lng + 0.01, center.lat], 0);
threeScene.add(line1);

@lzxue
Copy link
Contributor

lzxue commented Mar 19, 2024

问题描述

L7集成threejs,ThreeLayer的onAddMeshs方法中提供的scene.add()添加three中Line2类型线失败,并报错 image

重现链接

https://codesandbox.io/p/sandbox/cranky-mcclintock-z4ps9z?file=%2Fsrc%2Fcomponents%2FTestLine.vue%3A1%2C1

重现步骤

预期行为

TestL7Line文件和TestLine文件引用同一个ccreateLineWithLine2方法,L7地图中线未出现,期望出现一条自地图中心119高度至左下方的线(由于世界坐标为0,0,0,所以另一端点较远,未在屏幕展示,可参考createLineWithLineBasic方法)

平台

  • 操作系统: macOS
  • 网页浏览器: Google Chrome 119.0.6045.105
  • threejs: 0.115.0
  • @antv/l7: ^2.19.6
  • @antv/l7-three: ^2.19.6

屏幕截图或视频(可选)

threejs: image

L7 with threejs: image

补充说明(可选)

No response
https://l7.antv.antgroup.com/examples/engine/three/#basic_geometry 参照这个案例看看

@lzxue
Copy link
Contributor

lzxue commented Mar 19, 2024

Three.js中的Line2对象在L7的绘制中存在问题,下图中的红色线条和蓝色圆形物体(分别是Line对象和Line2对象),其实Positions是相同的 image

const geometry = new LineGeometry();
geometry.setPositions(positions);
const matLine = new LineMaterial({
    color: 0x0000ff,
    linewidth: 0.1,
});
const line = new Line2(geometry, matLine);
line.computeLineDistances();
line.scale.set(1, 1, 1);
layer.setObjectLngLat(line, [center.lng + 0.01, center.lat], 0);
threeScene.add(line);

// THREE.Line ( THREE.BufferGeometry, THREE.LineBasicMaterial ) - rendered with gl.LINE_STRIP
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3));
const matLineBasic = new THREE.LineBasicMaterial({
    color: 0xff0000,
    linewidth: 6
});
const line1 = new THREE.Line(geo, matLineBasic);
line1.computeLineDistances();
layer.setObjectLngLat(line1, [center.lng + 0.01, center.lat], 0);
threeScene.add(line1);

应该是 LineGeometry 和 BufferGeometry 有区别一个是标注,一个是顶点坐标

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants