maptalks / maptalks/maptalks.three

请问 如何得到点击模型位置的高度呢?

Open
#646 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
HTML
Stars
650
Forks
138
PR merge metrics
No merged PRs in 30d

Description

function addGltf() {
clock = new THREE.Clock();
stats = new Stats();
map.getContainer().appendChild(stats.dom);
var loader = new THREE.GLTFLoader();
loader.load('./data/alien.gltf', function (gltf) {

model = gltf.scene;
model.rotation.x = Math.PI / 2;
model.scale.set(100, 100, 100);

baseObjectModel = threeLayer.toModel(model, { coordinate: map.getCenter() });
// model.position.copy(threeLayer.coordinateToVector3(map.getCenter()));
threeLayer.addMesh(baseObjectModel);
baseObjectModel.on('mousemove', e => {

//这里能否在e 得到 点击位置的高程值???
const target = e.target;
const intersect = target.intersect;
//do some things
if (intersect && intersect.object && intersect.object.material) {
intersect.object.material.color.set('red');
}
})

// createGUI(model, gltf.animations);
animate();

}, undefined, function (e) {

console.error(e);

});
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the addGltf function and the baseObjectModel mousemove handler shown in the issue; inspect e.target.intersect and the threeLayer/GLTFLoader integration. Verify whether the intersection data exposes the requested elevation and identify the supported API or example needed. Done means documenting a reproducible way to obtain the clicked model position's height.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, three.js
Domain
computer-graphics
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.