Virtual Scattering Application

Page 4 of 5 Previous  1, 2, 3, 4, 5  Next

Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Sat Jun 08, 2019 10:32 pm

.
I happened to be expecting other mail, and received your BitBucket 'invite' about an hour an a half ago. I cloned g3d without a second thought. When I saw the .js files I realised I didn't need any directions. I won a prize, a fine reference edition. Thanks.

Since we jumped to a new page the last post is a page ago,  so I'll repost that JSDoc Home link.

G3D API

Home G3D 1.0.0. I didn't need to log in anywhere. Professional level documentation.  
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Sun Jun 09, 2019 12:50 am

No, no. It's actually documented. That makes it much better than professional documentation!
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Sun Jun 09, 2019 10:12 pm

.
Virtual Scattering Application - Page 4 Cringp10
Ring gun. Correcting the center ring color (phase angle). Before (top) and after (bottom).
No, no. It's actually documented. That makes it much better than professional documentation!
I for one asked for documentation, what you've done is more than I'd imagined.

I was able to correct the center ring color (phase angle) problem in Ring gun that I’d mentioned yesterday. I started at https://api.nevyns-lab.com/g3d/1.0.0/docs/module-G3DAnim.WaveAnimator.html.  To be perfectly honest, I can't say it helped. The main change was adding the animator for the center ring mesh. I also changed var pulseWaveFactor = 0.15; to var pulseWaveFactor = 2*Math.PI/(2*this.ringCount + 1) and reordered the special case center ring first section. After all the changes I’m not certain what actually corrected the problem, all I have is some satisfaction and the before and after image.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Tue Jun 11, 2019 6:53 pm

.
Virtual Scattering Application - Page 4 Motori10
I must say, thanks again for the spin. With 3 axial spin sets - and a stationary torus, this turbine/motor Helix gun configuration is clearly packing some zap.

Also packed, these guns are scaled up larger than ‘normal’ for the image’s sake. I work at a smaller size. I would also move them further outward but I cannot. The photon emission point is at the center of the torus, and I don't believe I can move the photon emission point away from the target. I recall you mentioning that, do you still intend to make that change?

The symmetrical opposite spin sets are available on the outside of the torus, directed away from the target- inside the code. They haven’t been added. The configuration is getting more complex, I need to see about some loops. I think this turbine/motor innard would fit perfectly inside the ring gun - better than this torus.

As usual, sorry for the slow progress and repetitive images. It’s a working project, and growing. The code is now longer and messier; I must concentrate on for loops. I’m grateful for the ongoing education/playtime.  
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Tue Jun 11, 2019 7:02 pm

That's looking pretty good. You can move the guns farther out. In scattering.html, line 184, there is a funtion called createGunPlacements. This then calls another function to do the work (this lets me change implementations easily). It is currently using createGunPlacements2, so go to that function and you will see a variable declared at the start called d, for distance. Change that to what you want and they will move out/in.

When your methods/functions get too large, try to split them into smaller methods and then call them from the original method. You might be able to create methods like createBarrel, etc, that only create a part of the model.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Wed Jun 12, 2019 8:09 pm

.
Virtual Scattering Application - Page 4 Neutro14
Still working in Helix. You know I just had to see what ring gun would look like filled with helix spinners.

I'm tossing out what I posted yesterday, the configuration shown here is much better. Of course it is not yet math functioned nor for-looped. The ring gun was clearly not complete by itself; the spinners also don’t seem to make enough sense on their own. Together, it appears they are a perfect match, even if I do say so myself. It's a pity they drag the browser fps into the dirt. I'll try to simplify it next.  
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Wed Jun 12, 2019 9:19 pm

We do have to watch the performance. We aren't even using many guns at the moment and I want more.

The animations could be slowing things down. I have written the animators with performance in mind, so maybe you just need to use them a bit more judiciously. Which might work better if you know how to do so.

Some Animator implementations extend from DelegateAnimator, such as WaveAnimator. These Animators are made to handle more than 1 animation. Hence why they defer to a delegate to actual do things. The idea is that you find all of the parts that you want animated with the same wave settings, and then add them all to the same WaveAnimator as delegates.

Suppose we have a barrel and a body that we want to pulse the color of with the same timing settings. We would set that up like this:

