Skip to content

Commit

Permalink
picking-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoji Chen committed Oct 2, 2019
1 parent fd34fbc commit fde02f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 101 deletions.
23 changes: 15 additions & 8 deletions modules/core/src/components/log-viewer/core-3d-viewer.js
Expand Up @@ -225,6 +225,7 @@ export default class Core3DViewer extends PureComponent {
.scale(scale),
mesh,
data: CAR_DATA,
pickable: true,
getPosition: d => d,
getColor: color,
texture,
Expand All @@ -240,7 +241,6 @@ export default class Core3DViewer extends PureComponent {
const {
frame,
streamsMetadata,
showTooltip,
objectStates,
customLayers,
getTransformMatrix,
Expand Down Expand Up @@ -282,7 +282,7 @@ export default class Core3DViewer extends PureComponent {
id: `xviz-${streamName}`,
...coordinateProps,

pickable: showTooltip || primitives[0].id,
pickable: true,

data: primitives,
style: stylesheet,
Expand Down Expand Up @@ -344,12 +344,21 @@ export default class Core3DViewer extends PureComponent {
);
}

_layerFilter({layer, viewport, isPicking}) {
if (viewport.id === 'driver') {
return layer.id !== 'car';
_layerFilter = ({layer, viewport, isPicking}) => {
if (viewport.id === 'driver' && layer.id === 'car') {
return false;
}
if (isPicking) {
if (this.props.showTooltip) {
return true;
}
if (layer.id.startsWith('xviz-')) {
const sampleData = layer.props.data[0];
return sampleData && sampleData.id;
}
}
return true;
}
};

_getCursor = () => {
return this.isHovering ? 'pointer' : 'crosshair';
Expand All @@ -375,7 +384,6 @@ export default class Core3DViewer extends PureComponent {
car,
streamsMetadata,
streamFilter,
showTooltip,
objectStates,
renderObjectLabel,
customLayers,
Expand All @@ -393,7 +401,6 @@ export default class Core3DViewer extends PureComponent {
car,
streamsMetadata,
streamFilter,
showTooltip,
objectStates,
customLayers,
getTransformMatrix,
Expand Down
12 changes: 11 additions & 1 deletion modules/core/src/components/log-viewer/hover-tooltip.js
Expand Up @@ -57,14 +57,24 @@ class HoverTooltip extends PureComponent {
}

_renderContent = info => {
const {streamName} = info.layer.props;

if (!streamName) {
return (
<div>
<b>{info.layer.id}</b>
</div>
);
}

const objectId = info.object.base && info.object.base.object_id;

return [
<div key="-stream-">
<div>
<b>stream</b>
</div>
{info.layer.props.streamName}
{streamName}
</div>,
objectId ? (
<div key="-id-">
Expand Down
93 changes: 1 addition & 92 deletions test/apps/webpack.config.local.js
@@ -1,92 +1 @@
// Copyright (c) 2019 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// This file contains webpack configuration settings that allow
// examples to be built against the deck.gl source code in this repo instead
// of building against their installed version of deck.gl.
//
// This enables using the examples to debug the main deck.gl library source
// without publishing or npm linking, with conveniences such hot reloading etc.

// avoid destructuring for older Node version support
const {resolve} = require('path');

const ALIASES = require('ocular-dev-tools/config/ocular.config')({
root: resolve(__dirname, '../..')
}).aliases;

// Support for hot reloading changes to the deck.gl library:
function makeLocalDevConfig() {
return {
mode: 'development',

// suppress warnings about bundle size
devServer: {
stats: {
warnings: false
}
},

devtool: 'source-map',

resolve: {
alias: ALIASES
},
module: {
rules: [
{
// Unfortunately, webpack doesn't import library sourcemaps on its own...
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre'
}
]
}
};
}

function addLocalDevSettings(config, exampleDir) {
const LOCAL_DEV_CONFIG = makeLocalDevConfig(exampleDir);
config = Object.assign({}, LOCAL_DEV_CONFIG, config);
config.resolve = Object.assign({}, LOCAL_DEV_CONFIG.resolve, config.resolve || {});
config.resolve.alias = config.resolve.alias || {};
Object.assign(config.resolve.alias, LOCAL_DEV_CONFIG.resolve.alias);

config.module = config.module || {};
Object.assign(config.module, {
rules: (config.module.rules || []).concat(LOCAL_DEV_CONFIG.module.rules)
});
return config;
}

module.exports = (config, exampleDir) => env => {
// npm run start-local now transpiles the lib
if (env && env.local) {
config = addLocalDevSettings(config, exampleDir);
}

// npm run start-es6 does not transpile the lib
if (env && env.es6) {
config = addLocalDevSettings(config, exampleDir);
}

// console.warn(JSON.stringify(config, null, 2)); // uncomment to debug config
return config;
};
module.exports = require('../../examples/webpack.config.local');

0 comments on commit fde02f9

Please sign in to comment.