From fde02f977a9b51e9f3a7e59e0c9599fc4e51837f Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Wed, 2 Oct 2019 16:33:39 -0700 Subject: [PATCH] picking-fix --- .../components/log-viewer/core-3d-viewer.js | 23 +++-- .../components/log-viewer/hover-tooltip.js | 12 ++- test/apps/webpack.config.local.js | 93 +------------------ 3 files changed, 27 insertions(+), 101 deletions(-) diff --git a/modules/core/src/components/log-viewer/core-3d-viewer.js b/modules/core/src/components/log-viewer/core-3d-viewer.js index 3ddbcb42..4e804261 100644 --- a/modules/core/src/components/log-viewer/core-3d-viewer.js +++ b/modules/core/src/components/log-viewer/core-3d-viewer.js @@ -225,6 +225,7 @@ export default class Core3DViewer extends PureComponent { .scale(scale), mesh, data: CAR_DATA, + pickable: true, getPosition: d => d, getColor: color, texture, @@ -240,7 +241,6 @@ export default class Core3DViewer extends PureComponent { const { frame, streamsMetadata, - showTooltip, objectStates, customLayers, getTransformMatrix, @@ -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, @@ -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'; @@ -375,7 +384,6 @@ export default class Core3DViewer extends PureComponent { car, streamsMetadata, streamFilter, - showTooltip, objectStates, renderObjectLabel, customLayers, @@ -393,7 +401,6 @@ export default class Core3DViewer extends PureComponent { car, streamsMetadata, streamFilter, - showTooltip, objectStates, customLayers, getTransformMatrix, diff --git a/modules/core/src/components/log-viewer/hover-tooltip.js b/modules/core/src/components/log-viewer/hover-tooltip.js index a13139ce..6e4cc0d9 100644 --- a/modules/core/src/components/log-viewer/hover-tooltip.js +++ b/modules/core/src/components/log-viewer/hover-tooltip.js @@ -57,6 +57,16 @@ class HoverTooltip extends PureComponent { } _renderContent = info => { + const {streamName} = info.layer.props; + + if (!streamName) { + return ( +
+ {info.layer.id} +
+ ); + } + const objectId = info.object.base && info.object.base.object_id; return [ @@ -64,7 +74,7 @@ class HoverTooltip extends PureComponent {
stream
- {info.layer.props.streamName} + {streamName} , objectId ? (
diff --git a/test/apps/webpack.config.local.js b/test/apps/webpack.config.local.js index 459fc6cb..7ad6d9c7 100644 --- a/test/apps/webpack.config.local.js +++ b/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');