Code:

var animator = new G3DAnim.WaveAnimator( 1/3, ... );
animator.addDelegate( createPhaseDelegate( 'barrel', barrelColors ) );
animator.addDelegate( createPhaseDelegate( 'body', bodyColors ) );
// where barrelColors and bodyColors are an object with the same structure as this.pulse.colors in our gun generators
// they can be the same object if you want them to be the same colors
...

Also, when you want to use the same colors for different parts, you can just give the phase delegate an array of targets.

Code:

var animator = new G3DAnim.WaveAnimator( 1/3, ... );
animator.addDelegate( createPhaseDelegate( ['barrel', 'body'], this.pulse.colors ) );
...

See if you can organize your code like that. It may not be enough, but it might help.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Fri Jun 14, 2019 6:46 pm

.
I’ve made some progress but haven’t started delegating yet. I was trying to understand it better first. Starting at JSDoc, https://api.nevyns-lab.com/g3d/1.0.0/docs/index.html. I did a quick search/review on G3D, and saw more than I expected. https://casual-effects.com/g3d/www/index.html. They call it an ‘Innovation Engine’. I’d describe it as an advanced graphics engine – your basic entry level world generator. You can model your world scenes in a great variety of alternative lighting/rendering choices in a relatively simple, compact package. I’ve never looked into ray tracing and can’t begin to describe it. For example, brief tangent, the amount of light an object is emitting is called gamma; I’d say it’s the charge field.
Virtual Scattering Application - Page 4 Simple10
As far as progress goes, the Helix gun now consists of 4 concentric sets of: two end rings with 1 to many spinners between them. I threw out the center ring, and half the spinners. I’ve included a recent image with nice green rings and reddening spinners above. Before I threw out the center ring, I decided I would rotate and scale it to allow me to closely align – by eye - the remaining rings in the spherical Helix gun. In the image below I pulled the guns in a single image together in a tighter group to make things easier to see. The point is, Helix is supposed to be spherical. So is Simple gun.
Virtual Scattering Application - Page 4 Orient10
I’ll look at colors and the waveAnimator next, but I also want to look at these spatial distortions.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Sun Jun 16, 2019 5:54 pm

That's not my G3D, it's a different API. Mine is no where near that featured and doesn't intend to be. I just wanted a Javascript API to easily handle things like textures and animations and any other utilities I might need.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Cr6 on Sun Jun 16, 2019 9:36 pm

Wow. Really cool guys...!

Cr6
Admin

Posts : 1153
Join date : 2014-08-09

View user profile http://milesmathis.forumotion.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Mon Jun 17, 2019 1:12 am

Thanks, Cr6.

Airman, the SimpleGunGenerator is not supposed to be spherical. I made it longer in one dimension than the others to give it an oval shape. I guess you might have copied that code when setting up your new generator. You found the right code in your image above. The bodyScale property controls that scaling.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Mon Jun 17, 2019 6:58 pm

.
Virtual Scattering Application - Page 4 Curren12
Current status. After converting most of the geomery/material module into a for-loop, the ribbons need to be re-sized.

Hey Cr6, thanks. This project is rewarding; I just find it hard to believe there's enough entertainment for you.
 
Back to work. Mostly frustration yesterday, today I made good progress converting most of Helix gun’s geometry and materials module into a for-loop. The only setback is that I need to figure out how to re-size the ribbons. Then I’ll work at for-looping the mesh section. That should make things simpler with respect to addressing the animations.

As you described, I saw I could move the guns back. The problem is that the photon emission points have a maximum radius and may not be moved to the back or anywhere near a gun which has been moved back.

That G3D did seem a bit overboard.

“the SimpleGunGenerator is not supposed to be spherical.”
I’ll try again. The Helix gun appears elongated or rugby ball shaped, just like both the Ring and Simple guns. But that’s a problem, according to my understanding of the code, each Helix gun should be spherical. When I left the rotated center ring in the model in order to make slight sizing adjustments and saw the alternating center ring rotations and gun position distortions I had to share.

Ring gun also appears rugby ball shaped; its bodyScale is (1,1,1), but it Ring gun also has a variable called elong to make the spherically calculated Ring gun rings appear elongated.

