Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Systems #5212

Merged
merged 116 commits into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
6103848
Work on resurrecting the particle branch
jasonbeverage Mar 2, 2017
dccaaeb
Changed the way particle lifetime works so there is a separate age an…
jasonbeverage Mar 2, 2017
b69ecc6
Added particle system sandcastle and PointEmitter
jasonbeverage Mar 2, 2017
58c41ca
Making sure dt is sensible in ParticleSystem
jasonbeverage Mar 2, 2017
994fe50
Animated entity in sandcastle example
jasonbeverage Mar 2, 2017
1c07d77
Tweaking particle system demo
jasonbeverage Mar 3, 2017
0245f40
Added ability to create a class based force
jasonbeverage Mar 3, 2017
9644b85
Reworked the way the emitter works so it can use a constant rate
jasonbeverage Mar 3, 2017
eaf1cbd
Added a burst option to the emitter
jasonbeverage Mar 3, 2017
8184286
Playing with the concept of a placer
jasonbeverage Mar 3, 2017
adc2cc7
Added BoxPlacer and SpherePlacer
jasonbeverage Mar 3, 2017
0d5b5b6
Corrected SpherePlacer to be centered around the position correctly
jasonbeverage Mar 7, 2017
867c69c
Playing with fire!
jasonbeverage Mar 7, 2017
2297924
Making sure normalizedAge is always 0.0 for particles with infinite life
jasonbeverage Mar 7, 2017
1876ad6
Color interpolation
jasonbeverage Mar 7, 2017
4555cfb
Fire on the engine
jasonbeverage Mar 7, 2017
1840d19
Adjusting scale based on age. New startScale, endScale attributes
jasonbeverage Mar 7, 2017
917c78a
Missing files
jasonbeverage Mar 7, 2017
80ad97a
Simplifying the point emitter to not require the initialDirection to …
jasonbeverage Mar 7, 2017
fb4affd
Added a lifetime option to the PointEmitter
jasonbeverage Mar 7, 2017
7b475ac
Added complete event to PointEmitter
jasonbeverage Mar 7, 2017
a2ec79b
Made it so particle systems can have multiple emitters
jasonbeverage Mar 7, 2017
2f11ce0
Simplify particle system emitter/modelmatrix relation
jasonbeverage Mar 7, 2017
ddb464f
Exploding plane and changed properties around
jasonbeverage Mar 7, 2017
f6baa2a
Changing around the way you set the speed to not use a variance but i…
jasonbeverage Mar 8, 2017
00406de
Changed the way life is initialized
jasonbeverage Mar 8, 2017
034a4f3
Added ConePlacer and changed around the PointEmitter to correctly pos…
jasonbeverage Mar 9, 2017
d165f45
Moving back to a single emitter per system.
jasonbeverage Mar 9, 2017
2ecfa59
Reworking properties
jasonbeverage Mar 9, 2017
617c317
Moved mass to ParticleSystem
jasonbeverage Mar 9, 2017
f64422f
More reorganization
jasonbeverage Mar 9, 2017
d2959ba
Moved logic into ParticleSystem
jasonbeverage Mar 9, 2017
64be343
Removed unused code
jasonbeverage Mar 9, 2017
fbc3ffc
Reworked Placers to be Emitters
jasonbeverage Mar 9, 2017
6720615
Made emitters return a Particle instead of taking one as an input
jasonbeverage Mar 9, 2017
98b1601
Added looping to particle system
jasonbeverage Mar 9, 2017
e52c608
Sprucing up particle demo
jasonbeverage Mar 9, 2017
de432ab
Made it so emitters have their own model matrix that can be manipulat…
jasonbeverage Mar 10, 2017
fc0493d
Removed local positions in favor of using the emitterModelMatrix
jasonbeverage Mar 10, 2017
c2996a2
Spinning emitter = more awesome
jasonbeverage Mar 10, 2017
431ef2d
Changing particle size
jasonbeverage Mar 10, 2017
982fd09
Fixed velocity of Box and Sphere emitters
jasonbeverage Mar 10, 2017
4f5279b
Choosing emitter type in sandcastle example
jasonbeverage Mar 10, 2017
72d8a5c
Added option to make the model fly in particle system demo
jasonbeverage Mar 10, 2017
f34760f
Increased radius of box and sphere emitters
jasonbeverage Mar 10, 2017
64f782f
Updated particle system screen shot
jasonbeverage Mar 10, 2017
72bb6d7
Merge branch 'master' into particles
jasonbeverage Apr 13, 2017
2185bb4
Work on integrating particle system with entity framework
jasonbeverage Apr 14, 2017
4bd4cc4
Made it so particle system demo uses entity framework
jasonbeverage Apr 14, 2017
54962e8
Merge branch 'master' into particles
jasonbeverage Apr 14, 2017
7a6b1d4
Revert bad commit
jasonbeverage Apr 14, 2017
8de7a3b
docs
jasonbeverage Apr 14, 2017
ebc1427
Work on being able to toggle show on a particle system
jasonbeverage Apr 17, 2017
c05f581
Added force support to the particle system in the entity framework
jasonbeverage Apr 17, 2017
1a33efb
Fix width and height properties in example
jasonbeverage Apr 17, 2017
251bb1c
Formatting ParticleSystem sandcastle example
jasonbeverage May 9, 2017
f76b890
min to minimum and max to maximum in particle systems
jasonbeverage May 9, 2017
e5e0998
Floating point values in particle system example instead of int
jasonbeverage May 9, 2017
dcacd47
null to undefined in particle system example
jasonbeverage May 9, 2017
a475545
Typo
jasonbeverage May 9, 2017
3fc0e0b
Describing units in ParticleSystemGraphics
jasonbeverage May 9, 2017
c980b70
Units
jasonbeverage May 9, 2017
9821d5e
Particle system docs
jasonbeverage May 9, 2017
e372fa0
Simplified return of Particle.update
jasonbeverage May 9, 2017
acd31e7
Removed unnecessary use of defaultValue in ParticleSystem constructor
jasonbeverage May 9, 2017
388f2d3
Using Cesium.lerp instead of manual lerping
jasonbeverage May 9, 2017
879e610
Commenting ParticleSystem and made some functions local functions ins…
jasonbeverage May 9, 2017
223ec9c
Recording bursts.length outside of the loop
jasonbeverage May 9, 2017
d16ab77
Remove unnecessary semicolon
jasonbeverage May 9, 2017
001d92c
Formatting
jasonbeverage May 10, 2017
2fb8637
Not calling defaultValue for options.image in Particle
jasonbeverage May 10, 2017
ac6d4e0
Scratch var in Particle.update
jasonbeverage May 10, 2017
5a46750
Fixed comment in ParticleSystemGraphics
jasonbeverage May 10, 2017
0a36b48
Fixed emitter constructors
jasonbeverage May 10, 2017
bbb128d
Added new randomBetween function to CesiumMath and using it in partic…
jasonbeverage May 10, 2017
8a8626c
Scratch variables in ParticleSystem
jasonbeverage May 10, 2017
7e2a965
Recording burstLength outside of loop when resetting bursts
jasonbeverage May 10, 2017
788d422
unnecessary semicolons
jasonbeverage May 10, 2017
47c7a6d
Changed signature of particle emitter to take an existing particle in…
jasonbeverage May 10, 2017
76d6ccf
Added ParticleEmitter interface class
jasonbeverage May 10, 2017
5b95fa2
Documenting particle emitters
jasonbeverage May 10, 2017
f2b0a7b
Not cloning colors in particle constructors
jasonbeverage May 10, 2017
319b9ce
Added a particlePool to the ParticleSystem class to limit allocations…
jasonbeverage May 10, 2017
de1dbcf
Checking for undefined bursts variable
jasonbeverage Jun 1, 2017
b49f8cd
Checking for undefined forces
jasonbeverage Jun 1, 2017
ae54804
Fixed looping
jasonbeverage Jun 1, 2017
5be6977
Fixed typo for forcesSubscription
jasonbeverage Jun 6, 2017
d0d71b6
Add/update doc, minor cleanup for ParticleSystem.
bagnell Jun 15, 2017
501abf5
Merge remote-tracking branch 'upstream/master' into particlesystem
bagnell Jun 15, 2017
8abd935
Add doc to Particle and make some properties private.
bagnell Jun 15, 2017
4789ff1
Add type for particle bursts.
bagnell Jun 15, 2017
5fd4e4d
Reduce garbage generated from emitters and more doc updates.
bagnell Jun 15, 2017
fda2fdb
Move some emitter properties to getter/setters and check for errors.
bagnell Jun 15, 2017
b4806bb
Fixes after last commit.
bagnell Jun 15, 2017
4eeb893
More doc updates.
bagnell Jun 15, 2017
e91de94
Fix missing require.
bagnell Jun 15, 2017
985498e
Merge remote-tracking branch 'upstream/master' into particlesystem
bagnell Jun 19, 2017
5d4d333
Change to fire image created by @rahwang.
bagnell Jun 19, 2017
d37d322
Add particle system tests.
bagnell Jun 20, 2017
def17e1
Remove particle datasource support for now. See particles-datasource …
bagnell Jun 20, 2017
e3af3ea
Fix eslint errors.
bagnell Jun 20, 2017
b17adcf
More eslint fixes.
bagnell Jun 20, 2017
08bd544
Check for invalid values when setting properties and update tests.
bagnell Jun 20, 2017
baddc32
Free particles from the pool.
bagnell Jun 20, 2017
ec341c6
Update CHANGES.md.
bagnell Jun 20, 2017
cd4ffd8
Add new particle system demo.
bagnell Jun 20, 2017
41390b9
Fix issue with increased clock speed or when scrubbing the timeline.
bagnell Jun 21, 2017
116d515
Add new Sandcastle example.
bagnell Jun 21, 2017
ce18cf8
Better fire from @rahwang.
bagnell Jun 21, 2017
f8de4ea
Update colors in Sandcastle example.
bagnell Jun 21, 2017
129772f
Give each system its own pool of particles.
bagnell Jun 21, 2017
95fc96f
Add better memory management.
bagnell Jun 21, 2017
0e44fbd
Merge remote-tracking branch 'upstream/master' into particlesystem
bagnell Jun 21, 2017
70c191e
Tweak CHANGES.md
pjcozzi Jun 21, 2017
ec59d9f
Resize fire image.
bagnell Jun 21, 2017
2e5e510
Fix Sandcastle show option.
bagnell Jun 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Apps/SampleData/fire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
174 changes: 174 additions & 0 deletions Apps/Sandcastle/gallery/Particle System Fireworks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Particle system fireworks.">
<meta name="cesium-sandcastle-labels" content="Beginner, Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

