Jump to content

lensFlare draw distance.


Kilombo
 Share

Recommended Posts

Hello everyone,

 

I've been trying for the past few hours to put out a lens flare that would fade away if the camera was more then at certain distance from the light. When I check the babylon.lensFlare.js it appears that the solution is on the borderlimit variable. Although, somehow if i put the borderlimit bigger then one the lensflare never disapear from the screen. And if i put him negative or zero, it doesn't appear at all. Anyone worked around with this already ?

 

(Delta, I'll test the mipmap in this evening no worry, I promise you :) )

Link to comment
Share on other sites

Hello Delta, I thought about it, and almost implemented something like that, although when I checked the babylon.lensflare.js file, I saw a this method (LensFlareSystem.prototype.render = function ()), it has one intensity property that works with two away vars (awayX and awayY), but this doesn't seem to be working properly. And I want to understand if i'm doing something wrong or if this is not supposed to work the way I'm thinking.

Link to comment
Share on other sites

  • 2 weeks later...

Sorry to reactivet DK, but I come back to this today. The problem is the same. I think you are talking about the light. But I'm talking about the particleSystem.

In particleSystem.js I don't see any reference to distance. Anyway, I tried do do dispose if distance from emitter or bigger then the light range, and if not it would render again. It happens that this doesn't work has visible or not visible, it has to be instanciated again.

 

Is it possible to had a setVisible(true/false) that would change the private visible var in the class, and that would rather turn visible or not the particleSystem ?

Link to comment
Share on other sites

Sorry to bother again DK. But it's not working.

 

In the example in the URL the lensflare should be _enabled = false (has it is), although it still draws.

The distance is bigger then 18000 (has i defined) so it runs the method disposeParticle() (and in the console.log returns false).

There's the class and in the end is the function. Do you find anything wrong or weird ?

function system(posx,posz,planet1,planet2,planet3){    //luzes    this.planet1 = planet1;    this.planet2 = planet2;    this.planet3 = planet3;    this.posx = posx;    this.posz = posz;    this.light0 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(this.posx, 0, this.posz), scene);    this.lightSphere0 = BABYLON.Mesh.CreateSphere("Sphere0", 64, 40, scene);    this.lensFlareSystem1 = new BABYLON.LensFlareSystem("lensFlareSystem", this.light0, scene);    this.lightSphere0.position = this.light0.position;    this.flare00 = new BABYLON.LensFlare(0.1, 0, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", this.lensFlareSystem1);    this.flare01 = new BABYLON.LensFlare(0.3, 0.1, new BABYLON.Color3(0.5, 0.5, 1), "Assets/lens4.png", this.lensFlareSystem1);    this.flare02 = new BABYLON.LensFlare(0.1, 0.5, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", this.lensFlareSystem1);    this.flare03 = new BABYLON.LensFlare(0.2, 0.2, new BABYLON.Color3(1, 0.5, 1), "Assets/Flare.png", this.lensFlareSystem1);    this.flare04 = new BABYLON.LensFlare(0.05, 0.3, new BABYLON.Color3(1, 1, 1), "Assets/lens5.png", this.lensFlareSystem1);    this.flare05 = new BABYLON.LensFlare(0.2, 0.4, new BABYLON.Color3(1, 1, 1), "Assets/lens4.png", this.lensFlareSystem1);    this.light0.range;    this.light0.intensity;}system.prototype.activateLens = function(){    this.lensFlareSystem1._isEnabled = true;};system.prototype.disposeLens = function(){    console.log("entra no desligador");    this.lensFlareSystem1._isEnabled = false;    console.log(this.lensFlareSystem1._isEnabled);};system.prototype.setSun = function(range,intensity){         this.lightSphere0.material = new BABYLON.StandardMaterial("white", scene);    this.lightSphere0.material.diffuseColor = new BABYLON.Color3(1, 1, 1);    this.lightSphere0.material.specularColor = new BABYLON.Color3(1, 1, 1);    this.lightSphere0.material.emissiveColor = new BABYLON.Color3(1, 1, 1);            this.lensFlareSystem1.borderLimit = 10;    this.lensFlareSystem1.render;        this.light0.range = range;    this.light0.intensity = intensity;};system.prototype.getSunRange = function(){    return this.light0.range;};system.prototype.getSunIntensity = function(){    return this.light0.intensity;};system.prototype.getSunPositionX = function(){    return this.lightSphere0.position.x;};system.prototype.getSunPositionZ = function(){    return this.lightSphere0.position.z;};system.prototype.setPlanets = function (){    var temp = this;    BABYLON.SceneLoader.ImportMesh(this.planet1, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) {                       newMeshes[0].scaling.x = 500;            newMeshes[0].scaling.y = 500;            newMeshes[0].scaling.z = 500;            newMeshes[0].position.x = (temp.posx)/2;            newMeshes[0].position.y = 0;            newMeshes[0].position.z = temp.posz/2;            newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL);             newMeshes[0].actionManager = new BABYLON.ActionManager(scene);            newMeshes[0].checkCollisions = true;            newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 });            makeOverOut(newMeshes[0]);                });    BABYLON.SceneLoader.ImportMesh(this.planet2, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) {                       newMeshes[0].scaling.x = 300;            newMeshes[0].scaling.y = 300;            newMeshes[0].scaling.z = 300;            newMeshes[0].position.x = (temp.posx/2)+(temp.posx);            newMeshes[0].position.y = 0;            newMeshes[0].position.z = temp.posz/2;            newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL);             newMeshes[0].actionManager = new BABYLON.ActionManager(scene);            newMeshes[0].checkCollisions = true;            newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 });            makeOverOut(newMeshes[0]);                });    BABYLON.SceneLoader.ImportMesh(this.planet3, "Assets/babylonreadyfiles/", "planets.babylon", scene, function(newMeshes) {                       newMeshes[0].scaling.x = 750;            newMeshes[0].scaling.y = 750;            newMeshes[0].scaling.z = 750;            newMeshes[0].position.x = temp.posx;            newMeshes[0].position.y = 0;            newMeshes[0].position.z = temp.posz/2;            newMeshes[0].rotate(BABYLON.Axis.X, Math.PI/4, BABYLON.Space.LOCAL);             newMeshes[0].actionManager = new BABYLON.ActionManager(scene);            newMeshes[0].checkCollisions = true;            newMeshes[0].setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 });            makeOverOut(newMeshes[0]);                });};function calculateSunDistance(system,camera){    distancex = Math.abs((camera.target.x)-(system.getSunPositionX()));    distancez = Math.abs((camera.target.z)-(system.getSunPositionZ()));    console.log(distancex, " ",distancez);    if ((distancex > system.getSunRange())||(distancez > system.getSunRange())){        system.setSun(system.getSunRange(),0);        system.disposeLens();        console.log("desligou");    }    else{        system.setSun(system.getSunRange(),1);        system.activateLens();        console.log("ligou");    }    };
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...