So I looked more closely at Simple gun. First its bodyScale  = (1,1,1), no scaling. I see no elongation variables. When I look all the Simple gun positions, I see that the four Northern mid latitude guns are spherical.  

I don’t know what the significance is, I believed I found another clue in the case of the mis-oriented guns. It may also include significant spatial distortions that can change spheres into rugbyballs.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Tue Jun 18, 2019 5:49 pm

.
Virtual Scattering Application - Page 4 Curren13
I was still on a roll when I corrected Helix's ribbon lengths and radii.

Then, with complete confidence I began to for-loop Helix’s create Model section. Less than halfway in the rings changed colors. Soon afterwards, the ribbon radii reduced their size again. I was thwarted at around line 878. Trying various ways I could think of to create a new THREE.Group for each keyed rotator without listing them all before the loop. Here, rotator1A and rotator1B.
Code:
// model.parts.( 'rotator' + (k+1) + 'A' ) = new THREE.Group();
// or
// model.parts['rotator' + (k+1) + 'B' ] = new THREE.Group();  
// Both attempts - no joy.
It appears the same sort of keyed, referential difficulties are necessary to include each concentric set of additional ribbon loops: this.ribbonsPerSet1, this.ribbonsPerSet2 this.ribbonsPerSet3 and this.ribbonsPerSet4.

I'll be here for a while, all's well.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Tue Jun 18, 2019 9:08 pm

The first one is definitely wrong, but the second should work. Maybe there is some other problem around that line. Sometimes, when you have a problem you can't find, you start to change things looking for it, and you can change things that don't need changing. I was stuck in that position last night working on some shadowing in a shader. Once I found the real problem, I had lost little things I liked that I had changed along the way. So be careful with what you change. There is an old adage that you should only change one thing at a time, and if it didn't fix the problem, change it back and try something else. Of course, that completely fails when you have multiple things wrong, but sometimes you might see where the problem is by what those things actually change in the results. Finally, another lesson I had to re-learn recently, if everything looks correct, but there is still a problem, it can be one of two things: the problem is somewhere else, or your own understanding is incorrect. In my recent case, it was both!

I am going to change RotateAnimator, well really its parent class TargetAnimator, so that it can work with multiple targets. You can still give it a single string target, but you can also give it an array of strings and it will update them all with the same operation, a rotation in this case. This will allow you to put all ribbons into the same RotateAnimator instance. So you will do something like this:

Code:

var targets = [];
for( var i=0; i<numRibbons; i++ )
{
  var name = 'ribbon' + i;
  targets.push( name );
  var grp = new THREE.Group();
  ...
  model.parts[name] = grp;
}
var rotator = new G3DAnim.RotateAnimator( targets, ... );
...

I need to change the way it applies the rotation so that it adds to the existing rotation rather than setting it each time. That will allow you to set each ribbon with its own initial rotation, so they are offset from each other, and then the spinning happens on top of that.

However, I can't update the G3D library until I get home later today (and hopefully I remember).
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Tue Jun 18, 2019 10:51 pm

I've had a look at your helix code where you can't fit some of it into the loop. This can get tricky. What you can do is create an object (or array) that contains the data you need, in a structure that you can use it easily. It sounds so simple, and it often is, but sometimes it can take a while to see what you need. Start small, one thing at a time, and build it up to be what you need.

In this case, we have a loop creating ribbons and we then need to link those ribbons to a helix.

Before we begin, is there any reason that the helices can't be created in the createModel function, rather than init? It isn't actually creating any geometry, it is just referencing the ribbon geometry. All of the helices use this.createBodyMaterial to create their Material object, which I assume means that they are all the same. If so, then they can just share the same Material object rather than creating the same Material for all of them. Unless they are being animated through the Material, such as color, then they do need to be separate objects.

So you could just create 1 Material for them all like this:

in init():

Code:

  ...
  this.material.helix = this.createBodyMaterial();
  ...

Then move the helix creating for loops to the createModel method and refer to this.material.helix and the ribbon geometry to create the Mesh for each helix.

You could rearrange things to work like this:

Code:

// define ribbonsPerSet in constructor if you want it to be configurable
// we have a number per ribbon geometry which specifies the number of helices to use with the corresponding ribbon geometry
this.ribbonsPerSet = [ 2, 2, 2, 2 ];

