-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
618 lines (558 loc) · 37.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<!--Emergence Simulation System
by Marceline Peters / https://github.com/marcinas
original: protoplanets - https://threejs.org/examples/webgl_gpgpu_protoplanet.html
by mr.doob / http://mrdoob.com/
modifications by Marceline Peters
see readme for additional credits
-->
<!-- Emergence Simulation System -->
<!DOCTYPE html>
<html lang="en">
<!--links-->
<link rel="manifest" href="manifest.json">
<link rel="icon" href="images/favicon.ico">
<!--information, basic html -->
<head>
<!--version history, to do, done list-->
<script>
/*******************************************************************************
* VERSION HISTORY
*******************************************************************************/
var VERSION = {
VERSIONS: [
"Version Alpha 0.4+prior: see alpha version files",
"Version Beta 0.1 : protoplanets fork from three js examples",
"Version Beta 0.2 : toroid geometry added; file restructure; particles float within geometry bounds",
"Version Beta 0.3 : layered statistics and added custom stat",
"Version Beta 0.5 : entire rendering/graphics code rewrite begin; floating rainbow points",
"Version Beta 0.7 : sizing introduced; floating variously sized 2d squares",
"Version Beta 1.0 : ball texture used; dark ringed volumetric spheres",
"Version Beta 1.1 : controls and statistics restructure",
"Version Beta 1.8 : object oriented rewrite begin",
"Version Beta 2.5 : file structure organization",
"Version Beta 2.9 : last beta version; forward compatibility expected of Beta 2.9",
"Version Beta 2.9+prior: see beta version files",
"Version Gamma 0.0 : quanta (mass = 1) now have no collision options so they can act as energy; gaussian random function debug/rewrite; monads remember location of last impact " +
"and randomly emit particles in a similar direction and of a similar 'charge'; major changes to rendering and updating to efficiently process/display a more " +
"complex scene; efforts for backwards compatibility use in code design; first update header: fixed bad merge bug (needed crosses at -1 with unit/2 radius); " +
"added weighting scaling to prevMatch as well; first more obvious emergence display (particles now communicate through what look like sound waves); " +
"controls structuring; other changes based on conversion from particle-particle collider to quanta-monad-particle-collider; " +
"(versions 0.0a-0.0b formerly beta 3.0-3.3)",
"Version Gamma 0.1 : added version visual; fixed crossover, collision, and zone bugs allowing overlap; altered size/unit formula for no crashing; bugfixed max particle capacity " +
"options (displacement) with; added overloading mass options; fixed click on particle; added clear quanta button; changed initial zoning and zoning correction " +
"for better speed; altered zone functions to optimally work with new requirements",
"Version Gamma 0.2 : added basic unexciting bonding structure; rewrote stats panel and output (stats panel has been updated and debugged); added some controls labels; " +
"collision and emission visual controls added; tweaked default sizing ratio and exp; particles now display collide color 1 frame earlier (-2% opt)",
"Version Gamma 0.3 : further tweaks to statistics gathering and control (resets now); some optimization tweaks (1%); double-click on particle fix to a partial second; " +
"reorganized crossover/zones collision detection to better work with large particles; added reabsorption; fixed refresh sim visuals; added midpoint positioning " +
"at collision; organization and rewrite of readme; moved debug to basic.js; outOfBounds distance corrected with new getToroidDistanceTo function " +
"that checks all 8 possible toroid configurations for a monad (-5% opt); added charts functionality and positioning to simulation, with info from " +
"start to current time (monad charge, quanta charge, distance between particles 0 and 1; charts and stats now have ability to place a midline " +
"stats/charts can change each data point on red-purple-blue color scale based on input 0-100; added color key and monad size distribution chart " +
"added distinct color changes for monad-monad merging, bonding, and single-tick absorb/merge-emit; edited color scheme; emission-collision same quanta fixed ",
"Version Gamma 0.4 : changed charts to now have extra color dimension separate from height; moved temperature to charts; bugfixes; added impact effect control; " +
"fixed escape check detection; reabsorption has been bugfixed, finally; changed startup controls defaults; rewrote bonding to be local only and managed " +
"through position correction based on weight, current speed, with excess effects and toroid wrapping; bugfixed to visuals and recalcing unescaped quanta; " +
"added commenting to multiple sections; group.js deleted since it is no longer needed in current bonding scheme; click-monad interaction visuals tweaked; " +
"particle coloring scheme has been redone, with darkness now used as a measure of distance (blackoutRadius has been removed and distanceFactor added)",
"Version Gamma 0.5 : made a *much* smoother simulation viewing experience at cost of -5% opt; simulation and statistics tweaked so first tick only gather stats and updates them; " +
"initial generation tweaked; statistics code tweak for simpler data structure; statistics color charts now have full 6-hex color, background color bugfix; " +
"interactive.js and basic.js combined and hash code tweaked; added dual monad test mode and output statistics; added first stages of image capture for data; " +
"logs file removed from versions and placed into research; multiple-round testing and rudimentary tracker setup; first multi-run dual particle simulation farming",
"Version Gamma 0.6 : nearly finalized to-do into public publishing to-do and long-term; bugfixed major getToroidDistanceTo issues regarding checking all possible measurements; " +
"statistics now update on a true [1,freq] cycle instead of randomly throughout cycle; particle resize on window resize fixed; simulation id updating tweaked; "+
"removed from statistics: particle count, average monad mass, instability; remade in statistics: occupancy, occupancy immediate, monad count, msd + average mass; " +
"rearranged statistics panel placement; double-clicking set to fps; boxes now toroid-warp with particle; statistics now has customizable color schemes; " +
"window.onbeforeunload confirmation; initial camera setup and positioning tweaked; more commenting throughout; fixed restart when paused spamming multi-runs; " +
"added basic color-neutral mode (needs different distance effect); statistics variable renaming and panel display tweaks; rewrote some zones code simpler; " +
"much more multi-run dual particle simulation farming; redid visual controls layout and added bonding; changed bonding colors",
"Version Gamma 0.7 : toroid wrap-around supersize (larger than half zone) particle bonding, unbonding and collision fixed; +5% to opt thanks to some code and stats reconfiguration; " +
"impactEffect changed to quantaWeight rewritten to affect ratios between only quanta and monads; bonding now has sliders and toggles to control effects; " +
"default controls and bonding effects tweaked; monad visuals in simulation fixed to update whenever changes occur; changes to some variable names and setup; " +
"major changes to bonding, collision, merging, and bouncing (bouncing has been tweaked to analyze for monad-monad, quanta-monad, and parent-child collisions, " +
"collision now differentiated from merging so tiered and combined behaviours are possible, and some mathematics tweaked--theoretically backwards compatible); " +
"default modes and mode-selection changes, including stress, research, and clump; most files are now mostly commented",
"Version Gamma 0.8 : variables renamed in monad and elsewhere; statistics refactor into prototypes gives +5% to opt; occupancy/tick replacing with bondings/tick; variable renames " +
"tweaks to code to improve efficiency or readability; all basic commenting finished for all files; todos gone through and minor changes/bugfixes throughout; " +
"double-checking of all files; added banner and link to github; prepped files for upload",
"Version Release 1.00: uploaded to github, identical to Gamma 0.8",
"Version Release 1.01: changed initial maximum mass load, removed snapshot taking, added runtime fps information",
"Version Release 1.02: mergeRatio changed to 0 for all initial loads",
"Version Release 1.03: added warning for mobile users, tweaked visuals and initial median mass",
"Version Release 1.04: shifted some pixel lengths in controls, fixed zoom and resizing issues on some computers, cosmetic changes for controls, and new links",
"Version Release 1.05: cleaned up controls, moved accessibility options their own folder, added inversion, inverted default background/wireframe colors",
"Version Release 1.06: added controls header, rebased entire repo commits for consistency"
],
CURRENT_VERSION: "",
CURRENT_NOTES: ""
};
VERSION.CURRENT_VERSION = VERSION.VERSIONS[VERSION.VERSIONS.length - 1].slice(8,20);
VERSION.CURRENT_NOTES = VERSION.VERSIONS[VERSION.VERSIONS.length - 1].slice(22);
/*******************************************************************************
* TO-DO short term
*******************************************************************************
******************************************************************************/
/*******************************************************************************
* TO-DO long term, to be completed next research/development cycle
*******************************************************************************
define numbers and behavior for when Monad Polarity produces infinity (only monads of 1 quanta)
update readme to use markdown format (readme.md)
add information from research paper with new writings to develop a readme or explanation
possibly add a pop up that gives brief information about what's happening
change clump to scale up emission (since mass was scaled up)--also check boundary size
add perspective control to visual camera
add popup that triggers first time low fps encountered, pauses and asks (do you want to continue running sim?)
add frame-rate limit to prevent slowdown during very fast simulations (where statistics calcs are the bottleneck)
write function to gather monad info in CSV format for every # of frames
write to text file the logs
revise basic.takeSnapshot() to also take snapshot of statistics screen and controls fully opened
also re-enable under certain circumstances
track broken bonds
indicator for displacement/capacity
basic.debug(): check what prints on all combinations:
null values, undefined, 0, strings, arrays, array of strings, etc.
possible add new function as well: stringify() which has different instructions for each data type
monad.bounce() should have more research on how interactions work
split monad.qunata.countdown into color only variable and actual escape tracking variable separately
move countdown and mountdown to color (see also new color scheme idea, somewhere below)
monad.getToroidDistanceTo(): in if (x1 || y1 || z1 || x2 || y2 || z2)
optimize by only cycling through appropriate zones (check zone intersection code)
monad.checkBond(): in //get raw distance and weighted speed,
what about max speed check? why only check < 1?
should we have it less than 1? why? other than obvious fact of speed too fast to bond?
fix energy loss for merge-only simulations:
monad-monad-collision doesn't re-absorb the absorbed monad's quanta
(they are lost on reabsorption stage once their count is reached)
for monad.spaceDistanceTo(), find formula to always give perfect distance in toroid world (right now is just while loop)
when merging particles, if debug chosen index particle is nullified, change debug index to new particle index
for exceeding max speed and bonding manipulations, add controls to control cost of extra excess quanta.e emissions
for statistics update, fill in more || 0 or NaN values to avoid weird results
change bad values to negative? be careful of || though!! 0 is valid
stress test originally had funny values for polarity and size distribution (it doesn't appear to currently)
change monad research to record also distances for limited number of first particles
(i.e., 0/2, 1/2, 0/3, 1/3, 2/3, 0/4, 1/4, 2/4, 3/4)
or make dynamic so can scale so that all particle's distances/charges are measured
similarly update controls.world.strict settings so that all particles are equidistant
multiple textures for positive/negative particles (alternative to color-neutral mode)
maybe just a plus + on positives; minus - on negatives
add button to make all particles red or blue
maybe a slider of color polarization? the more, the more red and blue particles will appear
take pictures of statistics information
z-indexing so layer is controls -> statistics -> simulation
checkout how to avoid javascript runtime violations (mostly from loops taking too long)
write collision and other looping to be parallel processed (changed emphasis to one super-fast simulation
rather than many fast simulations)
check if added and constantly monitoring a .mass composition (similar to radius) in monad
affects runtime (currently, radius is always accurate but mass must be obtained from
adding attractons and repulsons whenever desired)
if possible to do and not slow simulation down: find a way to store double+ sets of
information in each monad in order to:
process every monad mathematically simultaneously (in the current system, if monads A, B, and C exist in the simulation and
have overlapping boundaries such that A is overlapping with B and B is overlapping with C (but A and C do not overlap)
within a single tick, there are rare but possible difference that can arise, say by: e.g. the overlaps being the barest
fractions of overlaps, merging being enabled but not bonding, and monad A is processed first, so it is merged with monad
B, creating an updated bigger monad positioned between the former monad A and monad B; monad B will not be processed because
it has merged; when monad C is processed, it will no longer be barely overlapping with monad B, and thus a potential
missed collision may occur)
process all statistics in same quantum step
analyze multiple event chaining (see the first argument above about simultaneous mathematics) in a way that ensures at least
for one quantum time step, there are no discrepancies based on monad order of processing
change colorCharge panel to be fully transparent except for red and blue and purpleness?
this way user can drag camera over it to have a monad right up against the color scale
add ability to download entire monad and settings dataset (all positions, velocities, etc.)
can re-upload dataset into simulation
idea would be to be able to pause simulation, download, and resume another day or another computer
this way can create lots of very unique setups just from data and load them into simulation
color-neutral mode: have different distance effect (darkness won't do--maybe purpleness?)
relabel all of these quanta stuff with actual words...
update [terminology] working to attracton/repulson
i think this means change n/p -/+ to r/a
checkout cache/binding (see research todo and notes.txt)
run enough tests on mass to find minimum mass on scaled world size that blues connected to blues near 100%
keep doing what you're doing, describing model, etc. but come up with an experiment
can be large scale (we ran 100 experiments on blue--they merged 95% of the time, etc.)
or can treat it like: we created this simulation to see what would happen
and here are some of our observations
story part one: show (if massive enough) blue-blue and red-red combined
story part two: the shapes in bonding (tetrahedral, lines) think orange packing
two reds, two blues, one red, one blue, three reds, three blues (100%)
cvs of distance over time
averaged out over time to smooth anomalies (e.g. do blues really separate before uniting)
new checkbox for absolute median ? (also check deviation calculations)
make a Data object JSON (every object is string that can be saved) probably of emergence object or statistics object
check out MCGB2 database dump lines 328-386 fishnut.js
send email to M to set up/show database
in case of crash: every run being over, just upload the data
think data storage (as in, for a 3000 tick simulation, just export as csvs with titles)
make toroid have options:
toroid (already done)
bounce off wall
repel reverse direction
toroid but warp opposite
vanishing point--particles disappear beyond box
can also do simple radius from center
add trails behind monads
consider rewriting ToroidDISTANCE if these are always same arguments (will need to check Zones.getcollisioninzone to see how gettoroiddistance used there)
change colors so that user can pick which of red,green,blue is positive and negative
add 26 cube copies of the environment around the central environment (like 26 toroid mirrors)
have them fade from transparent to nothing within a few zones of the edge, so near to the edge,
monads are visible in all their edge/corner locations, full opaque in central sim and transparent in side ones
add save and load of controls settings
(see https://workshop.chromeexperiments.com/examples/gui/#5--Saving-Values)
ALL CAPS in controls should be eliminated or integrated into presets
tooltips for all controls and settings
redo monad colors to have base color, over-color, and toggle to decide whether to use base or over
base color will always be red-blue spectrum with whiteout settings?
over-color will be collision, emission, bonding, etc. colors
check how new bonding and merging models will affect quantamerge
e.g. do experiments and watch to make sure results look 'normal'
single-quanta should always be absorbed
add effects that smaller particles have lower thresholds (distance?) for merging into
a big particle they are bonded with
rewrite collision-bonding mechanisms to ideally get bonding behavior without bonding arrays
e.g. just have particles try to avoid intersections? bouncing? shooting a/r into other monad?
line between two clicked particles
line between two particles that have exchanged quanta
line between two particles that are bonded
rewrite bounce rules for monad-monad non-bonding (right now always adds vectors for attractons > repulsons)
full color multi-layered histograms
like each rainbow color has a meaning, multiple transparent layers
extra lines and points like trendlines, local maxima, minima...
for log scale, just take log... duh
e.g. histogram of all monads: sizes, charges, total emitted, bonded, speed, all in one chart
collision
redo to ray-casting collision (allows higher max speed but needs complete rewrite of zones and maybe monad)
bonding:
WHEN BONDed, emission does not collide until it leaves volume of all bonded monads
once it leaves, it can collide, even with itself
workaround chrome bug:
GL_INVALID_OPERATION : glGenSyncTokenCHROMIUM: fence sync must be flushed before generating sync token
WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
fix: bonding over toroid edges
maybe write photo taker or video taker
finish alpha-beta version cataloging
cleanup initialization to make faster
crossover bigger regions than 3x3x3 cube? (right now just scales up to 5x5x5, 7x7x7, etc.)
maybe particles warp space around them (use zones to record stability)
use attraction fields in zones for aggregate data to visualize (e.g., every zone has a color)
if feel missed collisions
try shadowing past movements or using ray collisions if movement exceeds radius in one frame
future: imagine structures... +/- arrangement (what do they look like internally?)
add bouncing, elastic collisions
new universe option: toroidal sphere....
toggle for 'gravitational' attraction to center
okay, so each monad has two impact points:
a red and blue vector
when a new collision occurs, the blue portion of the impact is weighted and combined with the blue vector
same with red
when emitting, the red or blue quanta determines which impact vector it will use
all direction is a combination of the red and blue vector weighted
thus, on impact, blue and/or red vector is altered, and net velocity re-adjusted
could also have impact region (?)
******************************************************************************/
/*******************************************************************************
* DONE :) for prior accomplishments, see alpha and beta files
*******************************************************************************
possibly remove or officially add secret on-initial-load mode
add or rename link on main page to show it's going to github / readme
starting monads pow should be scaled to expected power (much less on mobile)
fix statistics/controls default sizing where devicePixelRatio != 1
change indenting on readme because github makes it look weird
.editorconfig
change sizing so that CNTL/CMD -/+ only scales statistics/instructions
make sure boundaries of simulation animation stay at edges of browser
COMMENTS/CLEANUP: FULLY DONE (COMMENTED, VARIABLE RENAME and LINE COMMNETS and CLEAR JUNK CODE):
emergence_simulation.html
controls.js
readme.txt
basic.js
zones.js
monad.js
statistics.js
emergence.js
spellcheck, etc.
get rest of to-do list from readme
add banner to top
cleanup takeSnapshot function but leave disabled
CHECK ALL TO-DOs in all code and either do them or place them here or in to-someday-do
individual line TODOs gone through and either done, moved to to-someday-do, or scrapped
add [optional parameter] brackets to javascript documentation
color neutral: reload charge colors and other stats charts/panels to match scheme
have a new simulation that's loaded while in pause advance a single tick (resets the stats)
change hash options to drop-down menu
since stress test, monad research, and clump mode can't overlap
leave debugInit as checkbox
bonds don't get removed on super merges (many heavy particles in center at generation)
collision checking fix for if combined radius is bigger than size (getToroidDistanceTo will negative numbers)
change 'collision' to 'merging' unless it actually checks for all interaction upon collision
option to not keep bonding constant--just always nudge away from overlap
add sliders and toggles for bonding settings
collision colors flash
every collision per time step determines probability of impact-based emission (both by polarity and direction)
average or keep array of impacts and choose randomly from it
for < 200 datapoints, have statistics floor the calculated number (won't cut off half then)
only needed for msd
investigate:
sometimes pausing (pressing ;) if near a restart will cause two-monad tests to rapidly restart
sometimes quanta and monads timelapse charts will have a single line much higher or lower than others
further statistics cleanup:
left panel instant stuff (fps,ms,mb,em,col,noise,unalter)
left panel current stuff (quanta,monads,temp,dist,other time values, -msd)
bottom panel timelapse stuff (current - msd +monad size dist., change final value to average
ax: particle count, average monad mass, instability
color-blind mode (black negative, white positive, gray neutral, red background, distance by amount of background color mixed in?)
added confirmation before closing browser window (prevents accidental experiment end)
bug: particle boxes don't toroid warp (they continue into empty space)
add run id number for mass number testing
bugfix: screen height and width change particle size appearance
bugfix: getToroidDistanceTo Incorrect (see bonding over toroid walls)
multiple collisions over a few frames with just 2 particles? see Run 3: -1490353990040.log
look for
motion and interaction between two big particles
small rom, big room
possible bug: when changing visualization (showRadiation), it causes a collision (perhaps resetting monads?)
new bonding mechanisms (local only, positional based)
each monad attempts to readjust any bonded particle not immediately next to it
it can only move the particle up to both of the particles speeds weighted by mass
if it cannot move the particle all of the way, the remaining distance is converted
to excess (similar to converting max speed to excess) and quanta is emitted to conserve energy
major bugfix: reabsorption loss fix (particles leave the timeslots stream and particles reabsorb before emission)
write different color for monad-monad collision
impact % charge or emission can be scaled (e.g. 1 quanta does 20 quanta worth of impact--monads move faster)
similarly, possibly add averaged position when collide
(i.e., the position of new bigger particle is the average of the two colliding particles)
oob re-design to check all 8 possible toroid wraps
fix mpolarity, charge, polarity in statistics (pretty much all get very strange in non-strange conditions)
mpolarity gets negative; cloud charge get negative on stress test; etc.
graph showing both quanta and monads and positive/negative using colors
add switch to turn off collision/emission colors
debug crossover (it's still not getting particles next door--see last screenshot)
clear quanta button
fix clicky mouse
recycle quanta instead of displace (lost quanta is readded (without velocity affects) to originator monad)
create enforceMass control
switch setup so that if ever the number of possible rendered particles reaches max and another needs to generate,
the farthest away, longest timed particle existence is replaced with the new emission
this will allow up to 1000s of high mass particles to interact and have a combined mass much higher than that of total renderable particles
make decay rate exponential
give every simulation an ID so it's easy to check prior photos
add a timer to show how long simulations are running
if possible w/ firefox
wrap code in anonymous functions
(function(window) {
//all code in your file goes here
})(window);
create graph function that takes in a lot of versatile data
dynamic so can get all sorts of data
maybe even during simulation
log plot and histograms for largest particle
add a print report button that prints a few frames of automatic debug material
use webform to put in constants
mass relates to volume/radius (oranges problem/ spheres)
for emission, place emitted particle on the sphere surface + 1
fixed speed use maxspeed
emitted particle should be the fastest thing in system
neg/pos maybe affect vectors (pos/neg)
based on composition of particles, bouncing, bonding, merging with activation energies as well?
emission based on kicking out the minority particle
add toroid opposite end warp switch
add toggle for whether p/n actually effect each other
decide how lighting works (can be based on neighbors total, mass, etc.)
same for color, shape, maybe even transparency
bug fix (one emission with two components, split/emit and will they merge again?)
check on fixed vector--observe interaction
use webgl or three.js, up to you, will optimize better
optimize graphics
probability per tick of emission
attraction vs repulsion
no rules of attraction and repulsion (no cycling)
just emit positives/negatives and collisions affect trajectory
more like seeing if attraction/repulsion emerges
goal:
color of sphere changing floating around in space
toroidal
2nd goal:
spheres collides
color based on ratio of +/-
3d canvas
100 particle minimum, 1000s preferred
******************************************************************************/
</script>
<!--basic-->
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<title>Emergence System Simulation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!--image import-->
<script src="images/ball.js"></script>
<script src="images/point.js"></script>
<!--effects only initial load (once particles load, resets elsewhere)-->
<style>
body {
background-color: #FFFFFF; /* only affects initial load */
margin: 0px;
overflow: hidden;
font-family: Monospace;
font-size: 12px;
text-align: center;
text-align: center;
cursor: pointer;
}
a { color:#0000ff; }
#info {
color: #555555;
position: absolute;
top: 10px;
width: 100%;
}
</style>
</head>
<!--simulation proper-->
<body>
<!--loads js scripts-->
<script src="js/three.js"></script>
<script src="js/Detector.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/GPUComputationRenderer.js"></script>
<script src="simulation/statistics.js"></script>
<script src="js/dat.gui.min.js"></script>
<!--statistics and data bars-->
<script>
var MOBILE = false;
//mobile detection credit: http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) {
alert("Due to the large processing power required to run the Emergence System Simulation and its visuals, it is recommended to use a desktop or powerful laptop to enjoy full use of the program's features and research capacity.");
MOBILE = true;
}
//"use strict";
</script>
<!--statistics and data bars-->
<script>
/**
* Sets up the modified statistics program to analyze the simulation during runtime.
* This includes information on simulation composition and distribution both in realtime,
* timed intervals, and on-request. See statistics.js file for more information.
*/
var statistics = new Statistics();
for (var d = 0; d < statistics.monitor.dom.length; d++)
document.body.appendChild( statistics.monitor.dom[d] );
/**
* Animation function created and immediately invoked (saves a lot of speed). Updates
* statistics monitor (all panels who are due to update) and recursively calls itself
* to read from the simulation and update statistical data accordingly.
*/
(function animate()
{
statistics.monitor.update();
requestAnimationFrame( animate );
})();
</script>
<!--vertex shader-->
<script id="vertexShader" type="x-shader/x-vertex">
varying vec3 vColor;
varying vec3 vStats;
varying vec2 vDist;
/**
* Vertex shader uses workaround design to get additional information
* into the system without extra variables. Input 'color' consists of six
* data pieces packaged into the rgb scheme:
* color = {
* r: float -> { floor(r) = vStats.x, distance; r%1f = vColor.r, red [0,1) }
* g: float -> { floor(g) = vStats.y, darkest; g%1f = vColor.g, green [0,1) }
* b: float -> { floor(b) = vStats.z, size; b%1f = vColor.b, blue [0,1) }
* }
* Thus the integer floored values give us size data and two currently unused values
* (Beta 0.5 has some aspects of this).
*/
void main()
{
vStats = vec3( floor( color.r ),
floor( color.g ),
floor( color.b ) );
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
vDist = vec2( max( vStats.y / 1000.0, min( 1.0, vStats.x / length( mvPosition.z ) )),
300.0 / length( mvPosition.z ) );
vColor = vec3( (color.r-vStats.x) * vDist.x,
(color.g-vStats.y) * vDist.x,
(color.b-vStats.z) * vDist.x );
gl_PointSize = vStats.z * vDist.y ;
gl_PointSize = max( gl_PointSize, 2.38 );
gl_Position = projectionMatrix * mvPosition;
}
</script>
<!--fragment shader-->
<script id="fragmentShader" type="x-shader/x-fragment">
uniform sampler2D texture;
varying vec3 vColor;
/**
* Basic fragment shader design filtering out alpha values below 0.5.
*/
void main()
{
gl_FragColor = vec4( vColor, 1.0 );
vec4 tColor = texture2D( texture, gl_PointCoord );
/* The below line will avoid chrome-related conditional crashes but the visual effects are undesirable. */
//tColor.a = tColor.a * floor(tColor.a + 0.5);
if ( tColor.a < 0.5 )//this conditional will crash chrome-related WebGL stuff after a long runtime (usually with several sims running at once)
discard;
gl_FragColor = vec4( gl_FragColor.r * tColor.r,
gl_FragColor.g * tColor.g,
gl_FragColor.b * tColor.b,
tColor.a);
}
</script>
<!--load simulation js scripts-->
<script src="simulation/basic.js"></script>
<script src="simulation/controls.js"></script>
<script src="simulation/zones.js"></script>
<script src="simulation/monad.js"></script>
<script src="simulation/emergence.js"></script>
<!--Emergence Simulation System-->
<script>
/**
* MAIN
*
* The effective 'main' of the simulation. After all of the components have been loaded
* (see above), the url message is used to determine constant reload settings (such as
* maximum particle count and system presets). Then, the Emergence system object itself
* is instantiated and set on an eternal animate loop.
*/
if (!Detector.webgl) Detector.addGetWebGLMessage();
setupWindow();
var DEBUG = false;
var bonded = 0;
var runs = 0;
var emergence = new Emergence(statistics);
emergence.startup();
/**
* Recursive immediately invoked animation function that calls the simulation to update
* itself and all its components one frame/tick, renders all of the particles and other
* visual objects/effects according to settings, and then has the statistics object
* check monitored information and update displays as needed. Note that the system will
* continue running, rendering, and monitoring statistics even if paused (controls to
* pause or step-through the simulation are handled in the emergence.update() function).
*/
(function animate()
{
requestAnimationFrame(animate);
emergence.update();
emergence.renderer.render(emergence.scene, emergence.camera);
statistics.monitor.update();
if (DEBUG) { debug(["system","scene"],emergence.scene); };
if (statistics.tick === emergence.runtime) {
//takeScreenshot();
if (statistics.instant.bonds || statistics.maximum.bonds)
bonded++;
debug("always",emergence.monads[0].toString());
debug("always",emergence.monads[1].toString(emergence.monads[0]));
debug("always","Runs: " + ++runs + " Bonds: " + bonded);
} else if (statistics.tick > emergence.runtime)
emergence.restartSimulation();
})();
</script>
<div id="info">
Emergence System Simulation<br/>a particle collider by <a href="https://www.linkedin.com/in/marcelinerenae/" target="_blank">Marceline Peters</a> (<a href="https://github.com/marcinas/marcinas.github.io" target="_blank">source code</a>)<br/>
</div>
</body>
</html>