Skip to content

WWT is not quite ready when promise resolves #327

@Carifio24

Description

@Carifio24

The WWT Pinia store offers the (extremely useful) waitForReady method that can be awaited to make sure that code only runs when WWT is ready. However, there are a few methods that will cause errors if invoked immediately after the store is ready. As a simple example of this, modify the research app mounted hook to be the following:

this.waitForReady().then(() => {
  console.log(this.findScreenPointForRADec({ ra: 10, dec: 20 }));
  // ...
});

then load up the app and you'll get a fun error like

Cannot read properties of undefined (reading 'get__isDistinguishedIdentity')
TypeError: Cannot read properties of undefined (reading 'get__isDistinguishedIdentity')
    at __webpack_modules__../esm/double3d.js.Matrix3d.multiplyMatrix (webpack-internal:///../engine/src/index.js:11645:17)
    at WWTControl.transformWorldPointToPickSpace (webpack-internal:///../engine/src/index.js:61047:68)
    at WWTControl.getScreenPointForCoordinates (webpack-internal:///../engine/src/index.js:61060:27)
    at Proxy.eval (webpack-internal:///../engine-pinia/dist/index.umd.js:6601:44)
    at eval (webpack-internal:///../node_modules/ts-loader/index.js??clonedRuleSet-40.use[0]!../node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/App.vue?vue&type=script&lang=ts:2055:31)

which we get because the render context matrices haven't been set up yet.

The obvious solution to this is to force-render a frame before we report from the store that WWT is ready, but maybe there's a better approach? Pinging @pkgw in case he has any thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions