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

Attempting to try the Minimal Scenery Example with java creates a frozen window. #771

Open
odinsbane opened this issue Aug 8, 2024 · 1 comment

Comments

@odinsbane
Copy link

Porting the MinimalSceneryExample to java creates a window that is non-responding.

package org.livingtech.scbridge;

import graphics.scenery.*;
import graphics.scenery.backends.Renderer;
import org.joml.Vector3f;

public class CreateSceneryWindow {
    public static void main(String[] args){
        SceneryBase base = new SceneryBase("Scenery Window"){
            @Override
            public void init(){
                Hub hub = getHub();
                Scene scene = getScene();
                hub.add(
                        SceneryElement.Renderer,
                        Renderer.createRenderer(
                                hub,
                                getApplicationName(),
                                getScene(),
                                512, 512
                        )
                );
                Box box = new Box(new Vector3f(1.0f, 1.0f, 1.0f));
                box.material().setDiffuse(new Vector3f(1.0f) );
                scene.addChild(box);

                PointLight light = new PointLight( 15.0f );
                light.spatial().setPosition(new Vector3f(0.0f, 0.0f, 2.0f));
                light.setIntensity(5.0f);
                light.setEmissionColor(new Vector3f(1.0f, 1.0f, 1.0f) );
                scene.addChild(light);

                DetachedHeadCamera cam = new DetachedHeadCamera();
                cam.spatial().setPosition(new Vector3f(0.0f, 0.0f, 5.0f) );
                cam.perspectiveCamera(50.0f, 512, 512, 0f, 10f);
                scene.addChild(cam);

            }
        };

        new Thread(base::main).start();
    }
}

Expected behavior

The window should show with a rendered cube?

Desktop (please complete the following information):

  • OS: Windows 10

Additional context

This isn't too important. If I create a sciview context I can get a scenery rendering window. I was curious if this would work/ should work.

@odinsbane
Copy link
Author

I found a fix for this, I had to set the renderer in the SceneryBase not just add the renderer to the hub.

                Renderer renderer = Renderer.createRenderer(
                        hub,
                        getApplicationName(),
                        scene,
                        512, 512
                );
                setRenderer(renderer);
                hub.add( SceneryElement.Renderer, renderer );

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

1 participant