// the for-loop in init should use this.ribbonsPerSet.length to determine how many times to loop

for( var i=0; i < this.ribbonsPerSet.length; i++ )
{
 for( var j=0; j<this.ribbonsPerSet[i]; j++ )
 {
 var name = 'helixA' + (i+1) + '' + (j+1);
 // notice the empty string in there, it may be needed (or not) to ensure that i and j don't add as numbers
 // I don't think it is needed because the expression starts with a string, so i becomes a string before it reaches j

 // use the geometry we created in init
 var g = this.geometry['ribbonA' + (i+1)];

 // use the material we created in init
 var m = this.material.helix;
 // or var m = this.material[name];

 // this stores it as a part, but you can just use a local variable if you don't need access to it later
 this.parts[name] = new THREE.Mesh( g, m );
 }
}

If you still want individual Material objects, then create them in init() like this:

Code:

for( var i=0; i < this.ribbonsPerSet.length; i++ )
{
 for( var j=0; j<this.ribbonsPerSet[i]; j++ )
 {
 var name = 'helixA' + (i+1) + '' + (j+1);
 this.material[name] = this.createBodyMaterial();
 }
}
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Wed Jun 19, 2019 5:55 pm

I changed TargetAnimator to accept an array of targets as well as a single string, and hence RotateAnimator now has that ability too. It might make using loops a bit easier and should be a bit more efficient to process too.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Wed Jun 19, 2019 10:00 pm

.
Many thanks Nevyn. I missed your last two messages and forged ahead, completing a second for-loop in the createModel section. You indicated one should always program in ’loop mode’, and I heartily agree.
 
I only delayed a week or two while being misdirected by G3D and mystified by delegating. I freely admit I learned a lot going through the effort. The keyed index referencing you included in Ring gun still amazes me. I finally understood what I had to do and went for it.

I needed to make several changes: like finalizing a suitable ring and ribbon function and getting the rings and ribbons variable numbering; geometries, materials and meshes; pulses and animations to agree – well I didn’t get that far. Oh, I found a source of my rugby ball problem, I was multiplying a mesh or two in only the y dimension - dumb. I thought I corrected that. Getting it into this form was a great review and organizer and makes dealing with meshes and the rest much easier.
 
The only immediate setback – beside the previously identified color change – is that all the ribbons are now type A, they all spin in the same direction. I’d like the concentric ring/ribbon sets to have alternating spin directions. I was working on an odd/even test that would flip alternating sets:

Code:
var num = n + 1;
if ( (num) - 2* Math.floor(num,2) != 0 ) {
keyP = 'B';
}
else {
keyP = 'A';
};
console.log( 'keyP: ' + keyP + ', num: ' + num );
Which was working till it wasn’t and I haven’t figured why. Frustrating.

That’s when I read your latest. Sometimes your advise and directions score direct hits, I usually need to read, assess and deliberate before knowing. And thanks for your patience.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Wed Jun 19, 2019 11:12 pm

To test for odd/even, you use the modulus operator. It is a strange little beast that divides 2 numbers, but gives you back what is left over, not the result of the division. So if we had 3 pieces of cake and divided that evenly between 2 people, there would be 1 piece left over. So 3 modulus 2 = 1. You are actually doing the math for it in your code above. So you can simplify that to this:

Code:

if( ( i % 2 ) === 0 )
{
  // even
}
else
{
  // odd
}

It is actually faster to check for inequality than for equality, so it is better to write it reversed:

Code:

if( ( i % 2 ) !== 0 )
{
  // odd
}
else
{
  // even
}

If you want every third item, then use ( i%3 ) === 0, every 100th, then ( i%100 ) === 0, etc. Not what you need right now, but will come in handy in the future.

Further more, since you only want to set a single variable, you could use a conditional statement to make it a bit simpler. A conditional statement looks like this:

condition ? result1 : result2

The condition is an expression that evaluates to a boolean value, so it must be true or false.
When condition evaluates to true: result1 is returned.
When condition evaluates to false: result2 is returned.

We read that as: if condition then result1 else result2.

So you could do this:

Code:

keyP = (i%2)===0 ? 'A' : 'B';

