Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to know when planetarium is ready? #91

Open
jumpjack opened this issue Oct 4, 2022 · 2 comments
Open

How to know when planetarium is ready? #91

jumpjack opened this issue Oct 4, 2022 · 2 comments

Comments

@jumpjack
Copy link

jumpjack commented Oct 4, 2022

How can I know when everything is loaded and I can access all objects? (specifically, planets).
Document being ready is not enough, it's ready before planetarium loading is completed, so console.log("planetarium.planets", planetarium.planets); will result in "undefined". (being planetarium = S.virtualsky)

@jumpjack
Copy link
Author

jumpjack commented Oct 4, 2022

I see a "loadedPlanets" event triggered , but how can I detect it?

this.trigger("loaded"+(t.charAt(0).toUpperCase() + t.slice(1)),{data:data});

@meNeither
Copy link

Unfortunately, I don't know if there is a better way, but my solution was to add hooks to VirtualSky: https://github.com/meNeither/VirtualSky/blob/starlitter/virtualsky.js#L310

After that, the following is possible:

(function(S){
	function mainLoop() {
		// …
	}

	S.virtualsky.hooks.startClip.push({
		init: mainLoop,
		name: 'mainLoop',
		version: '1.0'
	});
})(S);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants