deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

[Bug] Failed to set position/rotation for children nodes in SceneGraphLayer

Open skywalkershen opened this issue 3 years ago • 2 comments

Description

I'm trying to set position and rotation for boneNode of a boned gltf model loaded via sceneGraph, but failed for all the nodes except the root one. Even for the root one, it takes a while for the rendered result to update

Flavors

  • [ ] React
  • [ ] Python/Jupyter notebook
  • [ ] MapboxLayer
  • [ ] GoogleMapsOverlay
  • [ ] CartoLayer
  • [ ] DeckLayer/DeckRenderer for ArcGIS

Expected Behavior

The shape of the model should change according to the position/rotation set to its nodes.

Yet I found I can only config sceneLayer.state.scenegraph which is a ScenegraphNode from luma.gl to adjust its position and rotation. Configuring its children which are GroupNode that extends ScenegraphNode, does not change the rendering result.

Steps to Reproduce

The methods setRootRotation and setNodePelvisRotation use same logic, the only difference is the nodes they work with. Yet, the one manipulate root ScenegraphNode works, the other manipulating child GroupNode does not.

const INITIAL_VIEW_STATE = {
  latitude: 37.7749,
  longitude: 122.4194, 
  zoom: 4.5,
  maxZoom: 20,
  maxPitch: 180,
  bearing: -90,
  pitch: 0,
  maxPitch: 89,
  minPitch: -89,
  position: [122.4194, 37.7749]
},
data = [
    {
    "name": "Lafayette (LAFY)",
    "code": "LF",
    "address": "3601 Deer Hill Road, Lafayette CA 94549",
    "entries": "3481",
    "exits": "3616",
    "coordinates": INITIAL_VIEW_STATE.position
    }
  ],
modelLayer = new ScenegraphLayer({
    id: 'model-layer',
    data,
    pickable: true,
    scenegraph: '/public/models/xbot.glb',
    getPosition: d => d.coordinates,
    getOrientation: d => [0, Math.random() * 180, 90],
    _animations: {
      '*': {speed: 5}
    },
    sizeScale: 1,
    _lighting: 'pbr'
  }),
fpv = new FirstPersonView({
    focalDistance: 100,
    fovy: 80,
    // near: 0.1,
    far: 10000,
  }),
layers =[modelLayer],
deck = new Deck({
    canvas: 'deckCanvas',
    initialViewState: INITIAL_VIEW_STATE,
    controller: true,
    layers,
    views: [fpv]
  })

window.modelLayer = modelLayer
window.deck = deck;

// This works
function setRootRotation () {
   let rotation = [Math.random(), Math.random(), Math.random()],
       node = modelLayer.state.scenegraph;
   node.setRotation(rotation);
   nodeupdateMatrix();
   deck.redraw(true)
}

// This doesn't work on a child GroupNode
function setNodePelvisRotation () {
     let rotation = [Math.random(), Math.random(), Math.random()],
       node = modelLayer.state.scenegraph.children[0].children[2].children[0];
   node.setRotation(rotation);
   nodeupdateMatrix();
   deck.redraw(true)
}

Environment

  • Framework version:"^8.8.0-beta.2"
  • Browser:Version 103.0.5060.53 (Official Build) (x86_64)
  • OS:Mac OS Monterey 12.4 (21F79)

Logs

No response

skywalkershen avatar Aug 09 '22 10:08 skywalkershen

xbot.glb.zip Please see attached for the model I'm using, thank you.

skywalkershen avatar Aug 09 '22 10:08 skywalkershen

This should be reported to luma.gl. @ibgreen as far as I can tell only node.matrix is used in rendering, and setting position/rotation does not mutate the matrix.

Pessimistress avatar Aug 17 '22 17:08 Pessimistress