It's basically just a compressed if-else structure. Each result can only be 1 statement, but it can be any statement, so you can execute a function, add some numbers, concatenate strings, or whatever you want.

Notice that I said the condition evaluates to a boolean, it does not need to be a boolean, but if it isn't, then it must be a function call that returns a boolean or a comparison that equates to one.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Thu Jun 20, 2019 10:34 pm

.
Virtual Scattering Application - Page 4 Latest12
I restored the alternating ribbon spin sets. Sure. I knew the odd/even test was based on the floor and modulo functions, I think I dropped the if’s second equal sign at some point and I’m glad I did, otherwise I'd probably have never seen that wonderful odd/even test of yours. So simple, concise and useful. Thanks for sharing that.

I’m still cleaning up the post for-loop code changes. I threw out many ring and ribbon variables in the init section made redundant by the new loop structure.

Before we begin, is there any reason that the helices can't be created in the createModel function, rather than init?
I cleaned up that code too. Of course I’m probably misunderstanding the definition of ‘create’, but I believe that the helices or ribbon sets are being ‘assembled’ in the createModel function - in the for loop between lines 886-912 – by using the keyed geometries and materials defined in the init function.
It isn't actually creating any geometry, it is just referencing the ribbon geometry.
I think I agree. One references – or invokes - the materials and geometries available in the init module to create new meshes that are assembled/created in the create model.

All of the helices use this.createBodyMaterial to create their Material object, which I assume means that they are all the same. If so, then they can just share the same Material object rather than creating the same Material for all of them. Unless they are being animated through the Material, such as color, then they do need to be separate objects.
For starters. I’d like to reverse the colors of the Rings and Helices. Then mess with the animations. I don’t have any final ideas, I need to play with it first and figure this stuff out better.

So you could just create 1 Material for them all like this:
I’m reading your instructions, I'll do my best following them.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Fri Jun 21, 2019 12:55 am

Yes, assemble is probably a better word for it. You create geometry, you create material, you assemble a mesh using them.

One issue with creating things in the init function is that they will be shared between all models created via the createModel function. Which means that any Animators created in createModel will be changing the same objects, which is a waste of effort. I have been thinking about having ModelGenerator level Animators, which will operate on all models created with it. It kind of breaks the framework a bit, but will be much more efficient for things that are the same for all Models. Which a lot of mine are, but you are venturing into having unique things per gun, by the look of it.

It is perfectly fine, and desired, to create all geometry in init. It is the materials that need to be thought about, since Animators can change materials but they will never change geometry (only the Mesh that has the geometry).

However, I would still suggest you create the materials in init, but when you use them in createModel you clone them, unless you actually want to share them. All THREE.Material classes support the clone() method and you just use it like this:

Create a Material in init:
Code:

this.material.body = new THREE.MeshStandardMaterial();
this.material.body.map = ...
...

Then in createModel, we clone it to use it:

Code:

this.parts.body = new THREE.Mesh( this.geometry.body, this.material.body.clone() );

That will guarantee that you have a unique Material object for that Mesh. This is especially important when you want to use different colors on various meshes.
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Fri Jun 21, 2019 8:20 pm

.
Virtual Scattering Application - Page 4 Colors10
Current image of Helix, compared to last time, the rings and ribbons' colors are now switched.   

For starters. I’d like to reverse the colors of the Rings and Helices.
Done. Ding, ding ding! Bonus! This wasn’t just a color swap, the helices now pulse with the animated color waveform. A definite improvement.

Code:
this.material.body = new THREE.MeshStandardMaterial();
// this.material.body.map = ...
// ....  

I was expecting some difficulty, but it was quick and easy, thanks for the directions and insights. Putting the new THREE.MeshStandardMaterial - in the init function seemed like a contradiction at first. But after giving it some thought it made enough sense for me to find two other cooperative ring meshes ready and available in the existing code to choose from.  

Code:
var key = 'ringA' + (n+1);
//var mesh = new THREE.Mesh( this.geometry[ key ], matCR ); // 1.
//  1. Neon colored, or just random colors (as in my previous post’s image).
//var mesh = new THREE.Mesh( this.geometry[ key ], this.material.body.clone() ); // 2.
// 2. A ‘metalic’ grey color. Apparently the new THREE.MeshStandardMaterial
var mesh = new THREE.Mesh( this.geometry[ key ], this.material[ key ] ); // 3
// 3. Metallic wire rings – as I’d requested.