var scene = viewer.scene;
scene.debugShowFramesPerSecond = true;

Cesium.Math.setRandomNumberSeed(315);

var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883));
var emitterInitialLocation = new Cesium.Cartesian3(0.0, 0.0, 100.0);

var particleCanvas;

function getImage() {
if (!Cesium.defined(particleCanvas)) {
particleCanvas = document.createElement('canvas');
particleCanvas.width = 20;
particleCanvas.height = 20;
var context2D = particleCanvas.getContext('2d');
context2D.beginPath();
context2D.arc(8, 8, 8, 0, Cesium.Math.TWO_PI, true);
context2D.closePath();
context2D.fillStyle = 'rgb(255, 255, 255)';
context2D.fill();
}
return particleCanvas;
}

var minimumExplosionSize = 30.0;
var maximumExplosionSize = 100.0;
var particlePixelSize = 7.0;
var burstSize = 400.0;
var lifetime = 10.0;
var numberOfFireworks = 20.0;

var emitterModelMatrixScratch = new Cesium.Matrix4();

function createFirework(offset, color, bursts) {
var position = Cesium.Cartesian3.add(emitterInitialLocation, offset, new Cesium.Cartesian3());
var emitterModelMatrix = Cesium.Matrix4.fromTranslation(position, emitterModelMatrixScratch);
var particleToWorld = Cesium.Matrix4.multiply(modelMatrix, emitterModelMatrix, new Cesium.Matrix4());
var worldToParticle = Cesium.Matrix4.inverseTransformation(particleToWorld, particleToWorld);

var size = Cesium.Math.randomBetween(minimumExplosionSize, maximumExplosionSize);
var particlePositionScratch = new Cesium.Cartesian3();
var force = function(particle) {
var position = Cesium.Matrix4.multiplyByPoint(worldToParticle, particle.position, particlePositionScratch);
if (Cesium.Cartesian3.magnitudeSquared(position) >= size * size) {
Cesium.Cartesian3.clone(Cesium.Cartesian3.ZERO, particle.velocity);
}
};

var normalSize = (size - minimumExplosionSize) / (maximumExplosionSize - minimumExplosionSize);
var minLife = 0.3;
var maxLife = 1.0;
var life = normalSize * (maxLife - minLife) + minLife;

scene.primitives.add(new Cesium.ParticleSystem({
image : getImage(),
startColor : color,
endColor : color.withAlpha(0.0),
life : life,
speed : 100.0,
width : particlePixelSize,
height : particlePixelSize,
rate : 0,
emitter : new Cesium.SphereEmitter(0.1),
bursts : bursts,
lifeTime : lifetime,
forces : [force],
modelMatrix : modelMatrix,
emitterModelMatrix : emitterModelMatrix
}));
}

var xMin = -100.0;
var xMax = 100.0;
var yMin = -80.0;
var yMax = 100.0;
var zMin = -50.0;
var zMax = 50.0;

var colorOptions = [{
minimumRed : 0.75,
green : 0.0,
minimumBlue : 0.8,
alpha : 1.0
}, {
red : 0.0,
minimumGreen : 0.75,
minimumBlue : 0.8,
alpha : 1.0
}, {
red : 0.0,
green : 0.0,
minimumBlue : 0.8,
alpha : 1.0
}, {
minimumRed : 0.75,
minimumGreen : 0.75,
blue : 0.0,
alpha : 1.0
}];

for (var i = 0; i < numberOfFireworks; ++i) {
var x = Cesium.Math.randomBetween(xMin, xMax);
var y = Cesium.Math.randomBetween(yMin, yMax);
var z = Cesium.Math.randomBetween(zMin, zMax);
var offset = new Cesium.Cartesian3(x, y, z);
var color = Cesium.Color.fromRandom(colorOptions[i % colorOptions.length]);

var bursts = [];
for (var j = 0; j < 3; ++j) {
bursts.push(new Cesium.ParticleBurst({
time : Cesium.Math.nextRandomNumber() * lifetime,
minimum : burstSize,
maximum : burstSize
}));
}

createFirework(offset, color, bursts);
}

var camera = viewer.scene.camera;
var cameraOffset = new Cesium.Cartesian3(-300.0, 0.0, 0.0);
camera.lookAtTransform(modelMatrix, cameraOffset);
camera.lookAtTransform(Cesium.Matrix4.IDENTITY);

var toFireworks = Cesium.Cartesian3.subtract(emitterInitialLocation, cameraOffset, new Cesium.Cartesian3());
Cesium.Cartesian3.normalize(toFireworks, toFireworks);
var angle = Cesium.Math.PI_OVER_TWO - Math.acos(Cesium.Cartesian3.dot(toFireworks, Cesium.Cartesian3.UNIT_Z));
camera.lookUp(angle);

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>

</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading