Jump to content

Simple Loading with shaderBuilder


NasimiAsl
 Share

Recommended Posts

Link to comment
Share on other sites

1 hour ago, iiceman said:

i can't deny my friend   @iiceman   challenge i love do that give me time :)

first task : explode  

Link to comment
Share on other sites

@NasimiAsl, I did manage to implement my interpretation of a Teleport entrance (final code not yet published / nor scene).  There are many mystery areas though to in-part to no code comments / method argument descriptions what so ever.  I am just turning knobs in total ignorance.

In order to leverage having ShaderBuilder inside QI, I decided to also try to use your explode example in reverse (the explode first, then mesh appears).  Going to call it a PoofEntrance.  I ran into some problems.  I cannot get line 64 to transpile in typescript:

.Black(1,BABYLONX.Helper().Solid(color2).Build())

It seems Helper is a class whose constructor returns a new instance of ShaderBuilder.  While this transpiles to javascript, constructors are not supposed to return anything.  There is no possible syntax I can supply trying to call this.  If Helper was made a sub-class of ShaderBuilder, then I could call like:

.Black(1, new BABYLONX.Helper().Solid(color2).Build())

I suppose that I could also just ditch the Helper class like:

.Black(1, new BABYLONX.ShaderBuilder().Solid(color2).Build())

Is there some reason what little is in Helper could not just be moved to the ShaderBuilder class?

Link to comment
Share on other sites

1 hour ago, JCPalmer said:

@NasimiAsl, I did manage to implement my interpretation of a Teleport entrance (final code not yet published / nor scene).  There are many mystery areas though to in-part to no code comments / method argument descriptions what so ever.  I am just turning knobs in total ignorance.

In order to leverage having ShaderBuilder inside QI, I decided to also try to use your explode example in reverse (the explode first, then mesh appears).  Going to call it a PoofEntrance.  I ran into some problems.  I cannot get line 64 to transpile in typescript:


.Black(1,BABYLONX.Helper().Solid(color2).Build())

It seems Helper is a class whose constructor returns a new instance of ShaderBuilder.  While this transpiles to javascript, constructors are not supposed to return anything.  There is no possible syntax I can supply trying to call this.  If Helper was made a sub-class of ShaderBuilder, then I could call like:


.Black(1, new BABYLONX.Helper().Solid(color2).Build())

I suppose that I could also just ditch the Helper class like:


.Black(1, new BABYLONX.ShaderBuilder().Solid(color2).Build())

Is there some reason what little is in Helper could not just be moved to the ShaderBuilder class?

i write short  struct for c# in this part maybe this can help

public static class Shader
{
    public static ShaderBuilder ME {get;set;}

    // create Child instance
    public static ShaderBuilder Helper()
    {
         
         // create sub instance
         var sb = new ShaderBuilder();
         sb.Parent = Shader.ME;
         
         // change current instance
         Shader.ME = sb;
         
    }
}


public class ShaderBuilder
{
   
     public ShaderBuilder Parent {get;set;} 
  
     public string Body {get;set;}
       
     public ShaderBuilder()
     { 
         
          /// init first properties or setting
          
          // Keep instance in Static holder
          Shader.ME = this;
       
     }    

     
     public ShaderBuilder Back( string material )
     {
          this.Body += "if(!gl_FrontFace){"+material+"}";
          
          return this; 
     }

     public string Build()
     { 
           // change current instance
            Shader.Me = Shader.Me.Parent;  

           return this.Body;
     }

   public string BuildMaterial(scene)
     { 
            
            Shader.Me = null;  

           return this.CteateShader();
     }

} 

// usage

// start instance
new ShaderBuilder().
 // start sub => change Shader ME to Sub and reverse after Build Sub MAterial
 .Back( /* sub start */Shader.Helper().Solid().Build() /*sub end */).
 // Build Final material
 .BuildMaterial(scene)

the static class help a lot for find parent Setting and indexer so i recommend you use that

Link to comment
Share on other sites

Thanks, I am not really comfortable actually forking ShaderBuilder, so I will just make my own helper function & continue to use your code unmodified other than uglified & optimized.

If I might suggest changing Helper from a class to an exported function, though.  You would have to put the statics elsewhere, but not much of a problem except for old code.  Here's what I mean:

export function Helper() : ShaderBuilder {
    var setting = Shader.Me.Setting;
    var instance = new ShaderBuilder();
    instance.Parent = Shader.Me;
    instance.Setting = setting;

    return instance;
}

Back to the old code issue, I think the lack of any build/ transpile script in the repo or version being put into at least the js file name is going to cause reluctance for some to add this into their code base.  I think I offered add to a Gulp build process, which would transpile, uglify / optimize, create map & d.ts files.  Not going back a page to check & possible lose this post, but the offer still stands.

Link to comment
Share on other sites

Actually, I ended up only needing one color for 'Poof' entrance.  I just removed the helper part needed for the 2nd color.  I have not pushed up a demo scene which shows lets you play with all the entrances yet.  All the grand entrances are already in the can for QI 1.1, though.  Other tweaks needed in different part of extension to do.

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...