Пример #1
0
  public HemisphereLight clone() {

    HemisphereLight light = new HemisphereLight(0x000000, 0x000000);

    super.clone(light);

    light.groundColor.copy(this.groundColor);
    light.intensity = this.intensity;

    return light;
  }
Пример #2
0
  @Override
  public void onStart(RenderingContext context) {
    scene = new Scene();
    camera =
        new PerspectiveCamera(
            40, // fov
            context.getRenderer().getAbsoluteAspectRation(), // aspect
            1, // near
            10000 // far
            );

    camera.getPosition().set(700, 180, -500);

    scene.setFog(new Fog(0xfafafa, 1000, 10000));

    // CONTROLS

    //		controls = new TrackballControls( camera, getCanvas() );
    //		controls.getTarget().setZ( 150 );

    // LIGHTS

    DirectionalLight directionalLight = new DirectionalLight(0xffffff, 1.475);
    directionalLight.getPosition().set(100, 100, -100);
    scene.add(directionalLight);

    HemisphereLight hemiLight = new HemisphereLight(0xffffff, 0xffffff, 1.25);
    hemiLight.getColor().setHSL(0.6, 1.0, 0.75);
    hemiLight.getGroundColor().setHSL(0.1, 0.8, 0.7);
    hemiLight.getPosition().setY(500);
    scene.add(hemiLight);

    // SKYDOME

    ShaderMaterial skyMat = new ShaderMaterial(Resources.INSTANCE).setSide(Material.SIDE.BACK);

    skyMat.getShader().addUniform("topColor", new Uniform(Uniform.TYPE.C, new Color(0x0077ff)));
    skyMat.getShader().addUniform("bottomColor", new Uniform(Uniform.TYPE.C, new Color(0xffffff)));
    skyMat
        .getShader()
        .addUniform("topColor", new Uniform(Uniform.TYPE.C, hemiLight.getColor().clone()));
    skyMat.getShader().addUniform("offset", new Uniform(Uniform.TYPE.F, 400.0));
    skyMat.getShader().addUniform("exponent", new Uniform(Uniform.TYPE.F, 0.6));

    scene
        .getFog()
        .setColor(((Color) skyMat.getShader().getUniforms().get("bottomColor").getValue()).clone());

    SphereGeometry skyGeo = new SphereGeometry(4000, 32, 15);
    Mesh sky = new Mesh(skyGeo, skyMat);
    scene.add(sky);

    // RENDERER

    context.getRenderer().setClearColor(scene.getFog().getColor(), 1);
    context.getRenderer().setGammaInput(true);
    context.getRenderer().setGammaOutput(true);

    // MODEL

    //		new JsonLoader(model, new XHRLoader.ModelLoadHandler() {
    //
    //			@Override
    //			public void onModelLoaded(XHRLoader loader, AbstractGeometry geometry) {
    //				Mesh mesh = new Mesh( geometry, new MeshFaceMaterial(((JsonLoader)loader).getMaterials())
    // );
    //				mesh.getPosition().set( 0 );
    //				mesh.getScale().set( 100 );
    //				scene.add( mesh );
    //			}
    //		});

  }