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

Fix raycasting issue #740

Merged
merged 3 commits into from
Oct 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions emperor/support_files/js/sceneplotview3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ define([
// if a decomposition uses a parallel plot,
// update the default raycasting tolerance as
// it is otherwise too large and error-prone
var scope = this;
var updateRaycasterLinePrecision = function(evt) {
if (scope.UIState.getProperty('view.viewType') === 'parallel-plot')
scope._raycaster.linePrecision = 0.01;
Expand Down Expand Up @@ -927,38 +926,29 @@ define([

// Get first intersected item and call callback with it.
if (intersects && intersects.length > 0) {
var intersect, isPointCloud = intersects[0].object.isPoints;

// filter out things that are not visible
if (isPointCloud) {
var cloud = intersects[0].object;

intersects = _.filter(intersects, function(marker) {
return cloud.geometry.attributes.visible.getX(marker.index) &&
cloud.geometry.attributes.opacity.getX(marker.index);
});
}
else {
intersects = _.filter(intersects, function(match) {
return marker.visible && marker.opacity;
});
}

var firstObj = intersects[0].object;
var firstObj = intersects[0].object, intersect;
/*
* When the intersect object is a Points object, the raycasting method
* won't intersect individual mesh objects. Instead it intersects a point
* and we get the index of the point. This index can then be used to
* trace the original Plottable object.
*/
if (firstObj.isPoints || firstObj.isLineSegments) {
// don't search over invisible things
intersects = _.filter(intersects, function(marker) {
return firstObj.geometry.attributes.visible.getX(marker.index) &&
firstObj.geometry.attributes.opacity.getX(marker.index);
});

var meshIndex = intersects[0].index;
var modelIndex = this.decViews.scatter.getModelPointIndex(meshIndex,
this.UIState['view.viewType']);

intersect = this.decViews.scatter.decomp.plottable[modelIndex];
}
else {
intersects = _.filter(intersects, function(marker) {
return marker.object.visible && marker.object.material.opacity;
});
intersect = intersects[0].object;
}

Expand Down