0

I'm currently using react, react-map-gl, and three.js. I'd like to render a .obj that I have on top of the react-map-gl.

If the deck.gl code/react-map-gl code is commented out, I currently have my .obj appearing on the screen successfully via: car

and in render():

<div 
    className='component-app'
    data-test='component-app'>
    <DeckGL
      layers={this._renderLayers()}
      controller={controller}
      initialViewState={INITIAL_VIEW_STATE}
      viewState={viewState}
      onViewStateChange={this._onViewStateChange}>
      {baseMap && (
        <StaticMap
          width={width}
          height={height}
          reuseMaps
          mapStyle="mapbox://styles/mapbox/dark-v9"
          preventStyleDiffing={true}
          mapboxApiAccessToken={MAPBOX_TOKEN} />
      )}
    </DeckGL>
    {this._loadObj()}
  </div>

With this, however, my .obj file is always hidden by the map. I'd like to bring it on top of the map. I've tried editing z-index for all these components, to no avail. Would appreciate suggestions.

omnicon
  • 99
  • 3
  • 13

1 Answers1

0

Got it, the answer lied in simply adding an ID to my car canvas and then increasing z-index:

app.js:

renderer.domElement.id = 'object-canvas';

css:

#object-canvas {
  position: absolute;
  z-index: 10;
}
omnicon
  • 99
  • 3
  • 13
  • hi, i am curious about your solution. Can you please help me understand does putting z index of 10 solved the issue? I am trying to figure out if i can take advantage of both three.js and deckgl to take advantage of both world. – Pravin Poudel Aug 17 '23 at 16:19