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/Basic/X3DBaseNode",
56
"cobweb/Bits/X3DConstants",
57
"cobweb/Browser/Core/PrimitiveQuality",
58
"cobweb/Browser/Core/TextureQuality",
71
function BrowserOptions (executionContext)
73
X3DBaseNode .call (this, executionContext);
75
this .addAlias ("AntiAliased", this .Antialiased_);
77
this .setAttributeSplashScreen ();
79
this .primitiveQuality = PrimitiveQuality .MEDIUM;
80
this .textureQuality = TextureQuality .MEDIUM;
83
BrowserOptions .prototype = $.extend (Object .create (X3DBaseNode .prototype),
85
constructor: BrowserOptions,
86
fieldDefinitions: new FieldDefinitionArray ([
87
new X3DFieldDefinition (X3DConstants .inputOutput, "SplashScreen", new Fields .SFBool (true)),
88
new X3DFieldDefinition (X3DConstants .inputOutput, "Dashboard", new Fields .SFBool (true)),
89
new X3DFieldDefinition (X3DConstants .inputOutput, "Rubberband", new Fields .SFBool (true)),
90
new X3DFieldDefinition (X3DConstants .inputOutput, "EnableInlineViewpoints", new Fields .SFBool (true)),
91
new X3DFieldDefinition (X3DConstants .inputOutput, "Antialiased", new Fields .SFBool (true)),
92
new X3DFieldDefinition (X3DConstants .inputOutput, "TextureQuality", new Fields .SFString ("MEDIUM")),
93
new X3DFieldDefinition (X3DConstants .inputOutput, "PrimitiveQuality", new Fields .SFString ("MEDIUM")),
94
new X3DFieldDefinition (X3DConstants .inputOutput, "QualityWhenMoving", new Fields .SFString ("MEDIUM")),
95
new X3DFieldDefinition (X3DConstants .inputOutput, "Shading", new Fields .SFString ("GOURAUD")),
96
new X3DFieldDefinition (X3DConstants .inputOutput, "MotionBlur", new Fields .SFBool ()),
97
new X3DFieldDefinition (X3DConstants .inputOutput, "Gravity", new Fields .SFFloat (9.80665)),
99
getTypeName: function ()
101
return "BrowserOptions";
103
getComponentName: function ()
107
getContainerField: function ()
109
return "browserOptions";
111
initialize: function ()
113
X3DBaseNode .prototype .initialize .call (this);
115
this .SplashScreen_ .addInterest ("set_splashScreen__", this);
116
this .Rubberband_ .addInterest ("set_rubberband__", this);
117
this .PrimitiveQuality_ .addInterest ("set_primitiveQuality__", this);
118
this .TextureQuality_ .addInterest ("set_textureQuality__", this);
119
this .Shading_ .addInterest ("set_shading__", this);
120
this .getBrowser () .shutdown () .addInterest ("configure", this);
124
configure: function ()
126
var fieldDefinitions = this .getFieldDefinitions ();
128
for (var i = 0; i < fieldDefinitions .length; ++ i)
131
fieldDefinition = fieldDefinitions [i],
132
field = this .getField (fieldDefinition .name);
134
if (this .getBrowser () .getDataStorage () ["BrowserOptions." + fieldDefinition .name] !== undefined)
137
if (! field .equals (fieldDefinition .value))
138
field .setValue (fieldDefinition .value);
142
rubberband = this .getBrowser () .getDataStorage () ["BrowserOptions.Rubberband"],
143
primitiveQuality = this .getBrowser () .getDataStorage () ["BrowserOptions.PrimitiveQuality"],
144
textureQuality = this .getBrowser () .getDataStorage () ["BrowserOptions.TextureQuality"];
146
this .setAttributeSplashScreen ();
148
if (rubberband !== undefined && rubberband !== this .Rubberband_ .getValue ()) this .Rubberband_ = rubberband;
149
if (primitiveQuality !== undefined && primitiveQuality !== this .PrimitiveQuality_ .getValue ()) this .PrimitiveQuality_ = primitiveQuality;
150
if (textureQuality !== undefined && textureQuality !== this .TextureQuality_ .getValue ()) this .TextureQuality_ = textureQuality;
152
setAttributeSplashScreen: function ()
154
this .SplashScreen_ .set (this .getSplashScreen ());
156
getSplashScreen: function ()
158
return this .getBrowser () .getElement () .attr ("splashScreen") !== "false";
160
getNotifications: function ()
162
return this .getBrowser () .getElement () .attr ("notifications") !== "false";
164
getTimings: function ()
166
return this .getBrowser () .getElement () .attr ("timings") !== "false";
168
getContextMenu: function ()
170
return this .getBrowser () .getElement () .attr ("contextMenu") !== "false";
172
getCache: function ()
174
return this .getBrowser () .getElement () .attr ("cache") !== "false";
176
getPrimitiveQuality: function ()
178
return this .primitiveQuality;
180
getTextureQuality: function ()
182
return this .textureQuality;
184
getShading: function ()
186
return this .Shading_ .getValue ();
188
set_splashScreen__: function (splashScreen)
190
this .getBrowser () .getElement () .attr ("splashScreen", splashScreen .getValue () ? "true" : "false");
192
set_rubberband__: function (rubberband)
194
this .getBrowser () .getDataStorage () ["BrowserOptions.Rubberband"] = rubberband .getValue ();
196
set_primitiveQuality__: function (primitiveQuality)
198
this .getBrowser () .getDataStorage () ["BrowserOptions.PrimitiveQuality"] = primitiveQuality .getValue ();
201
arc = this .getBrowser () .getArc2DOptions (),
202
arcClose = this .getBrowser () .getArcClose2DOptions (),
203
circle = this .getBrowser () .getCircle2DOptions (),
204
disk = this .getBrowser () .getDisk2DOptions (),
205
cone = this .getBrowser () .getConeOptions (),
206
cylinder = this .getBrowser () .getCylinderOptions (),
207
sphere = this .getBrowser () .getSphereOptions ();
209
switch (primitiveQuality .getValue ())
213
this .primitiveQuality = PrimitiveQuality .LOW;
215
arc .dimension_ = 20;
216
arcClose .dimension_ = 20;
217
circle .dimension_ = 20;
218
disk .dimension_ = 20;
220
cone .xDimension_ = 16;
221
cylinder .xDimension_ = 16;
223
sphere .xDimension_ = 20;
224
sphere .yDimension_ = 9;
229
this .primitiveQuality = PrimitiveQuality .HIGH;
231
arc .dimension_ = 80;
232
arcClose .dimension_ = 80;
233
circle .dimension_ = 80;
234
disk .dimension_ = 80;
236
cone .xDimension_ = 32;
237
cylinder .xDimension_ = 32;
239
sphere .xDimension_ = 64;
240
sphere .yDimension_ = 31;
245
this .primitiveQuality = PrimitiveQuality .MEDIUM;
247
arc .dimension_ = 40;
248
arcClose .dimension_ = 40;
249
circle .dimension_ = 40;
250
disk .dimension_ = 40;
252
cone .xDimension_ = 20;
253
cylinder .xDimension_ = 20;
255
sphere .xDimension_ = 32;
256
sphere .yDimension_ = 15;
261
set_textureQuality__: function (textureQuality)
263
this .getBrowser () .getDataStorage () ["BrowserOptions.TextureQuality"] = textureQuality .getValue ();
265
var textureProperties = this .getBrowser () .getDefaultTextureProperties ();
267
switch (textureQuality .getValue ())
271
this .textureQuality = TextureQuality .LOW;
273
textureProperties .magnificationFilter_ = "AVG_PIXEL";
274
textureProperties .minificationFilter_ = "AVG_PIXEL";
275
textureProperties .textureCompression_ = "FASTEST";
276
textureProperties .generateMipMaps_ = true;
278
//glHint (GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
279
//glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
284
this .textureQuality = TextureQuality .HIGH;
286
textureProperties .magnificationFilter_ = "NICEST";
287
textureProperties .minificationFilter_ = "NICEST";
288
textureProperties .textureCompression_ = "NICEST";
289
textureProperties .generateMipMaps_ = true;
291
//glHint (GL_GENERATE_MIPMAP_HINT, GL_NICEST);
292
//glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
297
this .textureQuality = TextureQuality .MEDIUM;
299
textureProperties .magnificationFilter_ = "NICEST";
300
textureProperties .minificationFilter_ = "AVG_PIXEL_AVG_MIPMAP";
301
textureProperties .textureCompression_ = "NICEST";
302
textureProperties .generateMipMaps_ = true;
304
//glHint (GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
305
//glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
310
set_shading__: function (shading)
312
this .getBrowser () .setShading (shading .getValue ());
316
return BrowserOptions;