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

Cesium and three.js #6094

Closed
m-schuetz opened this issue Jan 5, 2018 · 2 comments
Closed

Cesium and three.js #6094

m-schuetz opened this issue Jan 5, 2018 · 2 comments

Comments

@m-schuetz
Copy link

m-schuetz commented Jan 5, 2018

Hi,

I hope it's fine if I open an issue here while I'm working on a demo with Cesium and three.js combined. ( related to #648 )
You can find a video of a working example here: https://www.youtube.com/watch?v=bnn39nNbDfA
I'll upload the whole thing once I've cleaned some stuff up.

To make this possible, at least for opaque objects, we need to be able to inject three.js render code into the cesium render pipeline. In the example given in the video, I've added a callback during the globe pass in Scene.js

// Cesium - Scene.js

us.updatePass(Pass.GLOBE);
var commands = frustumCommands.commands[Pass.GLOBE];
var length = frustumCommands.indices[Pass.GLOBE];
for (j = 0; j < length; ++j) {
    executeCommand(commands[j], scene, context, passState);
}

renderThreeJS({
	numFrustums: numFrustums,
	i: i,
	frustumCommands: frustumCommands,
	scene: scene,
	camera: camera,
	frustum: frustum,
	passState: passState
});

Do you have any suggestion/preference on how you'd allow developers to hook into the rendering pipeline?
Not sure how event handling is done in cesium. I'd usually do something like this:

// first, render globe
us.updatePass(Pass.GLOBE);
var commands = frustumCommands.commands[Pass.GLOBE];
var length = frustumCommands.indices[Pass.GLOBE];
for (j = 0; j < length; ++j) {
    executeCommand(commands[j], scene, context, passState);
}

// then, notify all globe_pass listeners
for(let listener of listeners["globe_pass"]){
	listener(numFrustums, frustum, camera);
}

Threejs developers could then add their render code like this:

cesium.addEventListener("globe_pass", (numFrustums, frustum, camera) => {
	// threejs render code here
	// e.g. copy view and projection matrices, as well as near and far from cesium
	// then call threeRenderer.render(threeScene, threeCamera);
})
  • We'd probably also need to let cesium know of the bounds of the three.js objects.
  • Another callback before the frustum loop is probably also usefull/necessary to give threejs developers the chance to cull and arange the scene for each individual frustum range.
@ggetz
Copy link
Contributor

ggetz commented Jan 5, 2018

Hi @m-schuetz !

Thanks for asking, please post discussions over at the Cesium Forum. There are members of the community and developers from the team who answer these kinds of questions there. Additionally, Cesium's a big project, so we use GitHub for feature requests and bug tracking exclusively.

I've gone ahead and opened a new forum thread for this here, and I'm going to close this issue.

Thanks!

@ggetz ggetz closed this as completed Jan 5, 2018
@cesium-concierge
Copy link

Congratulations on closing the issue! I found these Cesium forum links in the comments above:

https://groups.google.com/forum/#!topic/cesium-dev/GX7xLXrPDsE

If this issue affects any of these threads, please post a comment like the following:

The issue at #6094 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

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

3 participants