-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
325 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Particle Rotation</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" type="text/css" href="/style/reset.css" /> | ||
<link rel="stylesheet" type="text/css" href="/style/app.css" /> | ||
</head> | ||
|
||
<body> | ||
<div id="app"> | ||
<canvas id="canvas"></canvas> | ||
</div> | ||
|
||
<script src="https://unpkg.com/three@0.122.0/build/three.js"></script> | ||
<script src="https://unpkg.com/three@0.122.0/examples/js/controls/OrbitControls.js"></script> | ||
<script src="https://unpkg.com/stats-js@1.0.1/build/stats.min.js"></script> | ||
<script src="/common/three-nebula.js"></script> | ||
<script src="/common/Visualization.js"></script> | ||
<script src="/common/safeLog.js"></script> | ||
<script src="/common/run.js"></script> | ||
<script src="/experiments/particle-rotation/data.js"></script> | ||
<script src="/experiments/particle-rotation/index.js"></script> | ||
<script> | ||
run(init).then(() => console.log(`APP LOADED`)); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { System, SpriteRenderer, GPURenderer } = window.Nebula; | ||
|
||
window.init = async ({ scene, camera, renderer }) => { | ||
const { particleSystemState } = window.SYSTEM; | ||
const spriteRenderer = new SpriteRenderer(scene, THREE); | ||
const pointsRenderer = new GPURenderer(scene, THREE); | ||
const systemRenderer = pointsRenderer; | ||
const system = await System.fromJSONAsync(particleSystemState, THREE); | ||
|
||
return system.addRenderer(systemRenderer); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Vector3 } from '../core/three'; | ||
import Initializer from './Initializer'; | ||
import { INITIALIZER_TYPE_ROTATION as type } from './types'; | ||
|
||
/** | ||
* Sets the rotation property on initialized particles. | ||
* | ||
*/ | ||
export default class Rotation extends Initializer { | ||
/** | ||
* Constructs a Rotation property instance. | ||
* | ||
* @param {number} x - X axis rotation | ||
* @param {number} y - Y axis rotation | ||
* @param {number} z - Z axis rotation | ||
* @param {boolean} [useEmitterRotation=true] - Determines if we should use the emitter's rotation as the starting rotation | ||
* @param {boolean} [isEnabled=true] - Determines if the initializer should be enabled or not | ||
* @return void | ||
*/ | ||
constructor(x, y, z, useEmitterRotation=true, isEnabled = true) { | ||
super(type, isEnabled); | ||
this.rotation = new Vector3(x,y,z); | ||
this.useEmitterRotation = useEmitterRotation; | ||
} | ||
|
||
/** | ||
* Sets the particle's initial rotation. | ||
* | ||
* @param {Particle} particle - the particle to initialize the property on | ||
* @return void | ||
*/ | ||
initialize(particle) { | ||
if(this.useEmitterRotation) | ||
{ | ||
// set initial particle rotation to that of the particle's emitter then add our set rotation | ||
particle.rotation.copy(particle.parent.rotation).add(this.rotation); | ||
} | ||
else | ||
{ | ||
particle.rotation.copy(this.rotation); | ||
} | ||
} | ||
|
||
static fromJSON(json) { | ||
const { x, y, z, useEmitterRotation = true, isEnabled = true } = json; | ||
|
||
return new Rotation(x, y, z, useEmitterRotation, isEnabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.