Animations next. I’ll void before girding. Do you have any recommended source on the subject?
.


Last edited by LongtimeAirman on Fri Jun 21, 2019 8:55 pm; edited 1 time in total (Reason for editing : dig and http typos)

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Sat Jun 22, 2019 11:10 pm

.
Virtual Scattering Application - Page 4 Hplusc10
A still image of my first animation.

For learning purposes only. The Helix ring gun’s 8 wire rings aligned to the target bore sight - straight into the image – are replaced with 4 ‘centerRings’ – initially rotated 90 degrees about the center ring’s x or Z axis. The animation allows the 4 rings to rotate at different rates longitudinally about the bore sight y axis (at the same rates as the helicies); they are all B-spinners. I admit, it was nip and tuck for more than hour or two, but at some point, it was working. I think I needed to add the new center ring meshes to the existing rotator. I'll need to do a better job making a new 'rotator'.

More clean up. I was bothered by the fact that Helix used three iterations of an 'angleR loop' needed to calculate the rings and ribbon set positions; once in init and twice in the create model. That may be part of what you were referring to as building in the create model function(?). The angleR loop is now performed once in the init section. The calculated values are stored in new this.arrays which are then available for the create model section.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Sun Jun 23, 2019 7:39 pm

Sorry I haven't gotten back to you, airman, My ISP is having trouble accessing this site at the moment, so I can rarely see it when at home. My phone can see it, but not my PC or phone when on WIFI. Damn annoying. Almost as annoying as typing a large post on a phone.

In my last post, I didn't really mean for you to use MeshStandardMaterial, unless it is what you want, it was just an example. That material requires a few textures to make it work properly. It is being used for the background models and is what gives them their depth and lighting, but you need to give it the right type of textures. That is why I spent a bit of time building the TexturePack and TextureDef classes to contain them and generate the material for me. If you want to use it, I suggest you go through those channels since they will take care of everything for you. I haven't done that with any guns yet, but the RegionGenerator does use it. Have a look in scattering-region-gen.js for examples. If it doesn't make any sense, ask away. There is a little bit of magic involved.

Really pleased to see you experimenting with stuff. We don't have to use everything we create. We can just play with things to learn and throw out what we don't want (or put it aside for later).
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Nevyn on Mon Jun 24, 2019 1:27 am

Actually, I have done it with a gun generator. See SpiralGunGenerator and its getTextureDefs method. That declares what textures to use and they are then used in createModel. They can also be used in init since they are created in the parent classes init function. which is called at the top of our init methods like this:

Code:

this.ModelGenerator.init.call( this );

Let me just explain it to be clear.

This is the getTextureDefs method from SpiralGunGenerator:

Code:

 
 module.SpiralGunGenerator.prototype.getTextureDefs = function()
 {
 var rpt = new THREE.Vector2( 8, 3 );
 return {
 centerTube: TexDef.Metal.RedHotSteel.clone().wrap().repeat( rpt.y, rpt.x ),
 spiral1: TexDef.Slime.Slime1_blue.clone().wrap().repeat( rpt.x, rpt.y ),
 spiral2: TexDef.Slime.Slime1_red.clone().wrap().repeat( rpt.x, rpt.y ),
 spiral3: TexDef.Slime.Slime1_green.clone().wrap().repeat( rpt.x, rpt.y ),
 spiral4: TexDef.Slime.Slime1_blue.clone().wrap().repeat( rpt.x, rpt.y ),
 spiral5: TexDef.Slime.Slime1_red.clone().wrap().repeat( rpt.x, rpt.y ),
 spiral6: TexDef.Slime.Slime1_green.clone().wrap().repeat( rpt.x, rpt.y ),
 };
 };

It returns an object and each property of that object has a value that is a TextureDef object. I'm doing some texture repeating in there, so it looks more complicated than it needs to be. Here is a more simple version:

Code:

 
 module.SpiralGunGenerator.prototype.getTextureDefs = function()
 {
 return {
 centerTube: TexDef.Metal.RedHotSteel,
 spiral1: TexDef.Slime.Slime1_blue,
 spiral2: TexDef.Slime.Slime1_red,
 spiral3: TexDef.Slime.Slime1_green,
 spiral4: TexDef.Slime.Slime1_blue,
 spiral5: TexDef.Slime.Slime1_red,
 spiral6: TexDef.Slime.Slime1_green,
 };
 };

Now it is just referencing each TextureDef directly, no changes, no cloning.

Each of those items in the object will become a THREE.Material and will be stored in the this.materials object of the GunGenerator (or whatever sub-class of ModelGenerator we are using in the moment). So, without any more effort, we just use them in createModel like this:

Code:

var mesh = new THREE.Mesh( this.geometry.tube, this.materials.centerTube );

A quick note about cloning. If you need to make changes to the TextureDef (or TexturePack or Theme) then you must clone it first, otherwise any other code that uses that texture will have the same changes, or they may change it in other ways and your model starts looking or behaving strangely. Basically, if in doubt, clone it! It can't hurt to clone it, but it can certainly hurt if you don't, but needed to.

One last thing. In the SpiralGunGenerator constructor, it specifies what type of materials it wants to create from TextureDefs or TexturePacks. This is the line that controls it:

Code:

this.texturePackType = G3D.TexturePackType.STANDARD;

That will make it generate MeshStandardMaterial instances from any TextureDef or TexturePack that you return from getTexturePacks or getTextureDefs.

Why should you use TextureDefs or TexturePacks? They contain all of the required images and take care of putting it together into a material.

Why should you use TextureDef instead of TexturePack? It allows you to control the resolution of the textures easily. Just developing: use low res textures so you don't have to wait for them to load all the time. Want to get it looking the best it can: use high res textures.

To set the resolution, or definition, add a line to your constructor (of a ModelGenerator sub-class) like this:

Code:

this.definition = G3D.DEF.HI;

It can be G3D.DEF.HI, G3D.DEF.MED, or G3D.DEF.LO. At least, HI and LO are correct, not sure if it is MED or MID, but I think it is MED(ium).
Nevyn
Nevyn
Admin

Posts : 1668
Join date : 2014-09-11

View user profile http://www.nevyns-lab.com

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by LongtimeAirman on Mon Jun 24, 2019 9:22 pm

.
Three.js is famous for having no helpful manuals. All this business with materials, textures and animations has been a fearsome challenge. It’s been awhile since I last checked with three.js. https://threejs.org/

It’s good to see there has been some work on providing user friendly documentation. Here are two 'documents' I hadn't seen before.
https://discoverthreejs.com/
Welcome to the Missing Manual for three.js!
https://threejsfundamentals.org/
Three.js Fundamentals.

There are tons of great three.js animations to sample along the way. I especially liked -  
http://mirada.com/portfolio-item/visual-effects/mirada-vfx/

Virtual Scattering Application - Page 4 Ring2b10
Current version of Ring gun.

Ring gun shows my ‘linear’ thinking, we know that you made it work. Spiral gun, on the other hand, is all yours. The two are completely different. For example, in Spiral gun we find,  
Code:
this.geometry.spiral = G3DGeometry.createSpiralGeometry( this, 1 );
“… SpiralGeometry( this, 1 ); // Huh ???”  is beyond my current understanding. I don’t see how to glom – my usual technique – the same textures into Ring gun. Ok, complaining out of the way, I did made some progress. In the image above, Ring gun is still color animated. MeshStandardMaterial is identified as purple. To each gun I added three each ‘RedHotSteel’, (centerRingE) ellispes, indicating that the get texture Def function is working. The rotation animation however isn’t. I’m stuck for a day in the for loop, lines 1255 to lines 1276.

Pardon me for asking, If you’d be so kind to tell me the loop’s top two or three problems that would be a great help; otherwise I expect my progress will be very slow.
.

LongtimeAirman
Admin

Posts : 1282
Join date : 2014-08-10

View user profile

Back to top Go down

Virtual Scattering Application - Page 4 Empty Re: Virtual Scattering Application

Post by Sponsored content


Sponsored content


Back to top Go down

Page 4 of 5 Previous  1, 2, 3, 4, 5  Next

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum