1
/* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
2
*******************************************************************************
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
* Copyright create3000, Scheffelstraße 31a, Leipzig, Germany 2011.
8
* All rights reserved. Holger Seelig <holger.seelig@yahoo.de>.
10
* The copyright notice above does not evidence any actual of intended
11
* publication of such source code, and is an unpublished work by create3000.
12
* This material contains CONFIDENTIAL INFORMATION that is the property of
15
* No permission is granted to copy, distribute, or create derivative works from
16
* the contents of this software, in whole or in part, without the prior written
17
* permission of create3000.
19
* NON-MILITARY USE ONLY
21
* All create3000 software are effectively free software with a non-military use
22
* restriction. It is free. Well commented source is provided. You may reuse the
23
* source in any way you please with the exception anything that uses it must be
24
* marked to indicate is contains 'non-military use only' components.
26
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28
* Copyright 2015, 2016 Holger Seelig <holger.seelig@yahoo.de>.
30
* This file is part of the Cobweb Project.
32
* Cobweb is free software: you can redistribute it and/or modify it under the
33
* terms of the GNU General Public License version 3 only, as published by the
34
* Free Software Foundation.
36
* Cobweb is distributed in the hope that it will be useful, but WITHOUT ANY
37
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
38
* A PARTICULAR PURPOSE. See the GNU General Public License version 3 for more
39
* details (a copy is included in the LICENSE file that accompanied this code).
41
* You should have received a copy of the GNU General Public License version 3
42
* along with Cobweb. If not, see <http://www.gnu.org/licenses/gpl.html> for a
43
* copy of the GPLv3 License.
45
* For Silvio, Joy and Adi.
47
******************************************************************************/
53
"cobweb/Basic/X3DFieldDefinition",
54
"cobweb/Basic/FieldDefinitionArray",
55
"cobweb/Components/ParticleSystems/X3DParticleEmitterNode",
56
"cobweb/Bits/X3DConstants",
57
"standard/Math/Numbers/Vector3",
58
"standard/Math/Numbers/Rotation4",
64
X3DParticleEmitterNode,
71
function ConeEmitter (executionContext)
73
X3DParticleEmitterNode .call (this, executionContext);
75
this .addType (X3DConstants .ConeEmitter);
77
this .rotation = new Rotation4 (0, 0, 1, 0);
80
ConeEmitter .prototype = $.extend (Object .create (X3DParticleEmitterNode .prototype),
82
constructor: ConeEmitter,
83
fieldDefinitions: new FieldDefinitionArray ([
84
new X3DFieldDefinition (X3DConstants .inputOutput, "metadata", new Fields .SFNode ()),
85
new X3DFieldDefinition (X3DConstants .inputOutput, "position", new Fields .SFVec3f ()),
86
new X3DFieldDefinition (X3DConstants .inputOutput, "direction", new Fields .SFVec3f (0, 1, 0)),
87
new X3DFieldDefinition (X3DConstants .inputOutput, "angle", new Fields .SFFloat (0.7854)),
88
new X3DFieldDefinition (X3DConstants .inputOutput, "speed", new Fields .SFFloat ()),
89
new X3DFieldDefinition (X3DConstants .inputOutput, "variation", new Fields .SFFloat (0.25)),
90
new X3DFieldDefinition (X3DConstants .initializeOnly, "mass", new Fields .SFFloat ()),
91
new X3DFieldDefinition (X3DConstants .initializeOnly, "surfaceArea", new Fields .SFFloat ()),
93
getTypeName: function ()
97
getComponentName: function ()
99
return "ParticleSystems";
101
getContainerField: function ()
105
initialize: function ()
107
X3DParticleEmitterNode .prototype .initialize .call (this);
109
this .position_ .addInterest ("set_position__", this);
110
this .direction_ .addInterest ("set_direction__", this);
111
this .angle_ .addInterest ("set_angle__", this);
113
this .set_position__ ();
114
this .set_direction__ ();
115
this .set_angle__ ();
117
set_position__: function ()
119
this .position = this .position_ .getValue ()
121
set_direction__: function ()
123
var direction = this .direction_ .getValue ();
125
this .rotation .setFromToVec (Vector3 .zAxis, direction);
127
if (direction .equals (Vector3 .Zero))
128
this .getRandomVelocity = this .getSphericalRandomVelocity;
130
delete this .getRandomVelocity;
132
set_angle__: function ()
134
this .angle = this .angle_ .getValue ()
136
getRandomPosition: function (position)
138
return position .assign (this .position);
140
getRandomVelocity: function (velocity)
142
return this .rotation .multVecRot (this .getRandomNormalWithAngle (this .angle, velocity) .multiply (this .getRandomSpeed ()));