-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscenejs.min.js
772 lines (772 loc) · 379 KB
/
scenejs.min.js
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
/*
* SceneJS WebGL Scene Graph Library for JavaScript
* http://scenejs.org/
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://scenejs.org/license
* Copyright 2010, Lindsay Kay
*
* Includes WebGLTrace
* Various functions for helping debug WebGL apps.
* http://github.com/jackpal/webgltrace
* Copyright (c) 2009 The Chromium Authors. All rights reserved.
*
* Includes WebGL-Debug
* Various functions for helping debug WebGL apps.
* http://khronos.org/webgl/wiki/Debugging
* Copyright (c) 2009 The Chromium Authors. All rights reserved.
*/
var SceneJS={VERSION:"0.7.9.0",SUPPORTED_WEBGL_CONTEXT_NAMES:["experimental-webgl","webkit-3d","moz-webgl","moz-glweb20"],createNodeType:function(type,superType){if(!type){throw"createNodeType param 'type' is null or undefined";}if(typeof type!="string"){throw"createNodeType param 'type' should be a string";
}var supa=this._nodeTypes[superType||"node"];if(!supa){throw"undefined superType: '"+superType+"'";}var nodeType=function(){supa.nodeClass.apply(this,arguments);this._attr.nodeType=type;};SceneJS._inherit(nodeType,supa.nodeClass);var nodeFunc=function(){var n=new nodeType();nodeType.prototype.constructor.apply(n,arguments);
n._attr.nodeType=type;return n;};this._registerNode(type,nodeType,nodeFunc);SceneJS[type]=nodeFunc;return nodeType;},_registerNode:function(type,nodeClass,nodeFunc){this._nodeTypes[type]={nodeClass:nodeClass,nodeFunc:nodeFunc};},createNode:function(json){if(!json){throw"createNode param 'json' is null or undefined";
}var newNode=this._parseNodeJSON(json);SceneJS._eventModule.fireEvent(SceneJS._eventModule.NODE_CREATED,{nodeId:newNode.getID(),json:json});return SceneJS.withNode(newNode);},_parseNodeJSON:function(json){json.type=json.type||"node";var nodeType=this._nodeTypes[json.type];if(!nodeType){throw"Failed to parse JSON node definition - unknown node type: '"+json.type+"'";
}var newNode=new nodeType.nodeClass(this._copyCfg(json));if(json.nodes){var len=json.nodes.length;for(var i=0;i<len;i++){newNode.addNode(SceneJS._parseNodeJSON(json.nodes[i]));}}return newNode;},_copyCfg:function(cfg){var cfg2={};for(var key in cfg){if(cfg.hasOwnProperty(key)&&key!="nodes"){cfg2[key]=cfg[key];
}}return cfg2;},_scheduleNodeDestroy:function(node){this._destroyedNodes.push(node);},_destroyedNodes:[],_actionNodeDestroys:function(){var node;for(var i=this._destroyedNodes.length-1;i>=0;i--){node=this._destroyedNodes[i];node._doDestroy();SceneJS._eventModule.fireEvent(SceneJS._eventModule.NODE_CREATED,{nodeId:node.getID()});
}this._destroyedNodes=[];},_nodeTypes:{},_nodeIDMap:{},_nodeInstanceMap:{},nodeExists:function(id){if(!id){throw"nodeExists param 'id' null or undefined";}if(typeof id!="string"){throw"nodeExists param 'id' not a string";}var node=SceneJS._nodeIDMap[id];return(node!=undefined&&node!=null);},Message:new (function(){this.sendMessage=function(message){if(!message){throw"sendMessage param 'message' null or undefined";
}var commandId=message.command;if(!commandId){throw"Message element expected: 'command'";}var commandService=SceneJS.Services.getService(SceneJS.Services.COMMAND_SERVICE_ID);var command=commandService.getCommand(commandId);if(!command){throw"Message command not supported: '"+commandId+"' - perhaps this command needs to be added to the SceneJS Command Service?";
}command.execute(message);};})(),_needFrame:true,_traversalMode:1,_TRAVERSAL_MODE_RENDER:1,_TRAVERSAL_MODE_PICKING:2,_inherit:function(DerivedClassName,BaseClassName){DerivedClassName.prototype=new BaseClassName();DerivedClassName.prototype.constructor=DerivedClassName;},_namespace:function(){var a=arguments,o=null,i,j,d,rt;
for(i=0;i<a.length;++i){d=a[i].split(".");rt=d[0];eval("if (typeof "+rt+' == "undefined"){'+rt+" = {};} o = "+rt+";");for(j=1;j<d.length;++j){o[d[j]]=o[d[j]]||{};o=o[d[j]];}}},_createKeyForMap:function(keyMap,prefix){var i=0;while(true){var key=prefix+i++;if(!keyMap[key]){return key;}}},_applyIf:function(o1,o2){for(var key in o2){if(!o1[key]){o1[key]=o2[key];
}}return o1;},_getBaseURL:function(url){var i=url.lastIndexOf("/");if(i==0||i==-1){return"";}return url.substr(0,i+1);},_isArray:function(testObject){return testObject&&!(testObject.propertyIsEnumerable("length"))&&typeof testObject==="object"&&typeof testObject.length==="number";},_shallowClone:function(o){var o2={};
for(var name in o){if(o.hasOwnProperty(name)){o2[name]=o[name];}}return o2;}};SceneJS._namespace("SceneJS");window["SceneJS"]=SceneJS;SceneJS.Services=new (function(){this.NODE_LOADER_SERVICE_ID="node-loader";this.COMMAND_SERVICE_ID="command";this._services={};this.addService=function(name,service){this._services[name]=service;
};this.hasService=function(name){var service=this._services[name];return(service!=null&&service!=undefined);};this.getService=function(name){return this._services[name];};this.addService(this.NODE_LOADER_SERVICE_ID,{loadNode:function(nodeId){}});})();SceneJS.withNode=function(node){return new SceneJS._WithNode(node);
};SceneJS._WithNode=function(node){if(!node){throw"withNode param 'node' is null or undefined";}this._targetNode=node._render?node:SceneJS._nodeIDMap[node];if(!this._targetNode){throw"withNode node not found: '"+node+"'";}};SceneJS._WithNode.prototype.parent=function(){var parent=this._targetNode.getParent();
if(!parent){return null;}return new SceneJS._WithNode(parent);};SceneJS._WithNode.prototype.node=function(node){if(node===null||typeof(node)==="undefined"){throw"node param 'node' is null or undefined";}var type=typeof node;var nodeGot;if(type=="number"){nodeGot=this._targetNode.getNodeAt(node);}else{if(type=="string"){nodeGot=this._targetNode.getNode(node);
}else{throw"node param 'node' should be either an index number or an ID string";}}if(!nodeGot){throw"node not found: '"+node+"'";}return new SceneJS._WithNode(nodeGot);};SceneJS._WithNode.prototype.hasNode=function(node){if(!node===null||typeof(node)==="undefined"){throw"hasNode param 'node' is null or undefined";
}var type=typeof node;var nodeGot;if(type=="number"){nodeGot=this._targetNode.getNodeAt(node);}else{if(type=="string"){nodeGot=this._targetNode.getNode(node);}else{throw"hasNode param 'node' should be either an index number or an ID string";}}return(nodeGot!=undefined&&nodeGot!=null);};SceneJS._WithNode.prototype.eachParent=function(fn){if(!fn){throw"eachParent param 'fn' is null or undefined";
}var selector;var count=0;var node=this._targetNode;while(node._parent){selector=new SceneJS._WithNode(node._parent);if(fn.call(selector,count++)===true){return selector;}node=node._parent;}return undefined;};SceneJS._WithNode.prototype.eachNode=function(fn,options){if(!fn){throw"eachNode param 'fn' is null or undefined";
}if(typeof fn!="function"){throw"eachNode param 'fn' should be a function";}var stoppedNode;options=options||{};var count=0;if(options.andSelf){if(fn.call(this,count++)===true){return this;}}if(!options.depthFirst&&!options.breadthFirst){stoppedNode=this._iterateEachNode(fn,this._targetNode,count);}else{if(options.depthFirst){stoppedNode=this._iterateEachNodeDepthFirst(fn,this._targetNode,count,false);
}else{}}if(stoppedNode){return stoppedNode;}return undefined;};SceneJS._WithNode.prototype.numNodes=function(){return this._targetNode._children.length;};SceneJS._WithNode.prototype.eachInstance=function(fn){if(!fn){throw"eachInstance param 'fn' is null or undefined";}if(typeof fn!="function"){throw"eachInstance param 'fn' should be a function";
}var nodeInstances=SceneJS._nodeInstanceMap[this._targetNode._attr.id];if(nodeInstances){var instances=nodeInstances.instances;var count=0;var selector;for(var instanceNodeId in instances){if(instances.hasOwnProperty(instanceNodeId)){selector=new SceneJS._WithNode(instanceNodeId);if(fn.call(selector,count++)===true){return selector;
}}}}return undefined;};SceneJS._WithNode.prototype.numInstances=function(){var instances=SceneJS._nodeInstanceMap[this._targetNode._attr.id];return instances?instances.numInstances:0;};SceneJS._WithNode.prototype.set=function(attr,value){if(!attr){throw"set param 'attr' null or undefined";}if(typeof attr=="string"){this._callNodeMethod("set",attr,value,this._targetNode);
}else{this._callNodeMethods("set",attr,this._targetNode);}return this;};SceneJS._WithNode.prototype.add=function(attr,value){if(!attr){throw"add param 'attr' null or undefined";}if(typeof attr=="string"){this._callNodeMethod("add",attr,value,this._targetNode);}else{this._callNodeMethods("add",attr,this._targetNode);
}return this;};SceneJS._WithNode.prototype.inc=function(attr,value){if(!attr){throw"inc param 'attr' null or undefined";}if(typeof attr=="string"){this._callNodeMethod("inc",attr,value,this._targetNode);}else{this._callNodeMethods("inc",attr,this._targetNode);}return this;};SceneJS._WithNode.prototype.insert=function(attr,value){if(!attr){throw"insert param 'attr' null or undefined";
}if(typeof attr=="string"){this._callNodeMethod("insert",attr,value,this._targetNode);}else{this._callNodeMethods("insert",attr,this._targetNode);}return this;};SceneJS._WithNode.prototype.remove=function(attr,value){if(!attr){throw"remove param 'attr' null or undefined";}if(typeof attr=="string"){this._callNodeMethod("remove",attr,value,this._targetNode);
}else{this._callNodeMethods("remove",attr,this._targetNode);}return this;};SceneJS._WithNode.prototype.get=function(attr){if(!attr){return this._targetNode.getJSON();}var funcName="get"+attr.substr(0,1).toUpperCase()+attr.substr(1);var func=this._targetNode[funcName];if(!func){throw"Attribute '"+attr+"' not found on node '"+this._targetNode.getID()+"'";
}return func.call(this._targetNode);};SceneJS._WithNode.prototype.query=function(attr){if(!this._targetNode._rendering){throw"Node is not rendering - cannot do render-time query for '"+attr+"' on node '"+this._targetNode.getID()+"'";}var funcName="query"+attr.substr(0,1).toUpperCase()+attr.substr(1);
var func=this._targetNode[funcName];if(!func){throw"Render-time query for '"+attr+"' not available on node '"+this._targetNode.getID()+"'";}return func.call(this._targetNode);};SceneJS._WithNode.prototype.bind=function(name,handler){if(!name){throw"bind param 'name' null or undefined";}if(typeof name!="string"){throw"bind param 'name' should be a string";
}if(!handler){throw"bind param 'handler' null or undefined";}if(typeof handler!="function"){throw"bind param 'handler' should be a function";}else{this._targetNode.addListener(name,handler,{scope:this});}return this;};SceneJS._WithNode.prototype.pick=function(offsetX,offsetY){if(!offsetX){throw"pick param 'offsetX' null or undefined";
}if(typeof offsetX!="number"){throw"pick param 'offsetX' should be a number";}if(!offsetY){throw"pick param 'offsetY' null or undefined";}if(typeof offsetY!="number"){throw"pick param 'offsetY' should be a number";}if(this._targetNode.getType()!="scene"){throw'pick attempted on node that is not a "scene" type: \''+this._targetNode.getID()+"'";
}this._targetNode.pick(offsetX,offsetY);return this;};SceneJS._WithNode.prototype.render=function(){if(this._targetNode.getType()!="scene"){throw'render attempted on node that is not a "scene" type: \''+this._targetNode.getID()+"'";}this._targetNode.render();return this;};SceneJS._WithNode.prototype.start=function(cfg){if(this._targetNode.getType()!="scene"){throw'start attempted on node that is not a "scene" type: \''+this._targetNode.getID()+"'";
}cfg=cfg||{};if(cfg.idleFunc){var fn=cfg.idleFunc;cfg.idleFunc=function(){fn(this);};}this._targetNode.start(cfg);return this;};SceneJS._WithNode.prototype.stop=function(){if(this._targetNode.getType()!="scene"){throw'stop attempted on node that is not a "scene" \''+this._targetNode.getID()+"'";}this._targetNode.stop();
return this;};SceneJS._WithNode.prototype.destroy=function(){if(this._targetNode.getType()!="scene"){throw'destroy attempted on node that is not a "scene" type: \''+this._targetNode.getID()+"'";}this._targetNode.destroy();return this;};SceneJS._WithNode.prototype.data=function(data,value){if(!data){return this._targetNode._attr.data;
}this._targetNode._attr.data=this._targetNode._attr.data||{};if(typeof data=="string"){if(value!=undefined){this._targetNode._attr.data[data]=value;return this;}else{return this._targetNode._attr.data[data];}}else{if(value!=undefined){this._targetNode._attr.data=value;return this;}else{return this._targetNode._attr.data;
}}};SceneJS._WithNode.prototype._iterateEachNode=function(fn,node,count){var len=node._children.length;var selector;for(var i=0;i<len;i++){selector=new SceneJS._WithNode(node._children[i]);if(fn.call(selector,count++)==true){return selector;}}return undefined;};SceneJS._WithNode.prototype._iterateEachNodeDepthFirst=function(fn,node,count,belowRoot){var selector;
if(belowRoot){selector=new SceneJS._WithNode(node);if(fn.call(selector,count++)==true){return selector;}}belowRoot=true;var len=node._children.length;for(var i=0;i<len;i++){selector=this._iterateEachNodeDepthFirst(fn,node._children[i],count,belowRoot);if(selector){return selector;}}return undefined;};
SceneJS._WithNode.prototype._callNodeMethod=function(prefix,attr,value,targetNode){var funcName=prefix+attr.substr(0,1).toUpperCase()+attr.substr(1);var func=targetNode[funcName];if(!func){throw"Attribute '"+attr+"' not found on node '"+targetNode.getID()+"' for "+prefix;}func.call(targetNode,this._parseAttr(attr,value));
var params={};params[attr]=value;SceneJS._needFrame=true;targetNode._fireEvent("updated",params);};SceneJS._WithNode.prototype._callNodeMethods=function(prefix,attr,targetNode){for(var key in attr){if(attr.hasOwnProperty(key)){key=key.replace(/^\s*/,"").replace(/\s*$/,"");var funcName=prefix+key.substr(0,1).toUpperCase()+key.substr(1);
var func=targetNode[funcName];if(!func){throw"Attribute '"+key+"' not found on node '"+targetNode.getID()+"' for "+prefix;}func.call(targetNode,this._parseAttr(key,attr[key]));SceneJS._needFrame=true;}}SceneJS._needFrame=true;targetNode._fireEvent("updated",{attr:attr});};SceneJS._WithNode.prototype._parseAttr=function(attr,value){var tokens=attr.split(".");
if(tokens.length<=1){return value;}var obj={};var root=obj;var name;var i=0;var len=tokens.length-1;while(i<len){obj[tokens[i++]]=value;}obj=obj[name]={};return root;};SceneJS.Services.addService(SceneJS.Services.COMMAND_SERVICE_ID,(function(){var commands={};return{addCommand:function(commandId,command){if(!command.execute){throw"SceneJS Command Service (ID '"+SceneJS.Services.COMMAND_SERVICE_ID+") requires an 'execute' method on your '"+commandId+" command implementation";
}commands[commandId]=command;},hasCommand:function(commandId){var command=commands[commandId];return(command!=null&&command!=undefined);},getCommand:function(commandId){return commands[commandId];},executeCommand:function(params){if(!params){throw"sendMessage param 'message' null or undefined";}var commandId=params.command;
if(!commandId){throw"Message element expected: 'command'";}var commandService=SceneJS.Services.getService(SceneJS.Services.COMMAND_SERVICE_ID);var command=commandService.getCommand(commandId);if(!command){throw"Message command not supported: '"+commandId+"' - perhaps this command needs to be added to the SceneJS Command Service?";
}command.execute(params);}};})());SceneJS.Services.getService(SceneJS.Services.COMMAND_SERVICE_ID).addCommand("create",(function(){return{execute:function(params){var nodes=params.nodes;if(nodes){for(var i=0;i<nodes.length;i++){if(!nodes[i].id){throw"Message 'create' must have ID for new node";}SceneJS.createNode(nodes[i]);
}}}};})());(function(){var commandService=SceneJS.Services.getService(SceneJS.Services.COMMAND_SERVICE_ID);commandService.addCommand("update",{execute:function(params){var target=params.target;if(target){if(!SceneJS.nodeExists(target)){throw"Message 'update' target node not found: "+target;}var targetNode=SceneJS.withNode(target);
var sett=params["set"];if(sett){callNodeMethods("set",sett,targetNode);}if(params.insert){callNodeMethods("insert",params.insert,targetNode);}if(params.add){callNodeMethods("add",params.add,targetNode);}if(params.remove){callNodeMethods("remove",params.remove,targetNode);}}SceneJS._nodeIDMap[params.target]._fireEvent("updated",{});
var messages=params.messages;if(messages){for(var i=0;i<messages.length;i++){commandService.executeCommand(messages[i]);}}}});function callNodeMethods(prefix,attr,targetNode){for(var key in attr){if(attr.hasOwnProperty(key)){targetNode[prefix](attr);}}}})();SceneJS._debugModule=new (function(){this.configs={};
this.getConfigs=function(path){if(!path){return this.configs;}else{var cfg=this.configs;var parts=path.split(".");for(var i=0;cfg&&i<parts.length;i++){cfg=cfg[parts[i]];}return cfg||{};}};this.setConfigs=function(path,data){if(!path){this.configs=data;}else{var parts=path.split(".");var cfg=this.configs;
var subCfg;var name;for(var i=0;i<parts.length-1;i++){name=parts[i];subCfg=cfg[name];if(!subCfg){subCfg=cfg[name]={};}cfg=subCfg;}cfg[parts.length-1]=data;}};})();SceneJS.setDebugConfigs=function(){if(arguments.length==1){SceneJS._debugModule.setConfigs(null,arguments[0]);}else{if(arguments.length==2){SceneJS._debugModule.setConfigs(arguments[0],arguments[1]);
}else{throw"Illegal arguments given to SceneJS.setDebugs - should be either ({String}:name, {Object}:cfg) or ({Object}:cfg)";}}};SceneJS.getDebugConfigs=function(path){return SceneJS._debugModule.getConfigs(path);};SceneJS.errors={};SceneJS.errors.Exception=function(msg,cause){this.message="SceneJS.errors.Exception: "+msg;
this.cause=cause;};SceneJS.errors.WebGLNotSupportedException=function(msg,cause){this.message="SceneJS.errors.WebGLNotSupportedException: "+msg;this.cause=cause;};SceneJS.errors.NodeConfigExpectedException=function(msg,cause){this.message="SceneJS.errors.NodeConfigExpectedException: "+msg;this.cause=cause;
};SceneJS.errors.ShaderCompilationFailureException=function(msg,cause){this.message="SceneJS.errors.ShaderCompilationFailureException: "+msg;this.cause=cause;};SceneJS.errors.ShaderLinkFailureException=function(msg,cause){this.message="SceneJS.errors.ShaderLinkFailureException: "+msg;this.cause=cause;
};SceneJS.errors.NoSceneActiveException=function(msg,cause){this.message="SceneJS.errors.NoSceneActiveException: "+msg;this.cause=cause;};SceneJS.errors.NoCanvasActiveException=function(msg,cause){this.message="SceneJS.errors.NoCanvasActiveException: "+msg;this.cause=cause;};SceneJS.errors.CanvasNotFoundException=function(msg,cause){this.message="SceneJS.errors.CanvasNotFoundException: "+msg;
this.cause=cause;};SceneJS.errors.InvalidNodeConfigException=function(msg,cause){this.message="SceneJS.errors.InvalidNodeConfigException: "+msg;this.cause=cause;};SceneJS.errors.OutOfVRAMException=function(msg,cause){this.message="SceneJS.errors.OutOfVRAMException: "+msg;this.cause=cause;};SceneJS.errors.DocumentElementNotFoundException=function(msg,cause){this.message="SceneJS.errors.DocumentElementNotFoundException: "+msg;
this.cause=cause;};SceneJS.errors.WebGLUnsupportedNodeConfigException=function(msg,cause){this.message="SceneJS.errors.WebGLUnsupportedNodeConfigException: "+msg;this.cause=cause;};SceneJS.errors.PickWithoutRenderedException=function(msg,cause){this.message="SceneJS.errors.PickWithoutRenderedException: "+msg;
this.cause=cause;};SceneJS.errors.DataExpectedException=function(msg,cause){this.message="SceneJS.errors.DataExpectedException: "+msg;this.cause=cause;};SceneJS.errors.InternalException=function(msg,cause){this.message="SceneJS.errors.InternalException: "+msg;this.cause=cause;};SceneJS.errors.SymbolNotFoundException=function(msg,cause){this.message="SceneJS.errors.SymbolNotFoundException: "+msg;
this.cause=cause;};SceneJS.errors.CyclicInstanceException=function(msg,cause){this.message="SceneJS.errors.CyclicInstanceException: "+msg;this.cause=cause;};SceneJS.errors.InvalidSceneGraphException=function(msg,cause){this.message="SceneJS.errors.InvalidSceneGraphException: "+msg;this.cause=cause;};
SceneJS.errors.SocketNotSupportedException=function(msg,cause){this.message="SceneJS.errors.SocketNotSupportedException: "+msg;this.cause=cause;};SceneJS.errors.SocketErrorException=function(msg,cause){this.message="SceneJS.errors.SocketErrorException: "+msg;this.cause=cause;};SceneJS.errors.SocketServerErrorException=function(msg,cause){this.message="SceneJS.errors.SocketServerErrorException: "+msg;
this.cause=cause;};SceneJS.errors.WithConfigsNodeNotFoundException=function(msg,cause){this.message="SceneJS.errors.WithConfigsNodeNotFoundException: "+msg;this.cause=cause;};SceneJS.errors.WithConfigsPropertyNotFoundException=function(msg,cause){this.message="SceneJS.errors.WithConfigsPropertyNotFoundException: "+msg;
this.cause=cause;};SceneJS.errors.ModuleNotFoundException=function(msg,cause){this.message="SceneJS.errors.ModuleNotFoundException: "+msg;this.cause=cause;};SceneJS.errors.ModuleLoadTimeoutException=function(msg,cause){this.message="SceneJS.errors.ModuleLoadTimeoutException: "+msg;this.cause=cause;};
SceneJS.errors.ModuleInstallFailureException=function(msg,cause){this.message="SceneJS.errors.ModuleInstallFailureException: "+msg;this.cause=cause;};SceneJS._math_divVec3=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]/v[0];dest[1]=u[1]/v[1];dest[2]=u[2]/v[2];return dest;};SceneJS._math_negateVector4=function(v,dest){if(!dest){dest=v;
}dest[0]=-v[0];dest[1]=-v[1];dest[2]=-v[2];dest[3]=-v[3];return dest;};SceneJS._math_addVec4=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]+v[0];dest[1]=u[1]+v[1];dest[2]=u[2]+v[2];dest[3]=u[3]+v[3];return dest;};SceneJS._math_addVec4s=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]+s;dest[1]=v[1]+s;
dest[2]=v[2]+s;dest[3]=v[3]+s;return dest;};SceneJS._math_addVec3=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]+v[0];dest[1]=u[1]+v[1];dest[2]=u[2]+v[2];return dest;};SceneJS._math_addVec3s=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]+s;dest[1]=v[1]+s;dest[2]=v[2]+s;return dest;};SceneJS._math_addScalarVec4=function(s,v,dest){return SceneJS._math_addVec4s(v,s,dest);
};SceneJS._math_subVec4=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];dest[2]=u[2]-v[2];dest[3]=u[3]-v[3];return dest;};SceneJS._math_subVec3=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];dest[2]=u[2]-v[2];return dest;};SceneJS._math_lerpVec3=function(t,t1,t2,p1,p2){var f=(t-t1)/(t2-t1);
var p1x=p1.x,p1y=p1.y,p1z=p1.z;return{x:p1x+(f*p2.x-p1x),y:p1y+(f*p2.y-p1y),z:p1z+(f*p2.z-p1z)};};SceneJS._math_subVec2=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]-v[0];dest[1]=u[1]-v[1];return dest;};SceneJS._math_subVec4Scalar=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]-s;dest[1]=v[1]-s;
dest[2]=v[2]-s;dest[3]=v[3]-s;return dest;};SceneJS._math_subScalarVec4=function(v,s,dest){if(!dest){dest=v;}dest[0]=s-v[0];dest[1]=s-v[1];dest[2]=s-v[2];dest[3]=s-v[3];return dest;};SceneJS._math_mulVec4=function(u,v,dest){if(!dest){dest=u;}dest[0]=u[0]*v[0];dest[1]=u[1]*v[1];dest[2]=u[2]*v[2];dest[3]=u[3]*v[3];
return dest;};SceneJS._math_mulVec4Scalar=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]*s;dest[1]=v[1]*s;dest[2]=v[2]*s;dest[3]=v[3]*s;return dest;};SceneJS._math_mulVec3Scalar=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]*s;dest[1]=v[1]*s;dest[2]=v[2]*s;return dest;};SceneJS._math_divVec4=function(u,v,dest){if(!dest){dest=u;
}dest[0]=u[0]/v[0];dest[1]=u[1]/v[1];dest[2]=u[2]/v[2];dest[3]=u[3]/v[3];return dest;};SceneJS._math_divScalarVec3=function(s,v,dest){if(!dest){dest=v;}dest[0]=s/v[0];dest[1]=s/v[1];dest[2]=s/v[2];return dest;};SceneJS._math_divVec3s=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]/s;dest[1]=v[1]/s;
dest[2]=v[2]/s;return dest;};SceneJS._math_divVec4s=function(v,s,dest){if(!dest){dest=v;}dest[0]=v[0]/s;dest[1]=v[1]/s;dest[2]=v[2]/s;dest[3]=v[3]/s;return dest;};SceneJS._math_divScalarVec4=function(s,v,dest){if(!dest){dest=v;}dest[0]=s/v[0];dest[1]=s/v[1];dest[2]=s/v[2];dest[3]=s/v[3];return dest;};
SceneJS._math_dotVector4=function(u,v){return(u[0]*v[0]+u[1]*v[1]+u[2]*v[2]+u[3]*v[3]);};SceneJS._math_cross3Vec4=function(u,v){var u0=u[0],u1=u[1],u2=u[2];var v0=v[0],v1=v[1],v2=v[2];return[u1*v2-u2*v1,u2*v0-u0*v2,u0*v1-u1*v0,0];};SceneJS._math_cross3Vec3=function(u,v,dest){if(!dest){dest=u;}var x=u[0],y=u[1],z=u[2];
var x2=v[0],y2=v[1],z2=v[2];dest[0]=y*z2-z*y2;dest[1]=z*x2-x*z2;dest[2]=x*y2-y*x2;return dest;};SceneJS._math_sqLenVec4=function(v){return SceneJS._math_dotVector4(v,v);};SceneJS._math_lenVec4=function(v){return Math.sqrt(SceneJS._math_sqLenVec4(v));};SceneJS._math_dotVector3=function(u,v){return(u[0]*v[0]+u[1]*v[1]+u[2]*v[2]);
};SceneJS._math_dotVector2=function(u,v){return(u[0]*v[0]+u[1]*v[1]);};SceneJS._math_sqLenVec3=function(v){return SceneJS._math_dotVector3(v,v);};SceneJS._math_sqLenVec2=function(v){return SceneJS._math_dotVector2(v,v);};SceneJS._math_lenVec3=function(v){return Math.sqrt(SceneJS._math_sqLenVec3(v));};
SceneJS._math_lenVec2=function(v){return Math.sqrt(SceneJS._math_sqLenVec2(v));};SceneJS._math_rcpVec3=function(v,dest){return SceneJS._math_divScalarVec3(1,v,dest);};SceneJS._math_normalizeVec4=function(v,dest){var f=1/SceneJS._math_lenVec4(v);return SceneJS._math_mulVec4Scalar(v,f,dest);};SceneJS._math_normalizeVec3=function(v){var f=1/SceneJS._math_lenVec3(v);
return SceneJS._math_mulVec3Scalar(v,f);};SceneJS._math_mat4=function(){return new Array(16);};SceneJS._math_dupMat4=function(m){return m.slice(0,16);};SceneJS._math_getCellMat4=function(m,row,col){return m[row+col*4];};SceneJS._math_setCellMat4=function(m,row,col,s){m[row+col*4]=s;};SceneJS._math_getRowMat4=function(m,r){return[m[r],m[r+4],m[r+8],m[r+12]];
};SceneJS._math_setRowMat4=function(m,r,v){m[r]=v[0];m[r+4]=v[1];m[r+8]=v[2];m[r+12]=v[3];};SceneJS._math_setRowMat4c=function(m,r,x,y,z,w){SceneJS._math_setRowMat4(m,r,[x,y,z,w]);};SceneJS._math_setRowMat4s=function(m,r,s){SceneJS._math_setRowMat4c(m,r,s,s,s,s);};SceneJS._math_getColMat4=function(m,c){var i=c*4;
return[m[i],m[i+1],m[i+2],m[i+3]];};SceneJS._math_setColMat4v=function(m,c,v){var i=c*4;m[i]=v[0];m[i+1]=v[1];m[i+2]=v[2];m[i+3]=v[3];};SceneJS._math_setColMat4c=function(m,c,x,y,z,w){SceneJS._math_setColMat4v(m,c,[x,y,z,w]);};SceneJS._math_setColMat4Scalar=function(m,c,s){SceneJS._math_setColMat4c(m,c,s,s,s,s);
};SceneJS._math_mat4To3=function(m){return[m[0],m[1],m[2],m[4],m[5],m[6],m[8],m[9],m[10]];};SceneJS._math_m4s=function(s){return[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s];};SceneJS._math_setMat4ToZeroes=function(){return SceneJS._math_m4s(0);};SceneJS._math_setMat4ToOnes=function(){return SceneJS._math_m4s(1);
};SceneJS._math_diagonalMat4v=function(v){return[v[0],0,0,0,0,v[1],0,0,0,0,v[2],0,0,0,0,v[3]];};SceneJS._math_diagonalMat4c=function(x,y,z,w){return SceneJS._math_diagonalMat4v([x,y,z,w]);};SceneJS._math_diagonalMat4s=function(s){return SceneJS._math_diagonalMat4c(s,s,s,s);};SceneJS._math_identityMat4=function(){return SceneJS._math_diagonalMat4v([1,1,1,1]);
};SceneJS._math_isIdentityMat4=function(m){if(m[0]!==1||m[1]!==0||m[2]!==0||m[3]!==0||m[4]!==0||m[5]!==1||m[6]!==0||m[7]!==0||m[8]!==0||m[9]!==0||m[10]!==1||m[11]!==0||m[12]!==0||m[13]!==0||m[14]!==0||m[15]!==1){return false;}return true;};SceneJS._math_negateMat4=function(m,dest){if(!dest){dest=m;}dest[0]=-m[0];
dest[1]=-m[1];dest[2]=-m[2];dest[3]=-m[3];dest[4]=-m[4];dest[5]=-m[5];dest[6]=-m[6];dest[7]=-m[7];dest[8]=-m[8];dest[9]=-m[9];dest[10]=-m[10];dest[11]=-m[11];dest[12]=-m[12];dest[13]=-m[13];dest[14]=-m[14];dest[15]=-m[15];return dest;};SceneJS._math_addMat4=function(a,b,dest){if(!dest){dest=a;}dest[0]=a[0]+b[0];
dest[1]=a[1]+b[1];dest[2]=a[2]+b[2];dest[3]=a[3]+b[3];dest[4]=a[4]+b[4];dest[5]=a[5]+b[5];dest[6]=a[6]+b[6];dest[7]=a[7]+b[7];dest[8]=a[8]+b[8];dest[9]=a[9]+b[9];dest[10]=a[10]+b[10];dest[11]=a[11]+b[11];dest[12]=a[12]+b[12];dest[13]=a[13]+b[13];dest[14]=a[14]+b[14];dest[15]=a[15]+b[15];return dest;};
SceneJS._math_addMat4Scalar=function(m,s,dest){if(!dest){dest=m;}dest[0]=m[0]+s;dest[1]=m[1]+s;dest[2]=m[2]+s;dest[3]=m[3]+s;dest[4]=m[4]+s;dest[5]=m[5]+s;dest[6]=m[6]+s;dest[7]=m[7]+s;dest[8]=m[8]+s;dest[9]=m[9]+s;dest[10]=m[10]+s;dest[11]=m[11]+s;dest[12]=m[12]+s;dest[13]=m[13]+s;dest[14]=m[14]+s;dest[15]=m[15]+s;
return dest;};SceneJS._math_addScalarMat4=function(s,m,dest){return SceneJS._math_addMat4Scalar(m,s,dest);};SceneJS._math_subMat4=function(a,b,dest){if(!dest){dest=a;}dest[0]=a[0]-b[0];dest[1]=a[1]-b[1];dest[2]=a[2]-b[2];dest[3]=a[3]-b[3];dest[4]=a[4]-b[4];dest[5]=a[5]-b[5];dest[6]=a[6]-b[6];dest[7]=a[7]-b[7];
dest[8]=a[8]-b[8];dest[9]=a[9]-b[9];dest[10]=a[10]-b[10];dest[11]=a[11]-b[11];dest[12]=a[12]-b[12];dest[13]=a[13]-b[13];dest[14]=a[14]-b[14];dest[15]=a[15]-b[15];return dest;};SceneJS._math_subMat4Scalar=function(m,s,dest){if(!dest){dest=m;}dest[0]=m[0]-s;dest[1]=m[1]-s;dest[2]=m[2]-s;dest[3]=m[3]-s;
dest[4]=m[4]-s;dest[5]=m[5]-s;dest[6]=m[6]-s;dest[7]=m[7]-s;dest[8]=m[8]-s;dest[9]=m[9]-s;dest[10]=m[10]-s;dest[11]=m[11]-s;dest[12]=m[12]-s;dest[13]=m[13]-s;dest[14]=m[14]-s;dest[15]=m[15]-s;return dest;};SceneJS._math_subScalarMat4=function(s,m,dest){if(!dest){dest=m;}dest[0]=s-m[0];dest[1]=s-m[1];
dest[2]=s-m[2];dest[3]=s-m[3];dest[4]=s-m[4];dest[5]=s-m[5];dest[6]=s-m[6];dest[7]=s-m[7];dest[8]=s-m[8];dest[9]=s-m[9];dest[10]=s-m[10];dest[11]=s-m[11];dest[12]=s-m[12];dest[13]=s-m[13];dest[14]=s-m[14];dest[15]=s-m[15];return dest;};SceneJS._math_mulMat4=function(a,b,dest){if(!dest){dest=a;}var a00=a[0],a01=a[1],a02=a[2],a03=a[3];
var a10=a[4],a11=a[5],a12=a[6],a13=a[7];var a20=a[8],a21=a[9],a22=a[10],a23=a[11];var a30=a[12],a31=a[13],a32=a[14],a33=a[15];var b00=b[0],b01=b[1],b02=b[2],b03=b[3];var b10=b[4],b11=b[5],b12=b[6],b13=b[7];var b20=b[8],b21=b[9],b22=b[10],b23=b[11];var b30=b[12],b31=b[13],b32=b[14],b33=b[15];dest[0]=b00*a00+b01*a10+b02*a20+b03*a30;
dest[1]=b00*a01+b01*a11+b02*a21+b03*a31;dest[2]=b00*a02+b01*a12+b02*a22+b03*a32;dest[3]=b00*a03+b01*a13+b02*a23+b03*a33;dest[4]=b10*a00+b11*a10+b12*a20+b13*a30;dest[5]=b10*a01+b11*a11+b12*a21+b13*a31;dest[6]=b10*a02+b11*a12+b12*a22+b13*a32;dest[7]=b10*a03+b11*a13+b12*a23+b13*a33;dest[8]=b20*a00+b21*a10+b22*a20+b23*a30;
dest[9]=b20*a01+b21*a11+b22*a21+b23*a31;dest[10]=b20*a02+b21*a12+b22*a22+b23*a32;dest[11]=b20*a03+b21*a13+b22*a23+b23*a33;dest[12]=b30*a00+b31*a10+b32*a20+b33*a30;dest[13]=b30*a01+b31*a11+b32*a21+b33*a31;dest[14]=b30*a02+b31*a12+b32*a22+b33*a32;dest[15]=b30*a03+b31*a13+b32*a23+b33*a33;return dest;};SceneJS._math_mulMat4s=function(m,s,dest){if(!dest){dest=m;
}dest[0]=m[0]*s;dest[1]=m[1]*s;dest[2]=m[2]*s;dest[3]=m[3]*s;dest[4]=m[4]*s;dest[5]=m[5]*s;dest[6]=m[6]*s;dest[7]=m[7]*s;dest[8]=m[8]*s;dest[9]=m[9]*s;dest[10]=m[10]*s;dest[11]=m[11]*s;dest[12]=m[12]*s;dest[13]=m[13]*s;dest[14]=m[14]*s;dest[15]=m[15]*s;return dest;};SceneJS._math_mulMat4v4=function(m,v){var v0=v[0],v1=v[1],v2=v[2],v3=v[3];
return[m[0]*v0+m[4]*v1+m[8]*v2+m[12]*v3,m[1]*v0+m[5]*v1+m[9]*v2+m[13]*v3,m[2]*v0+m[6]*v1+m[10]*v2+m[14]*v3,m[3]*v0+m[7]*v1+m[11]*v2+m[15]*v3];};SceneJS._math_transposeMat4=function(mat,dest){var m4=mat[4],m14=mat[14],m8=mat[8];var m13=mat[13],m12=mat[12],m9=mat[9];if(!dest||mat==dest){var a01=mat[1],a02=mat[2],a03=mat[3];
var a12=mat[6],a13=mat[7];var a23=mat[11];mat[1]=m4;mat[2]=m8;mat[3]=m12;mat[4]=a01;mat[6]=m9;mat[7]=m13;mat[8]=a02;mat[9]=a12;mat[11]=m14;mat[12]=a03;mat[13]=a13;mat[14]=a23;return mat;}dest[0]=mat[0];dest[1]=m4;dest[2]=m8;dest[3]=m12;dest[4]=mat[1];dest[5]=mat[5];dest[6]=m9;dest[7]=m13;dest[8]=mat[2];
dest[9]=mat[6];dest[10]=mat[10];dest[11]=m14;dest[12]=mat[3];dest[13]=mat[7];dest[14]=mat[11];dest[15]=mat[15];return dest;};SceneJS._math_determinantMat4=function(mat){var a00=mat[0],a01=mat[1],a02=mat[2],a03=mat[3];var a10=mat[4],a11=mat[5],a12=mat[6],a13=mat[7];var a20=mat[8],a21=mat[9],a22=mat[10],a23=mat[11];
var a30=mat[12],a31=mat[13],a32=mat[14],a33=mat[15];return a30*a21*a12*a03-a20*a31*a12*a03-a30*a11*a22*a03+a10*a31*a22*a03+a20*a11*a32*a03-a10*a21*a32*a03-a30*a21*a02*a13+a20*a31*a02*a13+a30*a01*a22*a13-a00*a31*a22*a13-a20*a01*a32*a13+a00*a21*a32*a13+a30*a11*a02*a23-a10*a31*a02*a23-a30*a01*a12*a23+a00*a31*a12*a23+a10*a01*a32*a23-a00*a11*a32*a23-a20*a11*a02*a33+a10*a21*a02*a33+a20*a01*a12*a33-a00*a21*a12*a33-a10*a01*a22*a33+a00*a11*a22*a33;
};SceneJS._math_inverseMat4=function(mat,dest){if(!dest){dest=mat;}var a00=mat[0],a01=mat[1],a02=mat[2],a03=mat[3];var a10=mat[4],a11=mat[5],a12=mat[6],a13=mat[7];var a20=mat[8],a21=mat[9],a22=mat[10],a23=mat[11];var a30=mat[12],a31=mat[13],a32=mat[14],a33=mat[15];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;
var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var invDet=1/(b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06);
dest[0]=(a11*b11-a12*b10+a13*b09)*invDet;dest[1]=(-a01*b11+a02*b10-a03*b09)*invDet;dest[2]=(a31*b05-a32*b04+a33*b03)*invDet;dest[3]=(-a21*b05+a22*b04-a23*b03)*invDet;dest[4]=(-a10*b11+a12*b08-a13*b07)*invDet;dest[5]=(a00*b11-a02*b08+a03*b07)*invDet;dest[6]=(-a30*b05+a32*b02-a33*b01)*invDet;dest[7]=(a20*b05-a22*b02+a23*b01)*invDet;
dest[8]=(a10*b10-a11*b08+a13*b06)*invDet;dest[9]=(-a00*b10+a01*b08-a03*b06)*invDet;dest[10]=(a30*b04-a31*b02+a33*b00)*invDet;dest[11]=(-a20*b04+a21*b02-a23*b00)*invDet;dest[12]=(-a10*b09+a11*b07-a12*b06)*invDet;dest[13]=(a00*b09-a01*b07+a02*b06)*invDet;dest[14]=(-a30*b03+a31*b01-a32*b00)*invDet;dest[15]=(a20*b03-a21*b01+a22*b00)*invDet;
return dest;};SceneJS._math_traceMat4=function(m){return(m[0]+m[5]+m[10]+m[15]);};SceneJS._math_translationMat4v=function(v){var m=SceneJS._math_identityMat4();m[12]=v[0];m[13]=v[1];m[14]=v[2];return m;};SceneJS._math_translationMat4c=function(x,y,z){return SceneJS._math_translationMat4v([x,y,z]);};SceneJS._math_translationMat4s=function(s){return SceneJS._math_translationMat4c(s,s,s);
};SceneJS._math_rotationMat4v=function(anglerad,axis){var ax=SceneJS._math_normalizeVec4([axis[0],axis[1],axis[2],0]);var s=Math.sin(anglerad);var c=Math.cos(anglerad);var q=1-c;var x=ax[0];var y=ax[1];var z=ax[2];var xy,yz,zx,xs,ys,zs;xy=x*y;yz=y*z;zx=z*x;xs=x*s;ys=y*s;zs=z*s;var m=SceneJS._math_mat4();
m[0]=(q*x*x)+c;m[1]=(q*xy)+zs;m[2]=(q*zx)-ys;m[3]=0;m[4]=(q*xy)-zs;m[5]=(q*y*y)+c;m[6]=(q*yz)+xs;m[7]=0;m[8]=(q*zx)+ys;m[9]=(q*yz)-xs;m[10]=(q*z*z)+c;m[11]=0;m[12]=0;m[13]=0;m[14]=0;m[15]=1;return m;};SceneJS._math_rotationMat4c=function(anglerad,x,y,z){return SceneJS._math_rotationMat4v(anglerad,[x,y,z]);
};SceneJS._math_scalingMat4v=function(v){var m=SceneJS._math_identityMat4();m[0]=v[0];m[5]=v[1];m[10]=v[2];return m;};SceneJS._math_scalingMat4c=function(x,y,z){return SceneJS._math_scalingMat4v([x,y,z]);};SceneJS._math_scalingMat4s=function(s){return SceneJS._math_scalingMat4c(s,s,s);};SceneJS._math_lookAtMat4v=function(pos,target,up,dest){if(!dest){dest=SceneJS._math_mat4();
}var posx=pos[0],posy=pos[1],posz=pos[2],upx=up[0],upy=up[1],upz=up[2],targetx=target[0],targety=target[1],targetz=target[2];if(posx==targetx&&posy==targety&&posz==targetz){return SceneJS._math_identityMat4();}var z0,z1,z2,x0,x1,x2,y0,y1,y2,len;z0=posx-targetx;z1=posy-targety;z2=posz-targetz;len=1/Math.sqrt(z0*z0+z1*z1+z2*z2);
z0*=len;z1*=len;z2*=len;x0=upy*z2-upz*z1;x1=upz*z0-upx*z2;x2=upx*z1-upy*z0;len=Math.sqrt(x0*x0+x1*x1+x2*x2);if(!len){x0=0;x1=0;x2=0;}else{len=1/len;x0*=len;x1*=len;x2*=len;}y0=z1*x2-z2*x1;y1=z2*x0-z0*x2;y2=z0*x1-z1*x0;len=Math.sqrt(y0*y0+y1*y1+y2*y2);if(!len){y0=0;y1=0;y2=0;}else{len=1/len;y0*=len;y1*=len;
y2*=len;}dest[0]=x0;dest[1]=y0;dest[2]=z0;dest[3]=0;dest[4]=x1;dest[5]=y1;dest[6]=z1;dest[7]=0;dest[8]=x2;dest[9]=y2;dest[10]=z2;dest[11]=0;dest[12]=-(x0*posx+x1*posy+x2*posz);dest[13]=-(y0*posx+y1*posy+y2*posz);dest[14]=-(z0*posx+z1*posy+z2*posz);dest[15]=1;return dest;};SceneJS._math_lookAtMat4c=function(posx,posy,posz,targetx,targety,targetz,upx,upy,upz){return SceneJS._math_lookAtMat4v([posx,posy,posz],[targetx,targety,targetz],[upx,upy,upz]);
};SceneJS._math_orthoMat4c=function(left,right,bottom,top,near,far,dest){if(!dest){dest=SceneJS._math_mat4();}var rl=(right-left);var tb=(top-bottom);var fn=(far-near);dest[0]=2/rl;dest[1]=0;dest[2]=0;dest[3]=0;dest[4]=0;dest[5]=2/tb;dest[6]=0;dest[7]=0;dest[8]=0;dest[9]=0;dest[10]=-2/fn;dest[11]=0;dest[12]=-(left+right)/rl;
dest[13]=-(top+bottom)/tb;dest[14]=-(far+near)/fn;dest[15]=1;return dest;};SceneJS._math_frustumMat4v=function(fmin,fmax){var fmin4=[fmin[0],fmin[1],fmin[2],0];var fmax4=[fmax[0],fmax[1],fmax[2],0];var vsum=SceneJS._math_mat4();SceneJS._math_addVec4(fmax4,fmin4,vsum);var vdif=SceneJS._math_mat4();SceneJS._math_subVec4(fmax4,fmin4,vdif);
var t=2*fmin4[2];var m=SceneJS._math_mat4();var vdif0=vdif[0],vdif1=vdif[1],vdif2=vdif[2];m[0]=t/vdif0;m[1]=0;m[2]=0;m[3]=0;m[4]=0;m[5]=t/vdif1;m[6]=0;m[7]=0;m[8]=vsum[0]/vdif0;m[9]=vsum[1]/vdif1;m[10]=-vsum[2]/vdif2;m[11]=-1;m[12]=0;m[13]=0;m[14]=-t*fmax4[2]/vdif2;m[15]=0;return m;};SceneJS._math_frustumMatrix4=function(left,right,bottom,top,near,far,dest){if(!dest){dest=SceneJS._math_mat4();
}var rl=(right-left);var tb=(top-bottom);var fn=(far-near);dest[0]=(near*2)/rl;dest[1]=0;dest[2]=0;dest[3]=0;dest[4]=0;dest[5]=(near*2)/tb;dest[6]=0;dest[7]=0;dest[8]=(right+left)/rl;dest[9]=(top+bottom)/tb;dest[10]=-(far+near)/fn;dest[11]=-1;dest[12]=0;dest[13]=0;dest[14]=-(far*near*2)/fn;dest[15]=0;
return dest;};SceneJS._math_perspectiveMatrix4=function(fovyrad,aspectratio,znear,zfar){var pmin=new Array(4);var pmax=new Array(4);pmin[2]=znear;pmax[2]=zfar;pmax[1]=pmin[2]*Math.tan(fovyrad/2);pmin[1]=-pmax[1];pmax[0]=pmax[1]*aspectratio;pmin[0]=-pmax[0];return SceneJS._math_frustumMat4v(pmin,pmax);
};SceneJS._math_transformPoint3=function(m,p){var p0=p[0],p1=p[1],p2=p[2];return[(m[0]*p0)+(m[4]*p1)+(m[8]*p2)+m[12],(m[1]*p0)+(m[5]*p1)+(m[9]*p2)+m[13],(m[2]*p0)+(m[6]*p1)+(m[10]*p2)+m[14],(m[3]*p0)+(m[7]*p1)+(m[11]*p2)+m[15]];};SceneJS._math_transformPoints3=function(m,points){var result=new Array(points.length);
var len=points.length;var p0,p1,p2;var pi;var m0=m[0],m1=m[1],m2=m[2],m3=m[3];var m4=m[4],m5=m[5],m6=m[6],m7=m[7];var m8=m[8],m9=m[9],m10=m[10],m11=m[11];var m12=m[12],m13=m[13],m14=m[14],m15=m[15];for(var i=0;i<len;++i){pi=points[i];p0=pi[0];p1=pi[1];p2=pi[2];result[i]=[(m0*p0)+(m4*p1)+(m8*p2)+m12,(m1*p0)+(m5*p1)+(m9*p2)+m13,(m2*p0)+(m6*p1)+(m10*p2)+m14,(m3*p0)+(m7*p1)+(m11*p2)+m15];
}return result;};SceneJS._math_transformVector3=function(m,v){var v0=v[0],v1=v[1],v2=v[2];return[(m[0]*v0)+(m[4]*v1)+(m[8]*v2),(m[1]*v0)+(m[5]*v1)+(m[9]*v2),(m[2]*v0)+(m[6]*v1)+(m[10]*v2)];};SceneJS._math_projectVec4=function(v){var f=1/v[3];return[v[0]*f,v[1]*f,v[2]*f,1];};SceneJS._math_Plane3=function(normal,offset,normalize){this.normal=[0,0,1];
this.offset=0;if(normal&&offset){var normal0=normal[0],normal1=normal[1],normal2=normal[2];this.offset=offset;if(normalize){var s=Math.sqrt(normal0*normal0+normal1*normal1+normal2*normal2);if(s>0){s=1/s;this.normal[0]=normal0*s;this.normal[1]=normal1*s;this.normal[2]=normal2*s;this.offset*=s;}}}};SceneJS._math_MAX_DOUBLE=Number.MAX_VALUE;
SceneJS._math_MIN_DOUBLE=Number.MIN_VALUE;SceneJS._math_Box3=function(min,max){this.min=min||[SceneJS._math_MAX_DOUBLE,SceneJS._math_MAX_DOUBLE,SceneJS._math_MAX_DOUBLE];this.max=max||[SceneJS._math_MIN_DOUBLE,SceneJS._math_MIN_DOUBLE,SceneJS._math_MIN_DOUBLE];this.init=function(min,max){this.min[0]=min[0];
this.min[1]=min[1];this.min[2]=min[2];this.max[0]=max[0];this.max[1]=max[1];this.max[2]=max[2];return this;};this.fromPoints=function(points){var pointsLength=points.length;for(i=0;i<pointsLength;++i){var points_i3=points[i][3];var pDiv0=points[i][0]/points_i3;var pDiv1=points[i][1]/points_i3;var pDiv2=points[i][2]/points_i3;
if(pDiv0<this.min[0]){this.min[0]=pDiv0;}if(pDiv1<this.min[1]){this.min[1]=pDiv1;}if(pDiv2<this.min[2]){this.min[2]=pDiv2;}if(pDiv0>this.max[0]){this.max[0]=pDiv0;}if(pDiv1>this.max[1]){this.max[1]=pDiv1;}if(pDiv2>this.max[2]){this.max[2]=pDiv2;}}return this;};this.isEmpty=function(){return((this.min[0]>=this.max[0])&&(this.min[1]>=this.max[1])&&(this.min[2]>=this.max[2]));
};this.getCenter=function(){return[(this.max[0]+this.min[0])/2,(this.max[1]+this.min[1])/2,(this.max[2]+this.min[2])/2];};this.getSize=function(){return[(this.max[0]-this.min[0]),(this.max[1]-this.min[1]),(this.max[2]-this.min[2])];};this.getFacesAreas=function(){var s=this.size;return[(s[1]*s[2]),(s[0]*s[2]),(s[0]*s[1])];
};this.getSurfaceArea=function(){var a=this.getFacesAreas();return((a[0]+a[1]+a[2])*2);};this.getVolume=function(){var s=this.size;return(s[0]*s[1]*s[2]);};this.getOffset=function(half_delta){this.min[0]-=half_delta;this.min[1]-=half_delta;this.min[2]-=half_delta;this.max[0]+=half_delta;this.max[1]+=half_delta;
this.max[2]+=half_delta;return this;};};SceneJS._math_AxisBox3=function(min,max){var min0=min[0],min1=min[1],min2=min[2];var max0=max[0],max1=max[1],max2=max[2];this.verts=[[min0,min1,min2],[max0,min1,min2],[max0,max1,min2],[min0,max1,min2],[min0,min1,max2],[max0,min1,max2],[max0,max1,max2],[min0,max1,max2]];
this.toBox3=function(){var box=new SceneJS._math_Box3();for(var i=0;i<8;++i){var v=this.verts[i];for(var j=0;j<3;++j){if(v[j]<box.min[j]){box.min[j]=v[j];}if(v[j]>box.max[j]){box.max[j]=v[j];}}}};};SceneJS._math_Sphere3=function(center,radius){this.center=[center[0],center[1],center[2]];this.radius=radius;
this.isEmpty=function(){return(this.radius===0);};this.surfaceArea=function(){return(4*Math.PI*this.radius*this.radius);};this.getVolume=function(){var thisRadius=this.radius;return((4/3)*Math.PI*thisRadius*thisRadius*thisRadius);};};SceneJS._math_billboardMat=function(viewMatrix){var rotVec=[SceneJS._math_getColMat4(viewMatrix,0),SceneJS._math_getColMat4(viewMatrix,1),SceneJS._math_getColMat4(viewMatrix,2)];
var scaleVec=[SceneJS._math_lenVec4(rotVec[0]),SceneJS._math_lenVec4(rotVec[1]),SceneJS._math_lenVec4(rotVec[2])];var scaleVecRcp=SceneJS._math_mat4();SceneJS._math_rcpVec3(scaleVec,scaleVecRcp);var sMat=SceneJS._math_scalingMat4v(scaleVec);SceneJS._math_mulVec4Scalar(rotVec[0],scaleVecRcp[0]);SceneJS._math_mulVec4Scalar(rotVec[1],scaleVecRcp[1]);
SceneJS._math_mulVec4Scalar(rotVec[2],scaleVecRcp[2]);var rotMatInverse=SceneJS._math_identityMat4();SceneJS._math_setRowMat4(rotMatInverse,0,rotVec[0]);SceneJS._math_setRowMat4(rotMatInverse,1,rotVec[1]);SceneJS._math_setRowMat4(rotMatInverse,2,rotVec[2]);return SceneJS._math_mulMat4(rotMatInverse,sMat);
};SceneJS._math_FrustumPlane=function(nx,ny,nz,offset){var s=1/Math.sqrt(nx*nx+ny*ny+nz*nz);this.normal=[nx*s,ny*s,nz*s];this.offset=offset*s;this.testVertex=[(this.normal[0]>=0)?(1):(0),(this.normal[1]>=0)?(1):(0),(this.normal[2]>=0)?(1):(0)];};SceneJS._math_OUTSIDE_FRUSTUM=3;SceneJS._math_INTERSECT_FRUSTUM=4;
SceneJS._math_INSIDE_FRUSTUM=5;SceneJS._math_Frustum=function(viewMatrix,projectionMatrix,viewport){var m=SceneJS._math_mat4();SceneJS._math_mulMat4(projectionMatrix,viewMatrix,m);var m0=m[0],m1=m[1],m2=m[2],m3=m[3];var m4=m[4],m5=m[5],m6=m[6],m7=m[7];var m8=m[8],m9=m[9],m10=m[10],m11=m[11];var m12=m[12],m13=m[13],m14=m[14],m15=m[15];
var planes=[new SceneJS._math_FrustumPlane(m3-m0,m7-m4,m11-m8,m15-m12),new SceneJS._math_FrustumPlane(m3+m0,m7+m4,m11+m8,m15+m12),new SceneJS._math_FrustumPlane(m3-m1,m7-m5,m11-m9,m15-m13),new SceneJS._math_FrustumPlane(m3+m1,m7+m5,m11+m9,m15+m13),new SceneJS._math_FrustumPlane(m3-m2,m7-m6,m11-m10,m15-m14),new SceneJS._math_FrustumPlane(m3+m2,m7+m6,m11+m10,m15+m14)];
var rotVec=[SceneJS._math_getColMat4(viewMatrix,0),SceneJS._math_getColMat4(viewMatrix,1),SceneJS._math_getColMat4(viewMatrix,2)];var scaleVec=[SceneJS._math_lenVec4(rotVec[0]),SceneJS._math_lenVec4(rotVec[1]),SceneJS._math_lenVec4(rotVec[2])];var scaleVecRcp=SceneJS._math_rcpVec3(scaleVec);var sMat=SceneJS._math_scalingMat4v(scaleVec);
var sMatInv=SceneJS._math_scalingMat4v(scaleVecRcp);SceneJS._math_mulVec4Scalar(rotVec[0],scaleVecRcp[0]);SceneJS._math_mulVec4Scalar(rotVec[1],scaleVecRcp[1]);SceneJS._math_mulVec4Scalar(rotVec[2],scaleVecRcp[2]);var rotMatInverse=SceneJS._math_identityMat4();SceneJS._math_setRowMat4(rotMatInverse,0,rotVec[0]);
SceneJS._math_setRowMat4(rotMatInverse,1,rotVec[1]);SceneJS._math_setRowMat4(rotMatInverse,2,rotVec[2]);if(!this.matrix){this.matrix=SceneJS._math_mat4();}SceneJS._math_mulMat4(projectionMatrix,viewMatrix,this.matrix);if(!this.billboardMatrix){this.billboardMatrix=SceneJS._math_mat4();}SceneJS._math_mulMat4(sMatInv,SceneJS._math_mulMat4(rotMatInverse,sMat),this.billboardMatrix);
this.viewport=viewport.slice(0,4);this.textAxisBoxIntersection=function(box){var ret=SceneJS._math_INSIDE_FRUSTUM;var bminmax=[box.min,box.max];var plane=null;for(var i=0;i<6;++i){plane=planes[i];var normal0=plane.normal[0];var normal1=plane.normal[1];var normal2=plane.normal[2];var bminmaxTest0=bminmax[plane.testVertex[0]][0];
var bminmaxTest1=bminmax[plane.testVertex[1]][1];var bminmaxTest2=bminmax[plane.testVertex[2]][2];if(((normal0*bminmaxTest0)+(normal1*bminmaxTest1)+(normal2*bminmaxTest2)+(plane.offset))<0){return SceneJS._math_OUTSIDE_FRUSTUM;}if(((normal0*bminmaxTest0)+(normal1*bminmaxTest1)+(normal2*bminmaxTest2)+(plane.offset))<0){ret=SceneJS._math_INTERSECT_FRUSTUM;
}}return ret;};this.getProjectedSize=function(box){var diagVec=SceneJS._math_mat4();SceneJS._math_subVec3(box.max,box.min,diagVec);var diagSize=SceneJS._math_lenVec3(diagVec);var size=Math.abs(diagSize);var p0=[(box.min[0]+box.max[0])*0.5,(box.min[1]+box.max[1])*0.5,(box.min[2]+box.max[2])*0.5,0];var halfSize=size*0.5;
var p1=[-halfSize,0,0,1];var p2=[halfSize,0,0,1];p1=SceneJS._math_mulMat4v4(this.billboardMatrix,p1);p1=SceneJS._math_addVec4(p1,p0);p1=SceneJS._math_projectVec4(SceneJS._math_mulMat4v4(this.matrix,p1));p2=SceneJS._math_mulMat4v4(this.billboardMatrix,p2);p2=SceneJS._math_addVec4(p2,p0);p2=SceneJS._math_projectVec4(SceneJS._math_mulMat4v4(this.matrix,p2));
return viewport[2]*Math.abs(p2[0]-p1[0]);};this.getProjectedState=function(modelCoords){var viewCoords=SceneJS._math_transformPoints3(this.matrix,modelCoords);var canvasBoxMin0=10000000,canvasBoxMin1=10000000;var canvasBoxMax0=-10000000,canvasBoxMax1=-10000000;var v,x,y;var arrLen=viewCoords.length;for(var i=0;
i<arrLen;++i){v=SceneJS._math_projectVec4(viewCoords[i]);x=v[0];y=v[1];if(x<-0.5){x=-0.5;}if(y<-0.5){y=-0.5;}if(x>0.5){x=0.5;}if(y>0.5){y=0.5;}if(x<canvasBoxMin0){canvasBoxMin0=x;}if(y<canvasBoxMin1){canvasBoxMin1=y;}if(x>canvasBoxMax0){canvasBoxMax0=x;}if(y>canvasBoxMax1){canvasBoxMax1=y;}}canvasBoxMin0+=0.5;
canvasBoxMin1+=0.5;canvasBoxMax0+=0.5;canvasBoxMax1+=0.5;var viewport2=viewport[2],viewport3=viewport[3];canvasBoxMin0=(canvasBoxMin0*(viewport2+15));canvasBoxMin1=(canvasBoxMin1*(viewport3+15));canvasBoxMax0=(canvasBoxMax0*(viewport2+15));canvasBoxMax1=(canvasBoxMax1*(viewport3+15));var diagCanvasBoxVec=SceneJS._math_mat4();
SceneJS._math_subVec2([canvasBoxMax0,canvasBoxMax1],[canvasBoxMin0,canvasBoxMin1],diagCanvasBoxVec);var diagCanvasBoxSize=SceneJS._math_lenVec2(diagCanvasBoxVec);if(canvasBoxMin0<0){canvasBoxMin0=0;}if(canvasBoxMax0>viewport2){canvasBoxMax0=viewport2;}if(canvasBoxMin1<0){canvasBoxMin1=0;}if(canvasBoxMax1>viewport3){canvasBoxMax1=viewport3;
}return{canvasBox:{min:[canvasBoxMin0,canvasBoxMin1],max:[canvasBoxMax0,canvasBoxMax1]},canvasSize:diagCanvasBoxSize};};};SceneJS._math_identityQuaternion=function(){return[0,0,0,1];};SceneJS._math_angleAxisQuaternion=function(x,y,z,degrees){var angleRad=(degrees/180)*Math.PI;var halfAngle=angleRad/2;
var fsin=Math.sin(halfAngle);return[fsin*x,fsin*y,fsin*z,Math.cos(halfAngle)];};SceneJS._math_mulQuaternions=function(p,q){var p0=p[0],p1=p[1],p2=p[2],p3=p[3];var q0=q[0],q1=q[1],q2=q[2],q3=q[3];return[p3*q0+p0*q3+p1*q2-p2*q1,p3*q1+p1*q3+p2*q0-p0*q2,p3*q2+p2*q3+p0*q1-p1*q0,p3*q3-p0*q0-p1*q1-p2*q2];};
SceneJS._math_newMat4FromQuaternion=function(q){var q0=q[0],q1=q[1],q2=q[2],q3=q[3];var tx=2*q0;var ty=2*q1;var tz=2*q2;var twx=tx*q3;var twy=ty*q3;var twz=tz*q3;var txx=tx*q0;var txy=ty*q0;var txz=tz*q0;var tyy=ty*q1;var tyz=tz*q1;var tzz=tz*q2;var m=SceneJS._math_identityMat4();SceneJS._math_setCellMat4(m,0,0,1-(tyy+tzz));
SceneJS._math_setCellMat4(m,0,1,txy-twz);SceneJS._math_setCellMat4(m,0,2,txz+twy);SceneJS._math_setCellMat4(m,1,0,txy+twz);SceneJS._math_setCellMat4(m,1,1,1-(txx+tzz));SceneJS._math_setCellMat4(m,1,2,tyz-twx);SceneJS._math_setCellMat4(m,2,0,txz-twy);SceneJS._math_setCellMat4(m,2,1,tyz+twx);SceneJS._math_setCellMat4(m,2,2,1-(txx+tyy));
return m;};SceneJS._math_slerp=function(t,q1,q2){var q13=q1[3]*0.0174532925;var q23=q2[3]*0.0174532925;var cosHalfAngle=q13*q23+q1[0]*q2[0]+q1[1]*q2[1]+q1[2]*q2[2];if(Math.abs(cosHalfAngle)>=1){return[q1[0],q1[1],q1[2],q1[3]];}else{var halfAngle=Math.acos(cosHalfAngle);var sinHalfAngle=Math.sqrt(1-cosHalfAngle*cosHalfAngle);
if(Math.abs(sinHalfAngle)<0.001){return[q1[0]*0.5+q2[0]*0.5,q1[1]*0.5+q2[1]*0.5,q1[2]*0.5+q2[2]*0.5,q1[3]*0.5+q2[3]*0.5];}else{var a=Math.sin((1-t)*halfAngle)/sinHalfAngle;var b=Math.sin(t*halfAngle)/sinHalfAngle;return[q1[0]*a+q2[0]*b,q1[1]*a+q2[1]*b,q1[2]*a+q2[2]*b,(q13*a+q23*b)*57.295779579];}}};SceneJS._math_normalizeQuaternion=function(q){var len=SceneJS._math_lenVec4([q[0],q[1],q[2],q[3]]);
return[q[0]/len,q[1]/len,q[2]/len,q[3]/len];};SceneJS._math_conjugateQuaternion=function(q){return[-q[0],-q[1],-q[2],q[3]];};SceneJS._math_angleAxisFromQuaternion=function(q){q=SceneJS._math_normalizeQuaternion(q);var q3=q[3];var angle=2*Math.acos(q3);var s=Math.sqrt(1-q3*q3);if(s<0.001){return{x:q[0],y:q[1],z:q[2],angle:angle*57.295779579};
}else{return{x:q[0]/s,y:q[1]/s,z:q[2]/s,angle:angle*57.295779579};}};SceneJS._webgl_enumMap={funcAdd:"FUNC_ADD",funcSubtract:"FUNC_SUBTRACT",funcReverseSubtract:"FUNC_REVERSE_SUBTRACT",zero:"ZERO",one:"ONE",srcColor:"SRC_COLOR",oneMinusSrcColor:"ONE_MINUS_SRC_COLOR",dstColor:"DST_COLOR",oneMinusDstColor:"ONE_MINUS_DST_COLOR",srcAlpha:"SRC_ALPHA",oneMinusSrcAlpha:"ONE_MINUS_SRC_ALPHA",dstAlpha:"DST_ALPHA",oneMinusDstAlpha:"ONE_MINUS_DST_ALPHA",contantColor:"CONSTANT_COLOR",oneMinusConstantColor:"ONE_MINUS_CONSTANT_COLOR",constantAlpha:"CONSTANT_ALPHA",oneMinusConstantAlpha:"ONE_MINUS_CONSTANT_ALPHA",srcAlphaSaturate:"SRC_ALPHA_SATURATE",front:"FRONT",back:"BACK",frontAndBack:"FRONT_AND_BACK",never:"NEVER",less:"LESS",equal:"EQUAL",lequal:"LEQUAL",greater:"GREATER",notequal:"NOTEQUAL",gequal:"GEQUAL",always:"ALWAYS",cw:"CW",ccw:"CCW",linear:"LINEAR",nearest:"NEAREST",linearMipMapNearest:"LINEAR_MIPMAP_NEAREST",nearestMipMapNearest:"NEAREST_MIPMAP_NEAREST",nearestMipMapLinear:"NEAREST_MIPMAP_LINEAR",linearMipMapLinear:"LINEAR_MIPMAP_LINEAR",repeat:"REPEAT",clampToEdge:"CLAMP_TO_EDGE",mirroredRepeat:"MIRRORED_REPEAT",alpha:"ALPHA",rgb:"RGB",rgba:"RGBA",luminance:"LUMINANCE",luminanceAlpha:"LUMINANCE_ALPHA",textureBinding2D:"TEXTURE_BINDING_2D",textureBindingCubeMap:"TEXTURE_BINDING_CUBE_MAP",compareRToTexture:"COMPARE_R_TO_TEXTURE",unsignedByte:"UNSIGNED_BYTE"};
SceneJS._webgl_fogModes={EXP:0,EXP2:1,LINEAR:2};SceneJS._webgl_ProgramUniform=function(context,program,name,type,size,location,logging){var func=null;if(type==context.BOOL){func=function(v){context.uniform1i(location,v);};}else{if(type==context.BOOL_VEC2){func=function(v){context.uniform2iv(location,v);
};}else{if(type==context.BOOL_VEC3){func=function(v){context.uniform3iv(location,v);};}else{if(type==context.BOOL_VEC4){func=function(v){context.uniform4iv(location,v);};}else{if(type==context.INT){func=function(v){context.uniform1iv(location,v);};}else{if(type==context.INT_VEC2){func=function(v){context.uniform2iv(location,v);
};}else{if(type==context.INT_VEC3){func=function(v){context.uniform3iv(location,v);};}else{if(type==context.INT_VEC4){func=function(v){context.uniform4iv(location,v);};}else{if(type==context.FLOAT){func=function(v){context.uniform1f(location,v);};}else{if(type==context.FLOAT_VEC2){func=function(v){context.uniform2fv(location,v);
};}else{if(type==context.FLOAT_VEC3){func=function(v){context.uniform3fv(location,v);};}else{if(type==context.FLOAT_VEC4){func=function(v){context.uniform4fv(location,v);};}else{if(type==context.FLOAT_MAT2){func=function(v){context.uniformMatrix2fv(location,context.FALSE,v);};}else{if(type==context.FLOAT_MAT3){func=function(v){context.uniformMatrix3fv(location,context.FALSE,v);
};}else{if(type==context.FLOAT_MAT4){func=function(v){context.uniformMatrix4fv(location,context.FALSE,v);};}else{throw"Unsupported shader uniform type: "+type;}}}}}}}}}}}}}}}this.setValue=function(v){func(v);};this.getValue=function(){return context.getUniform(program,location);};};SceneJS._webgl_ProgramSampler=function(context,program,name,type,size,location,logging){this.bindTexture=function(texture,unit){texture.bind(unit);
context.uniform1i(location,unit);};};SceneJS._webgl_ProgramAttribute=function(context,program,name,type,size,location,logging){this.bindFloatArrayBuffer=function(buffer){buffer.bind();context.enableVertexAttribArray(location);context.vertexAttribPointer(location,buffer.itemSize,context.FLOAT,false,0,0);
};};SceneJS._webgl_Shader=function(context,type,source,logging){this.handle=context.createShader(type);this.valid=true;context.shaderSource(this.handle,source);context.compileShader(this.handle);if(context.getShaderParameter(this.handle,context.COMPILE_STATUS)!=0){}else{this.valid=false;logging.error("Shader compile failed:"+context.getShaderInfoLog(this.handle));
}if(!this.valid){throw SceneJS._errorModule.fatalError(new SceneJS.errors.ShaderCompilationFailureException("Shader program failed to compile"));}};SceneJS._webgl_Program=function(hash,lastUsed,context,vertexSources,fragmentSources,logging){this.hash=hash;this.lastUsed=lastUsed;var shaders=[];for(var i=0;
i<vertexSources.length;i++){shaders.push(new SceneJS._webgl_Shader(context,context.VERTEX_SHADER,vertexSources[i],logging));}for(var i=0;i<fragmentSources.length;i++){shaders.push(new SceneJS._webgl_Shader(context,context.FRAGMENT_SHADER,fragmentSources[i],logging));}var handle=context.createProgram();
for(var i=0;i<shaders.length;i++){var shader=shaders[i];if(shader.valid){context.attachShader(handle,shader.handle);}}context.linkProgram(handle);context.validateProgram(handle);this.valid=true;this.valid=this.valid&&(context.getProgramParameter(handle,context.LINK_STATUS)!=0);this.valid=this.valid&&(context.getProgramParameter(handle,context.VALIDATE_STATUS)!=0);
if(this.valid){}else{logging.debug("Program link failed: "+context.getProgramInfoLog(handle));}if(!this.valid){throw SceneJS._errorModule.fatalError(new SceneJS.errors.ShaderLinkFailureException("Shader program failed to link"));}var uniforms={};var samplers={};var numUniforms=context.getProgramParameter(handle,context.ACTIVE_UNIFORMS);
for(var i=0;i<numUniforms;++i){var u=context.getActiveUniform(handle,i);if(u){var u_name=u.name;if(u_name[u_name.length-1]=="\u0000"){u_name=u_name.substr(0,u_name.length-1);}var location=context.getUniformLocation(handle,u_name);if((u.type==context.SAMPLER_2D)||(u.type==context.SAMPLER_CUBE)||(u.type==35682)){samplers[u_name]=new SceneJS._webgl_ProgramSampler(context,handle,u_name,u.type,u.size,location,logging);
}else{uniforms[u_name]=new SceneJS._webgl_ProgramUniform(context,handle,u_name,u.type,u.size,location,logging);}}}var attributes={};var numAttribs=context.getProgramParameter(handle,context.ACTIVE_ATTRIBUTES);for(var i=0;i<numAttribs;i++){var a=context.getActiveAttrib(handle,i);if(a){var location=context.getAttribLocation(handle,a.name);
attributes[a.name]=new SceneJS._webgl_ProgramAttribute(context,handle,a.name,a.type,a.size,location,logging);}}this.bind=function(){context.useProgram(handle);};this.setUniform=function(name,value){var u=uniforms[name];if(u){u.setValue(value);}else{}};this.bindFloatArrayBuffer=function(name,buffer){var attr=attributes[name];
if(attr){attr.bindFloatArrayBuffer(buffer);}else{}};this.bindTexture=function(name,texture,unit){var sampler=samplers[name];if(sampler){sampler.bindTexture(texture,unit);}else{}};this.unbind=function(){};this.destroy=function(){if(this.valid){context.deleteProgram(handle);for(var s in shaders){context.deleteShader(shaders[s].handle);
}attributes=null;uniforms=null;samplers=null;this.valid=false;}};};SceneJS._webgl_Texture2D=function(context,cfg){this.canvas=cfg.canvas;this.textureId=cfg.textureId;this.handle=context.createTexture();this.target=context.TEXTURE_2D;this.minFilter=cfg.minFilter;this.magFilter=cfg.magFilter;this.wrapS=cfg.wrapS;
this.wrapT=cfg.wrapT;context.bindTexture(this.target,this.handle);if(cfg.image){try{context.texImage2D(context.TEXTURE_2D,0,context.RGBA,context.RGBA,context.UNSIGNED_BYTE,cfg.image);}catch(e){context.texImage2D(context.TEXTURE_2D,0,cfg.image,cfg.flipY);}this.format=context.RGBA;this.width=cfg.image.width;
this.height=cfg.image.height;this.isDepth=false;this.depthMode=0;this.depthCompareMode=0;this.depthCompareFunc=0;}else{if(!cfg.texels){if(cfg.sourceType==context.FLOAT){cfg.texels=new Float32Array(cfg.width*cfg.height*4);}else{cfg.texels=new WebGLUnsignedByteArray(cfg.width*cfg.height*4);}}context.texImage2D(context.TEXTURE_2D,0,cfg.internalFormat,cfg.width,cfg.height,0,cfg.sourceFormat,cfg.sourceType,cfg.texels);
if(cfg.isDepth){if(cfg.depthMode){context.texParameteri(context.TEXTURE_2D,context.DEPTH_TEXTURE_MODE,cfg.depthMode);}if(cfg.depthCompareMode){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_COMPARE_MODE,cfg.depthCompareMode);}if(cfg.depthCompareFunc){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_COMPARE_FUNC,cfg.depthCompareFunc);
}}this.format=cfg.internalFormat;this.width=cfg.width;this.height=cfg.height;this.isDepth=cfg.isDepth;this.depthMode=cfg.depthMode;this.depthCompareMode=cfg.depthCompareMode;this.depthCompareFunc=cfg.depthCompareFunc;}if(cfg.minFilter){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_MIN_FILTER,cfg.minFilter);
}if(cfg.magFilter){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_MAG_FILTER,cfg.magFilter);}if(cfg.wrapS){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_WRAP_S,cfg.wrapS);}if(cfg.wrapT){context.texParameteri(context.TEXTURE_2D,context.TEXTURE_WRAP_T,cfg.wrapT);}if(cfg.minFilter==context.NEAREST_MIPMAP_NEAREST||cfg.minFilter==context.LINEAR_MIPMAP_NEAREST||cfg.minFilter==context.NEAREST_MIPMAP_LINEAR||cfg.minFilter==context.LINEAR_MIPMAP_LINEAR){context.generateMipmap(context.TEXTURE_2D);
}context.bindTexture(this.target,null);this.bind=function(unit){context.activeTexture(context["TEXTURE"+unit]);context.bindTexture(this.target,this.handle);};this.unbind=function(unit){context.activeTexture(context["TEXTURE"+unit]);context.bindTexture(this.target,null);};this.generateMipmap=function(){context.generateMipmap(context.TEXTURE_2D);
};this.destroy=function(){if(this.handle){context.deleteTexture(this.handle);this.handle=null;}};};SceneJS._webgl_ArrayBuffer=function(context,type,values,numItems,itemSize,usage){this.handle=context.createBuffer();context.bindBuffer(type,this.handle);context.bufferData(type,values,usage);this.handle.numItems=numItems;
this.handle.itemSize=itemSize;context.bindBuffer(type,null);this.type=type;this.numItems=numItems;this.itemSize=itemSize;this.bind=function(){context.bindBuffer(type,this.handle);};this.unbind=function(){context.bindBuffer(type,null);};this.destroy=function(){context.deleteBuffer(this.handle);};};WebGLDebugUtils=function(){var log=function(msg){if(window.console&&window.console.log){window.console.log(msg);
}};var glValidEnumContexts={"enable":{0:true},"disable":{0:true},"getParameter":{0:true},"drawArrays":{0:true},"drawElements":{0:true,2:true},"createShader":{0:true},"getShaderParameter":{1:true},"getProgramParameter":{1:true},"getVertexAttrib":{1:true},"vertexAttribPointer":{2:true},"bindTexture":{0:true},"activeTexture":{0:true},"getTexParameter":{0:true,1:true},"texParameterf":{0:true,1:true},"texParameteri":{0:true,1:true,2:true},"texImage2D":{0:true,2:true,6:true,7:true},"texSubImage2D":{0:true,6:true,7:true},"copyTexImage2D":{0:true,2:true},"copyTexSubImage2D":{0:true},"generateMipmap":{0:true},"bindBuffer":{0:true},"bufferData":{0:true,2:true},"bufferSubData":{0:true},"getBufferParameter":{0:true,1:true},"pixelStorei":{0:true,1:true},"readPixels":{4:true,5:true},"bindRenderbuffer":{0:true},"bindFramebuffer":{0:true},"checkFramebufferStatus":{0:true},"framebufferRenderbuffer":{0:true,1:true,2:true},"framebufferTexture2D":{0:true,1:true,2:true},"getFramebufferAttachmentParameter":{0:true,1:true,2:true},"getRenderbufferParameter":{0:true,1:true},"renderbufferStorage":{0:true,1:true},"clear":{0:true},"depthFunc":{0:true},"blendFunc":{0:true,1:true},"blendFuncSeparate":{0:true,1:true,2:true,3:true},"blendEquation":{0:true},"blendEquationSeparate":{0:true,1:true},"stencilFunc":{0:true},"stencilFuncSeparate":{0:true,1:true},"stencilMaskSeparate":{0:true},"stencilOp":{0:true,1:true,2:true},"stencilOpSeparate":{0:true,1:true,2:true,3:true},"cullFace":{0:true},"frontFace":{0:true}};
var glEnums=null;function init(ctx){if(glEnums==null){glEnums={};for(var propertyName in ctx){if(typeof ctx[propertyName]=="number"){glEnums[ctx[propertyName]]=propertyName;}}}}function checkInit(){if(glEnums==null){throw"WebGLDebugUtils.init(ctx) not called";}}function mightBeEnum(value){checkInit();
return(glEnums[value]!==undefined);}function mightBeValidEnum(fname,i,value){if(!mightBeEnum(value)){return false;}return(fname in glValidEnumContexts)&&(i in glValidEnumContexts[fname]);}function glEnumToString(value){checkInit();var name=glEnums[value];return(name!==undefined)?name:("*UNKNOWN WebGL ENUM (0x"+value.toString(16)+")");
}function makeDebugContext(ctx,opt_onErrorFunc){init(ctx);function formatFunctionCall(functionName,args){var argStr="";for(var ii=0;ii<args.length;++ii){argStr+=((ii==0)?"":", ")+(mightBeEnum(args[ii])?glEnumToString(args[ii]):args[ii]);}return functionName+"("+argStr+")";}opt_onErrorFunc=opt_onErrorFunc||function(err,functionName,args){log("WebGL error "+glEnumToString(err)+" in "+formatFunctionCall(functionName,args));
};var glErrorShadow={};var tracing=false;ctx.setTracing=function(newTracing){if(!tracing&&newTracing){log("gl.setTracing("+newTracing+");");}tracing=newTracing;};var escapeDict={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"};function quote(s){var q="'";var l=s.length;
for(var i=0;i<l;i++){var c=s.charAt(i);var d=s.charCodeAt(i);var e=escapeDict[c];if(e!=undefined){q+=e;}else{if(d<32||d>=128){var h="000"+d.toString(16);q+="\\u"+h.substring(h.length-4);}else{q+=s.charAt(i);}}}q+="'";return q;}function genSymMaker(name){var counter=0;return function(){var sym=name+counter;
counter++;return sym;};}var constructorDict={"createBuffer":genSymMaker("buffer"),"createFrameBuffer":genSymMaker("frameBuffer"),"createProgram":genSymMaker("program"),"createRenderbuffer":genSymMaker("renderBuffer"),"createShader":genSymMaker("shader"),"createTexture":genSymMaker("texture"),"getUniformLocation":genSymMaker("uniformLocation"),"readPixels":genSymMaker("pixels")};
var objectNameProperty="__webgl_trace_name__";var arrayTypeDict={"[object WebGLByteArray]":"WebGLByteArray","[object WebGLUnsignedByteArray]":"WebGLUnsignedByteArray","[object WebGLShortArray]":"WebGLShortArray","[object Uint16Array]":"Uint16Array","[object WebGLIntArray]":"WebGLIntArray","[object WebGLUnsignedIntArray]":"WebGLUnsignedIntArray","[object Float32Array]":"Float32Array"};
function asWebGLArray(a){var arrayType=arrayTypeDict[a];if(arrayType===undefined){return undefined;}var buf="new "+arrayType+"( [";buf+="] )";return buf;}function traceFunctionCall(functionName,args){var argStr="";for(var ii=0;ii<args.length;++ii){var arg=args[ii];if(ii>0){argStr+=", ";}var objectName;
try{if(arg!==null&&arg!==undefined){objectName=arg[objectNameProperty];}}catch(e){alert(functionName);throw e;}var webGLArray=asWebGLArray(arg);if(objectName!=undefined){argStr+=objectName;}else{if(webGLArray!=undefined){argStr+=webGLArray;}else{if(typeof(arg)=="string"){argStr+=quote(arg);}else{if(mightBeValidEnum(functionName,ii,arg)){argStr+="gl."+glEnumToString(arg);
}else{argStr+=arg;}}}}}return"gl."+functionName+"("+argStr+");";}function makeErrorWrapper(ctx,functionName){return function(){var resultName;if(tracing){var prefix="";objectNamer=constructorDict[functionName];if(objectNamer!=undefined){resultName=objectNamer();prefix="var "+resultName+" = ";}log(prefix+traceFunctionCall(functionName,arguments));
}var result=ctx[functionName].apply(ctx,arguments);if(tracing&&resultName!=undefined){result[objectNameProperty]=resultName;}var err=ctx.getError();if(err!=0){glErrorShadow[err]=true;opt_onErrorFunc(err,functionName,arguments);}return result;};}var wrapper={};for(var propertyName in ctx){if(typeof ctx[propertyName]=="function"){wrapper[propertyName]=makeErrorWrapper(ctx,propertyName);
}else{wrapper[propertyName]=ctx[propertyName];}}wrapper.getError=function(){for(var err in glErrorShadow){if(glErrorShadow[err]){glErrorShadow[err]=false;return err;}}return ctx.NO_ERROR;};return wrapper;}return{"init":init,"mightBeEnum":mightBeEnum,"glEnumToString":glEnumToString,"makeDebugContext":makeDebugContext};
}();SceneJS.Node=function(){this._attr={};this._attr.nodeType="node";this._attr.NODEINFO=null;this._attr.sid=null;this._attr.flags=null;this._attr.data={};this._attr.enabled=true;this._rendering=false;this._children=[];this._parent=null;this._listeners={};this._numListeners=0;this._setDirty();if(this._attr.id){SceneJS._nodeIDMap[this._attr.id]=undefined;
}SceneJS.Node._ArgParser.parseArgs(arguments,this);if(!this._attr.id){this._attr.id=SceneJS._createKeyForMap(SceneJS._nodeIDMap,"n");}SceneJS._nodeIDMap[this._attr.id]=this;if(this._init){this._init(this._getParams());}};SceneJS.Node.prototype.constructor=SceneJS.Node;SceneJS.Node._ArgParser=new (function(){this.parseArgs=function(args,node){node._getParams=function(){return{};
};node._params={};if(args.length>0){var arg=args[0];if(!arg){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("First element in node config is null or undefined"));}if(arg._render){this._parseChild(arg,args,1,node);}else{this._parseConfigObject(arg,args,1,node);}}};
this._parseConfigObject=function(arg,args,i,node){var cfg=arg;var param;for(var key in cfg){if(cfg.hasOwnProperty(key)){param=cfg[key];if(param!=null){if(key=="id"){node._attr.id=param;}else{if(key=="sid"){node._attr.sid=param;}else{if(key=="info"){node._attr.NODEINFO=param;}else{if(key=="data"){node._attr.data=param;
}else{if(key=="flags"){node._attr.flags=param;}else{if(key=="enabled"){node._attr.enabled=param;}else{if(key=="layer"){node._nodeLayer=param;}else{node._params[key]=param;}}}}}}}}}}node._getParams=(function(){var _config=node._params;node._params={};return function(){return _config;};})();if(i<args.length){arg=args[i];
if(arg._render){this._parseChild(arg,args,i+1,node);}else{throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Unexpected type for node argument "+i+" - expected a child node"));}}};this._parseChild=function(arg,args,i,node){node._children.push(arg);arg._parent=node;arg._resetMemoLevel();
if(i<args.length){arg=args[i];if(!arg){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Node argument "+i+" is null or undefined"));}if(arg._attr){this._parseChild(arg,args,i+1,node);}else{throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Unexpected type for node argument "+i+" - expected a child node"));
}}};})();SceneJS.Node.prototype._setDirty=function(){this._memoLevel=0;};SceneJS.Node.prototype._resetMemoLevel=function(){this._setDirty();for(var i=0;i<this._children.length;i++){this._children[i]._resetMemoLevel();}};SceneJS.Node.prototype._render=function(traversalContext){this._renderNodes(traversalContext);
};SceneJS.Node.prototype._renderNodes=function(traversalContext,selectedChildren){var flags=SceneJS._flagsModule.flags;if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&flags.picking){SceneJS._pickModule.pushNode(this);}if(this._listeners["pre-rendered"]){this._fireEvent("pre-rendered",{});
}var children=selectedChildren||this._children;var numChildren=children.length;var child;var i;if(numChildren>0){var childTraversalContext;for(i=0;i<numChildren;i++){child=children[i];if(child._attr.enabled&&(!child._attr.flags||child._attr.flags.enabled!=false)){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&(child._attr.flags&&!child._attr.flags.picking)){continue;
}childTraversalContext={insideRightFringe:traversalContext.insideRightFringe||(i<numChildren-1),callback:traversalContext.callback};child._renderWithEvents.call(child,childTraversalContext);}}}if(numChildren==0){if(!traversalContext.insideRightFringe){if(traversalContext.callback){traversalContext.callback(traversalContext);
}}}if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&flags.picking){SceneJS._pickModule.popNode(this);}if(this._listeners["post-rendering"]){this._fireEvent("post-rendering",{});}};SceneJS.Node.prototype._renderWithEvents=function(traversalContext){if(this._nodeLayer){if(!SceneJS._layerModule.layerEnabled(this._nodeLayer)){return;
}SceneJS._layerModule.pushLayer(this._nodeLayer);}this._rendering=true;if(this._attr.flags){SceneJS._flagsModule.pushFlags(this._attr.flags);}if(this._listeners["rendering"]){this._fireEvent("rendering",{});}if(this._listeners["pre-rendering"]){this._fireEvent("pre-rendering",{});}var loadStatusSnapshot;
if(this._listeners["loading-status"]){loadStatusSnapshot=SceneJS._loadStatusModule.getStatusSnapshot();}this._render(traversalContext);if(this._listeners["loading-status"]){this._fireEvent("loading-status",SceneJS._loadStatusModule.diffStatus(loadStatusSnapshot));}if(this._listeners["rendered"]){this._fireEvent("rendered",{});
}if(this._listeners["post-rendered"]){this._fireEvent("post-rendered",{});}this._rendering=false;if(this._attr.flags){SceneJS._flagsModule.popFlags();}if(this._nodeLayer){SceneJS._layerModule.popLayer();}};SceneJS.Node.prototype._renderNodeAtIndex=function(index,traversalContext){if(index>=0&&index<this._children.length){var child=this._children[index];
child._renderWithEvents.call(child,traversalContext);}};SceneJS.Node.prototype.getID=function(){return this._attr.id;};SceneJS.Node.prototype.getId=SceneJS.Node.prototype.getID;SceneJS.Node.prototype.getType=function(){return this._attr.nodeType;};SceneJS.Node.prototype.setFlags=function(flags){this._attr.flags=SceneJS._shallowClone(flags);
};SceneJS.Node.prototype.getFlags=function(){return SceneJS._shallowClone(this._attr.flags||{});};SceneJS.Node.prototype.getData=function(){return this._attr.data;};SceneJS.Node.prototype.setData=function(data){this._attr.data=data;return this;};SceneJS.Node.prototype.getSID=function(){return this._attr.sid;
};SceneJS.Node.prototype.getInfo=function(){return this._attr.NODEINFO||"";};SceneJS.Node.prototype.setInfo=function(info){this._attr.NODEINFO=info;};SceneJS.Node.prototype.getNumNodes=function(){return this._children.length;};SceneJS.Node.prototype.getNodes=function(){var list=new Array(this._children.length);
var len=this._children.length;for(var i=0;i<len;i++){list[i]=this._children[i];}return list;};SceneJS.Node.prototype.getNodeAt=function(index){if(index<0||index>=this._children.length){return null;}return this._children[index];};SceneJS.Node.prototype.getFirstNode=function(){if(this._children.length==0){return null;
}return this._children[0];};SceneJS.Node.prototype.getLastNode=function(){if(this._children.length==0){return null;}return this._children[this._children.length-1];};SceneJS.Node.prototype.getNode=function(id){for(var i=0;i<this._children.length;i++){if(this._children[i].getID()==id){return this._children[i];
}}return null;};SceneJS.Node.prototype.removeNodeAt=function(index){var r=this._children.splice(index,1);this._setDirty();if(r.length>0){r[0]._parent=null;return r[0];}else{return null;}};SceneJS.Node.prototype.removeNode=function(node){if(!node){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#removeNode - node argument undefined"));
}if(!node._render){if(typeof node=="string"){var gotNode=SceneJS._nodeIDMap[node];if(!gotNode){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#removeNode - node not found anywhere: '"+node+"'"));}node=gotNode;}}if(node._render){for(var i=0;i<this._children.length;
i++){if(this._children[i]._attr.id==node._attr.id){this._setDirty();return this.removeNodeAt(i);}}}throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#removeNode - child node not found: "+(node._render?": "+node._attr.id:node)));};SceneJS.Node.prototype.removeNodes=function(){for(var i=0;
i<this._children.length;i++){if(this._children[i]._parent=null){}}var children=this._children;this._children=[];this._setDirty();return children;};SceneJS.Node.prototype.addNodes=function(nodes){if(!nodes){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#addNodes - nodes argument is undefined"));
}for(var i=nodes.length-1;i>=0;i--){this.addNode(nodes[i]);}this._setDirty();return this;};SceneJS.Node.prototype.addNode=function(node){if(!node){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#addNode - node argument is undefined"));}if(!node._render){if(typeof node=="string"){var gotNode=SceneJS._nodeIDMap[node];
if(!gotNode){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#addNode - node not found: '"+node+"'"));}node=gotNode;}else{node=SceneJS._parseNodeJSON(node);}}if(!node._render){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#addNode - node argument is not a SceneJS.Node or subclass!"));
}if(node._parent!=null){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#addNode - node argument is still attached to another parent!"));}this._children.push(node);node._parent=this;node._resetMemoLevel();this._setDirty();return node;};SceneJS.Node.prototype.findNodeIndex=function(sid){for(var i=0;
i<this._children.length;i++){if(this._children[i].getSID()==sid){return i;}}return -1;};SceneJS.Node.prototype.insertNode=function(node,i){if(!node){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#insertNode - node argument is undefined"));}if(!node._render){node=SceneJS._parseNodeJSON(node);
}if(!node._render){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#insertNode - node argument is not a SceneJS.Node or subclass!"));}if(node._parent!=null){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#insertNode - node argument is still attached to another parent!"));
}if(i==undefined||i==null){var children=this.removeNodes();var leaf=node;while(leaf.getNumNodes()>0){leaf=leaf.getLastNode();}leaf.addNodes(children);this.addNode(node);}else{if(i<=0){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidSceneGraphException("SceneJS.Node#insertNode - node index out of range: -1"));
}else{if(i>=this._children.length){this._children.push(node);}else{this._children.splice(i,0,node);}}}node._parent=this;node._resetMemoLevel();this._setDirty();return node;};SceneJS.Node.prototype.mapNodes=function(func){if(func(this)){return this;}var result;for(var i=0;i<this._children.length;i++){result=this._children[i].mapNodes(func);
if(result){return result;}}return null;};SceneJS.Node.prototype.addListener=function(eventName,fn,options){var list=this._listeners[eventName];if(!list){list=[];this._listeners[eventName]=list;}list.push({eventName:eventName,fn:fn,options:options||{}});this._numListeners++;this._setDirty();return this;
};SceneJS.Node.prototype.setEnabled=function(enabled){this._attr.enabled=enabled;this._setDirty();return this;};SceneJS.Node.prototype.getEnabled=function(){return this._attr.enabled;};SceneJS.Node.prototype.destroy=function(){if(!this._destroyed){this._destroyed=true;SceneJS._scheduleNodeDestroy(this);
}return this;};SceneJS.Node.prototype._doDestroy=function(){if(this._destroy){this._destroy();}if(this._parent){this._parent.removeNode(this);}SceneJS._nodeIDMap[this._attr.id]=null;if(this._children.length>0){var children=this._children.slice(0);for(var i=0;i<children.length;i++){children[i]._doDestroy();
}}return this;};SceneJS.Node.prototype._fireEvent=function(eventName,params){var list=this._listeners[eventName];if(list){if(!params){params={};}var event={name:eventName,params:params};var listener;for(var i=0,len=list.length;i<len;i++){listener=list[i];if(listener.options.scope){listener.fn.call(listener.options.scope,event);
}else{listener.fn.call(this,event);}}}};SceneJS.Node.prototype.removeListener=function(eventName,fn){var list=this._listeners[eventName];if(!list){return null;}for(var i=0;i<list.length;i++){if(list[i].fn==fn){list.splice(i,1);return fn;}}this._numListeners--;return null;};SceneJS.Node.prototype.hasListener=function(eventName){return this._listeners[eventName];
};SceneJS.Node.prototype.hasListeners=function(){return(this._numListeners>0);};SceneJS.Node.prototype.removeListeners=function(){this._listeners={};this._numListeners=0;return this;};SceneJS.Node.prototype.getParent=function(){return this._parent;};SceneJS.Node.prototype.findNodesByType=function(type,recursive){return this._findNodesByType(type,[],recursive);
};SceneJS.Node.prototype._findNodesByType=function(type,list,recursive){for(var i=0;i<this._children;i++){var node=this._children[i];if(node.nodeType==type){list.add(node);}}if(recursive){for(var i=0;i<this._children;i++){this._children[i]._findNodesByType(type,list,recursive);}}return list;};SceneJS.Node.prototype.getJSON=function(){return this._attr;
};SceneJS.node=function(){var n=new SceneJS.Node();SceneJS.Node.prototype.constructor.apply(n,arguments);return n;};SceneJS._registerNode("node",SceneJS.Node,SceneJS.node);SceneJS._eventModule=new (function(){this.ERROR=0;this.INIT=1;this.RESET=2;this.TIME_UPDATED=3;this.SCENE_CREATED=4;this.SCENE_RENDERING=5;
this.SCENE_RENDERED=6;this.SCENE_DESTROYED=7;this.RENDERER_UPDATED=8;this.RENDERER_EXPORTED=9;this.CANVAS_ACTIVATED=10;this.CANVAS_DEACTIVATED=11;this.VIEWPORT_UPDATED=12;this.GEOMETRY_UPDATED=13;this.GEOMETRY_EXPORTED=14;this.MODEL_TRANSFORM_UPDATED=15;this.MODEL_TRANSFORM_EXPORTED=16;this.PROJECTION_TRANSFORM_UPDATED=17;
this.PROJECTION_TRANSFORM_EXPORTED=18;this.VIEW_TRANSFORM_UPDATED=19;this.VIEW_TRANSFORM_EXPORTED=20;this.LIGHTS_UPDATED=21;this.LIGHTS_EXPORTED=22;this.MATERIAL_UPDATED=23;this.MATERIAL_EXPORTED=24;this.TEXTURES_UPDATED=25;this.TEXTURES_EXPORTED=26;this.SHADER_ACTIVATE=27;this.SHADER_ACTIVATED=28;this.SHADER_RENDERING=29;
this.SHADER_NEEDS_BOUNDARIES=30;this.SHADER_DEACTIVATED=31;this.FOG_UPDATED=32;this.FOG_EXPORTED=33;this.NAME_UPDATED=34;this.PROCESS_CREATED=35;this.PROCESS_KILLED=36;this.PROCESS_TIMED_OUT=37;this.LOGGING_ELEMENT_ACTIVATED=38;this.PICK_COLOR_EXPORTED=39;this.BOUNDARY_EXPORTED=40;this.NODE_CREATED=41;
this.NODE_UPDATED=42;this.NODE_DESTROYED=43;this.IMAGEBUFFER_EXPORTED=44;this.CLIP_EXPORTED=45;this.FLAGS_EXPORTED=46;var events=new Array(37);this.addListener=function(type,command,priority){var list=events[type];if(!list){list=[];events[type]=list;}var handler={command:command,priority:(priority==undefined)?list.length:priority};
for(var i=0;i<list.length;i++){if(list[i].priority>handler.priority){list.splice(i,0,handler);return;}}list.push(handler);};this.fireEvent=function(type,params){var list=events[type];if(list){if(!params){params={};}for(var i=0;i<list.length;i++){list[i].command(params);}}};})();SceneJS.bind=function(name,func){switch(name){case"error":SceneJS._eventModule.addListener(SceneJS._eventModule.ERROR,function(params){func({exception:params.exception,fatal:params.fatal});
});break;case"reset":SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){func();});break;case"scene-created":SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_CREATED,function(params){func({sceneId:params.sceneId});});break;case"node-created":SceneJS._eventModule.addListener(SceneJS._eventModule.NODE_CREATED,function(params){func({nodeId:params.nodeId,json:params.json});
});break;case"node-updated":SceneJS._eventModule.addListener(SceneJS._eventModule.NODE_UPDATED,function(params){func({nodeId:params.nodeId});});break;case"node-destroyed":SceneJS._eventModule.addListener(SceneJS._eventModule.NODE_DESTROYED,function(params){func({nodeId:params.nodeId});});break;case"scene-rendering":SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(params){func({sceneId:params.sceneId});
});break;case"canvas-activated":SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(params){func({canvas:params.canvas});});break;case"process-created":SceneJS._eventModule.addListener(SceneJS._eventModule.PROCESS_CREATED,function(params){func(params);});break;case"process-timed-out":SceneJS._eventModule.addListener(SceneJS._eventModule.PROCESS_TIMED_OUT,function(params){func(params);
});break;case"process-killed":SceneJS._eventModule.addListener(SceneJS._eventModule.PROCESS_KILLED,function(params){func(params);});break;case"scene-rendered":SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERED,function(params){func({sceneId:params.sceneId});});break;case"scene-destroyed":SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_DESTROYED,function(params){func({sceneId:params.sceneId});
});break;default:throw"SceneJS.bind - this event type not supported: '"+name+"'";}};SceneJS.addListener=SceneJS.onEvent=SceneJS.bind;SceneJS._loggingModule=new (function(){var activeSceneId;var funcs=null;var queues={};var indent=0;var indentStr="";function log(channel,message){if(SceneJS._isArray(message)){_logHTML(channel,arrayToHTML(message));
for(var i=0;i<message.length;i++){_logToConsole(message[i]);}}else{_logHTML(channel,message);_logToConsole(message);}}function _logHTML(channel,message){message=activeSceneId?indentStr+activeSceneId+": "+message:indentStr+message;var func=funcs?funcs[channel]:null;if(func){func(message);}else{var queue=queues[channel];
if(!queue){queue=queues[channel]=[];}queue.push(message);}}function _logToConsole(message){if(typeof console=="object"){message=activeSceneId?indentStr+activeSceneId+": "+message:indentStr+message;console.log(message);}}function arrayToHTML(array){var array2=[];for(var i=0;i<array.length;i++){var padding=(i<10)?" ":((i<100)?" ":(i<1000?" ":""));
array2.push(i+padding+": "+array[i]);}return array2.join("<br/>");}function logScript(src){for(var i=0;i<src.length;i++){logToConsole(src[i]);}}function flush(channel){var queue=queues[channel];if(queue){var func=funcs?funcs[channel]:null;if(func){for(var i=0;i<queue.length;i++){func(queue[i]);}queues[channel]=[];
}}}SceneJS._eventModule.addListener(SceneJS._eventModule.LOGGING_ELEMENT_ACTIVATED,function(params){var element=params.loggingElement;if(element){funcs={warn:function log(msg){element.innerHTML+='<p style="color:orange;">'+msg+"</p>";},error:function log(msg){element.innerHTML+='<p style="color:darkred;">'+msg+"</p>";
},debug:function log(msg){element.innerHTML+='<p style="color:darkblue;">'+msg+"</p>";},info:function log(msg){element.innerHTML+='<p style="color:darkgreen;">'+msg+"</p>";}};}else{funcs=null;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(params){activeSceneId=params.sceneId;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERED,function(){activeSceneId=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){queues={};funcs=null;},100000);this.setIndent=function(_indent){indent=_indent;var indentArray=[];for(var i=0;i<indent;i++){indentArray.push("----");
}indentStr=indentArray.join("");};this.error=function(msg){log("error",msg);};this.warn=function(msg){log("warn",msg);};this.info=function(msg){log("info",msg);};this.debug=function(msg){log("debug",msg);};this.getFuncs=function(){return funcs;};this.setFuncs=function(l){if(l){funcs=l;for(var channel in queues){flush(channel);
}}};})();SceneJS._errorModule=new (function(){SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){var time=(new Date()).getTime();SceneJS._eventModule.fireEvent(SceneJS._eventModule.TIME_UPDATED,time);});this.fatalError=function(e){e=e.message?e:new SceneJS.errors.Exception(e);
SceneJS._eventModule.fireEvent(SceneJS._eventModule.ERROR,{exception:e,fatal:true});return e.message;};this.error=function(e){e=e.message?e:new SceneJS.errors.Exception(e);SceneJS._loggingModule.error(e.message);SceneJS._eventModule.fireEvent(SceneJS._eventModule.ERROR,{exception:e,fatal:false});return e.message;
};})();SceneJS._timeModule=new (function(){var time=(new Date()).getTime();SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){time=(new Date()).getTime();SceneJS._eventModule.fireEvent(SceneJS._eventModule.TIME_UPDATED,time);});this.getTime=function(){return time;};})();
SceneJS._layerModule=new (function(){this.DEFAULT_LAYER_NAME="___default";var enabledLayers;var layerOrder;var layerStack=new Array(500);var stackLen=0;var self=this;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){self.setActiveLayers(null);stackLen=0;});this.setActiveLayers=function(layers){enabledLayers={};
layerOrder=[{name:this.DEFAULT_LAYER_NAME,priority:0}];if(layers){var priority;for(var layerName in layers){if(layers.hasOwnProperty(layerName)){priority=layers[layerName];insertLayer(layerName,priority);}}}};function insertLayer(layerName,priority){enabledLayers[layerName]=true;var newLayer={name:layerName,priority:priority};
var layer;for(var i=layerOrder.length-1;i>=0;i--){layer=layerOrder[i];if(layer.priority>priority){layerOrder.splice(i,0,newLayer);return;}}layerOrder.push(newLayer);}this.getLayerOrder=function(){return layerOrder;};this.getEnabledLayers=function(){return enabledLayers;};this.layerEnabled=function(layer){return(layerOrder.length==0)||(enabledLayers[layer]===true);
};this.pushLayer=function(layer){layerStack[stackLen++]=layer;};this.getLayer=function(){return stackLen==0?undefined:layerStack[stackLen-1];};this.popLayer=function(){stackLen--;};})();SceneJS._memoryModule=new (function(){var evictors=[];var iEvictor=0;SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){iEvictor=0;
});function evict(){if(evictors.length==0){return false;}var tries=0;while(true){if(iEvictor>evictors.length){iEvictor=0;}if(evictors[iEvictor++]()){SceneJS._loggingModule.warn("Evicted least-used item from memory");return true;}else{tries++;if(tries==evictors.length){return false;}}}}function outOfMemory(description){SceneJS._loggingModule.error("Memory allocation failed");
throw SceneJS._errorModule.fatalError(new SceneJS.errors.OutOfVRAMException("Out of memory - failed to allocate memory for "+description));}this.registerEvictor=function(evict){evictors.push(evict);};this.allocate=function(context,description,tryAllocate){var maxTries=10;var tries=0;while(true){try{tryAllocate();
if(context.getError()==context.OUT_OF_MEMORY){outOfMemory(description);}return;}catch(e){if(context.getError()!=context.OUT_OF_MEMORY){SceneJS._loggingModule.error(e.message||e);throw e;}if(++tries>maxTries||!evict()){outOfMemory(description);}}}};})();SceneJS._instancingModule=new function(){var countInstances=0;
var instances={};SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){countInstances=0;instances={};});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){countInstances=0;instances={};});this.acquireInstance=function(nodeID){if(instances[nodeID]){SceneJS._errorModule.error(new SceneJS.errors.CyclicInstanceException("SceneJS.Instance attempted to create cyclic instantiation: "+nodeID));
return null;}var node=SceneJS._nodeIDMap[nodeID];if(!node){var nodeStore=SceneJS.Services.getService(SceneJS.Services.NODE_LOADER_SERVICE_ID);if(nodeStore){node=nodeStore.loadNode(nodeID);}}if(node){instances[nodeID]=nodeID;countInstances++;}return node;};this.instancing=function(){return countInstances>0;
};this.releaseInstance=function(nodeID){instances[nodeID]=undefined;countInstances--;};}();SceneJS.Library=SceneJS.createNodeType("library");SceneJS.Library.prototype._render=function(){};SceneJS.Instance=SceneJS.createNodeType("instance");SceneJS.Instance.prototype._init=function(params){this.setTarget(params.target);
this._attr.mustExist=params.mustExist;this._attr.retry=(params.retry==null||params.retry==undefined)?false:params.retry;this._symbol=null;if(this._attr.target){this._state=this._attr.target?SceneJS.Instance.STATE_SEARCHING:SceneJS.Instance.STATE_INITIAL;}};SceneJS.Instance.STATE_INITIAL="init";SceneJS.Instance.STATE_ERROR="error";
SceneJS.Instance.STATE_SEARCHING="searching";SceneJS.Instance.STATE_CONNECTED="connected";SceneJS.Instance.prototype.getState=function(){return this._state;};SceneJS.Instance.prototype.getTarget=function(){return this._attr.target;};SceneJS.Instance.prototype.setTarget=function(target){var map;if(this._attr.target){map=SceneJS._nodeInstanceMap[this._attr.target];
if(!map){map=SceneJS._nodeInstanceMap[this._attr.target]={numInstances:0,instances:{}};}map.numInstances--;map.instances[this._attr.id]=undefined;}this._attr.target=target;if(target){map=SceneJS._nodeInstanceMap[target];if(!map){map=SceneJS._nodeInstanceMap[this._attr.target]={numInstances:0,instances:{}};
}map.numInstances++;map.instances[this._attr.id]=this._attr.id;}this._setDirty();return this;};SceneJS.Instance.prototype._render=function(traversalContext){if(this._attr.target){var nodeId=this._attr.target;this._symbol=SceneJS._instancingModule.acquireInstance(nodeId);if(!this._symbol){var exception;
if(this._attr.mustExist){throw SceneJS._errorModule.fatalError(exception=new SceneJS.errors.SymbolNotFoundException("SceneJS.Instance could not find target node: '"+this._attr.target+"'"));}this._changeState(SceneJS.Instance.STATE_ERROR,exception);if(this._attr.retry){SceneJS._needFrame=true;SceneJS._loadStatusModule.status.numNodesLoading++;
}}else{SceneJS._loadStatusModule.status.numNodesLoaded++;this._changeState(SceneJS.Instance.STATE_CONNECTED);this._symbol._renderWithEvents(this._createTargetTraversalContext(traversalContext,this._symbol));SceneJS._instancingModule.releaseInstance(nodeId);this._changeState(SceneJS.Instance.STATE_SEARCHING);
this._symbol=null;}}};SceneJS.Instance.prototype._changeState=function(newState,exception){var oldState=this._state;this._state=newState;if(this._numListeners>0&&this._listeners["state-changed"]){this._fireEvent("state-changed",{oldState:oldState,newState:newState,exception:exception});}};SceneJS.Instance.prototype._createTargetTraversalContext=function(traversalContext,target){this._superCallback=traversalContext.callback;
var _this=this;if(!this._callback){this._callback=function(traversalContext){var subTraversalContext={callback:_this._superCallback,insideRightFringe:_this._children.length>1};_this._renderNodes(subTraversalContext);};}return{callback:this._callback,insideRightFringe:target._children.length>1};};SceneJS.Instance.prototype._destroy=function(){if(this._attr.target){var map=SceneJS._nodeInstanceMap[this._attr.target];
if(map){map.numInstances--;map.instances[this._attr.id]=undefined;}}};SceneJS.Instance.prototype.queryState=function(){return this._state;};SceneJS.Instance.prototype.queryTargetNode=function(){if(this._state!=SceneJS.Instance.STATE_CONNECTED){return null;}return SceneJS.withNode(this._symbol);};SceneJS.Selector=SceneJS.createNodeType("selector");
SceneJS.Selector.prototype._init=function(params){this.setSelection(params.selection);};SceneJS.Selector.prototype.setSelection=function(selection){this._attr.selection=selection||[];this._setDirty();return this;};SceneJS.Selector.prototype.getSelection=function(){var selection=new Array(this._attr.selection.length);
for(var i=0;i<this._attr.selection.length;i++){selection[i]=this._attr.selection[i];}return selection;};SceneJS.Selector.prototype._render=function(traversalContext){if(this._attr.selection.length>0){var children=[];for(var i=0,len=this._attr.selection.length;i<len;i++){var j=this._attr.selection[i];
if(0<=j&&j<this._children.length){children.push(this._children[j]);}}this._renderNodes(traversalContext,children);}};SceneJS._processModule=new (function(){var time=(new Date()).getTime();var groups={};var activeSceneId;SceneJS._eventModule.addListener(SceneJS._eventModule.TIME_UPDATED,function(t){time=t;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_CREATED,function(params){var group={sceneId:params.sceneId,processes:{},numProcesses:0};groups[params.sceneId]=group;});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(params){activeSceneId=params.sceneId;});
SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERED,function(){var group=groups[activeSceneId];var processes=group.processes;for(var pid in processes){var process=processes[pid];if(process){if(process.destroyed){processes[pid]=undefined;group.numProcesses--;}else{var elapsed=time-process.timeStarted;
if((process.timeoutSecs>-1)&&(elapsed>(process.timeoutSecs*1000))){SceneJS._loggingModule.warn("Process timed out after "+process.timeoutSecs+" seconds: "+process.description);SceneJS._eventModule.fireEvent(SceneJS._eventModule.PROCESS_TIMED_OUT,{sceneId:activeSceneId,process:{id:process.id,timeStarted:process.timeStarted,description:process.description,timeoutSecs:process.timeoutSecs}});
process.destroyed=true;processes[pid]=undefined;group.numProcesses--;if(process.onTimeout){process.onTimeout();}}else{process.timeRunning=elapsed;}}}}activeSceneId=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_DESTROYED,function(params){groups[params.sceneId]=undefined;});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(params){groups={};
activeSceneId=null;});this.createProcess=function(cfg){if(!activeSceneId){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NoSceneActiveException("No scene active - can't create process"));}var group=groups[activeSceneId];var i=0;while(true){var pid=activeSceneId+i++;if(!group.processes[pid]){var process={sceneId:activeSceneId,id:pid,timeStarted:time,timeRunning:0,description:cfg.description||"",type:cfg.type,info:cfg.info,timeoutSecs:cfg.timeoutSecs||30,onTimeout:cfg.onTimeout};
group.processes[pid]=process;group.numProcesses++;SceneJS._eventModule.fireEvent(SceneJS._eventModule.PROCESS_CREATED,{sceneId:activeSceneId,process:{id:process.id,timeStarted:process.timeStarted,description:process.description,type:process.type,info:process.info,timeoutSecs:process.timeoutSecs}});return process;
}}};this.killProcess=function(process){if(process){process.destroyed=true;SceneJS._eventModule.fireEvent(SceneJS._eventModule.PROCESS_KILLED,{sceneId:activeSceneId,process:{id:process.id,timeStarted:process.timeStarted,description:process.description,type:process.type,info:process.info,timeoutSecs:process.timeoutSecs}});
}};this.getNumProcesses=function(sceneId){var group=groups[sceneId];if(!group){return 0;}return sceneId?group.numProcesses:(activeSceneId?groups[activeSceneId].numProcesses:0);};this.getProcesses=function(sceneId){var group=groups[sceneId];if(!group){return{};}return sceneId?group.processes:(activeSceneId?groups[activeSceneId].processes:{});
};})();SceneJS._sceneModule=new (function(){var initialised=false;var scenes={};var nScenes=0;var activeSceneId;var projMat;var viewMat;SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){scenes={};nScenes=0;activeSceneId=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.PROJECTION_TRANSFORM_UPDATED,function(params){projMat=params.matrix;
});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(params){viewMat=params.matrix;});function findLoggingElement(loggingElementId){var element;if(!loggingElementId){element=document.getElementById(SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID);if(!element){SceneJS._loggingModule.info("SceneJS.Scene config 'loggingElementId' omitted and failed to find default logging element with ID '"+SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID+"' - that's OK, logging to browser console instead");
}}else{element=document.getElementById(loggingElementId);if(!element){element=document.getElementById(SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID);if(!element){SceneJS._loggingModule.info("SceneJS.Scene config 'loggingElementId' unresolved and failed to find default logging element with ID '"+SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID+"' - that's OK, logging to browser console instead");
}else{SceneJS._loggingModule.info("SceneJS.Scene config 'loggingElementId' unresolved - found default logging element with ID '"+SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID+"' - logging to browser console also");}}else{SceneJS._loggingModule.info("SceneJS.Scene logging to element with ID '"+loggingElementId+"' - logging to browser console also");
}}return element;}function findCanvas(canvasId){var canvas;if(!canvasId){SceneJS._loggingModule.info("SceneJS.Scene config 'canvasId' omitted - looking for default canvas with ID '"+SceneJS.Scene.DEFAULT_CANVAS_ID+"'");canvasId=SceneJS.Scene.DEFAULT_CANVAS_ID;canvas=document.getElementById(canvasId);
if(!canvas){throw SceneJS._errorModule.fatalError(new SceneJS.errors.CanvasNotFoundException("SceneJS.Scene failed to find default canvas with ID '"+SceneJS.Scene.DEFAULT_CANVAS_ID+"'"));}}else{canvas=document.getElementById(canvasId);if(canvas){SceneJS._loggingModule.info("SceneJS.Scene binding to canvas '"+canvasId+"'");
}else{SceneJS._loggingModule.info("SceneJS.Scene config 'canvasId' unresolved - looking for default canvas with "+"ID '"+SceneJS.Scene.DEFAULT_CANVAS_ID+"'");canvasId=SceneJS.Scene.DEFAULT_CANVAS_ID;canvas=document.getElementById(canvasId);if(!canvas){throw SceneJS._errorModule.fatalError(new SceneJS.errors.CanvasNotFoundException("SceneJS.Scene config 'canvasId' does not match any elements in the page and no "+"default canvas found with ID '"+SceneJS.Scene.DEFAULT_CANVAS_ID+"'"));
}}}var context;var contextNames=SceneJS.SUPPORTED_WEBGL_CONTEXT_NAMES;for(var i=0;(!context)&&i<contextNames.length;i++){try{if(SceneJS._debugModule.getConfigs("webgl.logTrace")==true){context=canvas.getContext(contextNames[i]);if(context){context=WebGLDebugUtils.makeDebugContext(context,function(err,functionName,args){SceneJS._loggingModule.error("WebGL error calling "+functionName+" on WebGL canvas context - see console log for details");
});context.setTracing(true);}}else{context=canvas.getContext(contextNames[i]);}}catch(e){}}if(!context){throw SceneJS._errorModule.fatalError(new SceneJS.errors.WebGLNotSupportedException("Canvas document element with ID '"+canvasId+"' failed to provide a supported WebGL context"));}context.clearColor(0,0,0,1);
context.clearDepth(1);context.enable(context.DEPTH_TEST);context.disable(context.CULL_FACE);context.depthRange(0,1);context.disable(context.SCISSOR_TEST);return{canvas:canvas,context:context,canvasId:canvasId};}this.createScene=function(scene,params){if(!initialised){SceneJS._loggingModule.info("SceneJS V"+SceneJS.VERSION+" initialised");
SceneJS._eventModule.fireEvent(SceneJS._eventModule.INIT);}var canvas=findCanvas(params.canvasId);var loggingElement=findLoggingElement(params.loggingElementId);var sceneId=SceneJS._createKeyForMap(scenes,"s");scenes[sceneId]={sceneId:sceneId,scene:scene,canvas:canvas,loggingElement:loggingElement};nScenes++;
SceneJS._eventModule.fireEvent(SceneJS._eventModule.SCENE_CREATED,{sceneId:sceneId});SceneJS._loggingModule.info("Scene defined: "+sceneId);return sceneId;};this.destroyScene=function(sceneId){scenes[sceneId]=null;nScenes--;SceneJS._eventModule.fireEvent(SceneJS._eventModule.SCENE_DESTROYED,{sceneId:sceneId});
if(activeSceneId==sceneId){activeSceneId=null;}SceneJS._loggingModule.info("Scene destroyed: "+sceneId);if(nScenes==0){SceneJS._loggingModule.info("SceneJS reset");SceneJS._eventModule.fireEvent(SceneJS._eventModule.RESET);}};this.activateScene=function(sceneId){var scene=scenes[sceneId];if(!scene){throw SceneJS._errorModule.fatalError("Scene not defined: '"+sceneId+"'");
}activeSceneId=sceneId;SceneJS._eventModule.fireEvent(SceneJS._eventModule.LOGGING_ELEMENT_ACTIVATED,{loggingElement:scene.loggingElement});SceneJS._eventModule.fireEvent(SceneJS._eventModule.SCENE_RENDERING,{sceneId:sceneId,nodeId:sceneId,canvas:scene.canvas});SceneJS._eventModule.fireEvent(SceneJS._eventModule.CANVAS_ACTIVATED,scene.canvas);
};this.redrawScene=function(sceneId){var scene=scenes[sceneId];if(!scene){throw SceneJS._errorModule.fatalError("Scene not defined: '"+sceneId+"'");}SceneJS._eventModule.fireEvent(SceneJS._eventModule.CANVAS_ACTIVATED,scene.canvas);SceneJS._shaderModule.redraw();SceneJS._eventModule.fireEvent(SceneJS._eventModule.CANVAS_DEACTIVATED,scene.canvas);
};this.getSceneCanvas=function(sceneId){var scene=scenes[sceneId];if(!scene){throw SceneJS._errorModule.fatalError("Scene not defined: '"+sceneId+"'");}return scene.canvas.canvas;};this.getAllScenes=function(){var list=[];for(var id in scenes){var scene=scenes[id];if(scene){list.push(scene.scene);}}return list;
};this.getScene=function(sceneId){return scenes[sceneId].scene;};this.deactivateScene=function(){if(!activeSceneId){throw SceneJS._errorModule.fatalError("Internal error: no scene active");}var sceneId=activeSceneId;activeSceneId=null;var scene=scenes[sceneId];if(!scene){throw SceneJS._errorModule.fatalError("Scene not defined: '"+sceneId+"'");
}SceneJS._eventModule.fireEvent(SceneJS._eventModule.CANVAS_DEACTIVATED,scene.canvas);SceneJS._eventModule.fireEvent(SceneJS._eventModule.SCENE_RENDERED,{sceneId:sceneId});};})();SceneJS.Scene=SceneJS.createNodeType("scene");SceneJS.Scene.prototype._init=function(params){if(params.canvasId){this._canvasId=document.getElementById(params.canvasId)?params.canvasId:SceneJS.Scene.DEFAULT_CANVAS_ID;
}else{this._canvasId=SceneJS.Scene.DEFAULT_CANVAS_ID;}this._loggingElementId=params.loggingElementId;this.setLayers(params.layers);this._destroyed=false;};SceneJS.Scene.DEFAULT_CANVAS_ID="_scenejs-default-canvas";SceneJS.Scene.DEFAULT_LOGGING_ELEMENT_ID="_scenejs-default-logging";SceneJS.Scene.prototype.getCanvasId=function(){return this._canvasId;
};SceneJS.Scene.prototype.setLayers=function(layers){this._layers=layers||{};};SceneJS.Scene.prototype.getLayers=function(){return this._layers;};SceneJS.Scene.prototype.start=function(cfg){if(this._destroyed){throw new SceneJS.errors.InvalidSceneGraphException("Attempted start on Scene that has been destroyed");
}if(!this._running){this._running=true;var self=this;var fnName="__scenejs_renderScene"+this._sceneId;window[fnName]=function(){if(cfg.idleFunc){cfg.idleFunc();}if(self._running){if(SceneJS._needFrame){SceneJS._needFrame=false;self._renderWithEvents();}}};this._pInterval=setInterval("window['"+fnName+"']()",1000/(cfg.fps||100));
}};SceneJS.Scene.prototype.isRunning=function(){return this._running;};SceneJS.Scene.prototype.render=function(){if(this._destroyed){throw new SceneJS.errors.InvalidSceneGraphException("Attempted render on Scene that has been destroyed");}if(!this._running){this._renderWithEvents();}else{SceneJS._needFrame=true;
}};SceneJS.Scene.prototype._render=function(){if(!this._sceneId){this._sceneId=SceneJS._sceneModule.createScene(this,{canvasId:this._canvasId,loggingElementId:this._loggingElementId});}SceneJS._actionNodeDestroys();SceneJS._sceneModule.activateScene(this._sceneId);SceneJS._layerModule.setActiveLayers(this._layers);
var traversalContext={};this._renderNodes(traversalContext);SceneJS._sceneModule.deactivateScene();SceneJS._actionNodeDestroys();};SceneJS.Scene.prototype.pick=function(canvasX,canvasY){if(this._destroyed){throw new SceneJS.errors.InvalidSceneGraphException("Attempted pick on Scene that has been destroyed");
}if(!this._sceneId){throw new SceneJS.errors.InvalidSceneGraphException("Attempted pick on Scene that has not yet rendered");}SceneJS._pickModule.pick(canvasX,canvasY);if(!this._running){this._renderWithEvents();this._renderWithEvents();}else{SceneJS._needFrame=true;}};SceneJS.Scene.prototype.getNumProcesses=function(){return(this._sceneId)?SceneJS._processModule.getNumProcesses(this._sceneId):0;
};SceneJS.Scene.prototype._destroy=function(){if(this._sceneId){this.stop();SceneJS._sceneModule.destroyScene(this._sceneId);this._sceneId=null;this._destroyed=true;}};SceneJS.Scene.prototype.isActive=function(){return(this._sceneId!=null);};SceneJS.Scene.prototype.stop=function(){if(this._running&&this._sceneId){this._running=false;
window["__scenejs_renderScene"+this._sceneId]=null;window.clearInterval(this._pInterval);}};SceneJS.reset=function(){var scenes=SceneJS._sceneModule.getAllScenes();var temp=[];for(var i=0;i<scenes.length;i++){temp.push(scenes[i]);}while(temp.length>0){temp.pop().destroy();}};SceneJS._shaderModule=new (function(){var debugCfg;
var time=(new Date()).getTime();var canvas;var nextStateId;var flagsState;var rendererState;var lightState;var boundaryState;var colortransState;var materialState;var fogState;var texState;var geoState;var modelXFormState;var viewXFormState;var projXFormState;var pickState;var imageBufState;var clipState;
var deformState;var morphState;var layers={};var programs={};var stateHash=null;SceneJS._memoryModule.registerEvictor(function(){var earliest=time;var programToEvict;for(var hash in programs){if(hash){var program=programs[hash];if(program.lastUsed<earliest){programToEvict=program;earliest=programToEvict.lastUsed;
}}}if(programToEvict){programToEvict.destroy();programs[programToEvict.hash]=null;return true;}return false;});SceneJS._eventModule.addListener(SceneJS._eventModule.TIME_UPDATED,function(t){time=t;});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){for(var programId in programs){programs[programId].destroy();
}programs={};});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(activatedCanvas){debugCfg=SceneJS._debugModule.getConfigs("shading");canvas=activatedCanvas;nextStateId=0;flagsState={flags:{},hash:""};rendererState={props:{},hash:""};lightState={lights:[],hash:""};boundaryState=null;
colortransState={_stateId:nextStateId++,trans:{},hash:""};materialState={material:{_stateId:nextStateId++,baseColor:[0.5,0.5,0.5],specularColor:[0.9,0.9,0.9],specular:200,shine:1,reflect:0,alpha:1,emit:0.7},hash:""};fogState={_stateId:nextStateId++,fog:null,hash:""};texState={_stateId:nextStateId++,layers:[],hash:""};
geoState=null;imageBufState=null;createLayer(SceneJS._layerModule.DEFAULT_LAYER_NAME);clipState={_stateId:nextStateId++,clips:[],hash:""};deformState={_stateId:nextStateId++,deform:null,hash:""};morphState={_stateId:nextStateId++,morph:null,hash:""};stateHash=null;});function createLayer(layerName){layers[layerName]={binSet:{opaqueNodes:[],transpNodes:[]}};
}this.setFlags=function(flags){flagsState={_stateId:nextStateId++,flags:flags};};SceneJS._eventModule.addListener(SceneJS._eventModule.RENDERER_EXPORTED,function(props){rendererState={_stateId:nextStateId++,props:props,hash:""};stateHash=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.TEXTURES_EXPORTED,function(texture){var hashStr;
if(texture.layers.length){var hash=[];for(var i=0;i<texture.layers.length;i++){var layer=texture.layers[i];hash.push("/");hash.push(layer.applyFrom);hash.push("/");hash.push(layer.applyTo);hash.push("/");hash.push(layer.blendMode);if(layer.matrix){hash.push("/anim");}}hashStr=hash.join("");}else{hashStr="__scenejs_no_tex";
}texState={_stateId:nextStateId++,texture:texture,hash:hashStr};stateHash=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.LIGHTS_EXPORTED,function(lights){var hash=[];for(var i=0;i<lights.length;i++){var light=lights[i];hash.push(light.mode);if(light.specular){hash.push("s");}if(light.diffuse){hash.push("d");
}}lightState={_stateId:nextStateId++,lights:lights,hash:hash.join("")};stateHash=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.BOUNDARY_EXPORTED,function(boundary){boundaryState={_stateId:nextStateId++,boundary:boundary.viewBox,hash:""};stateHash=null;});this.setColortrans=function(trans){colortransState={_stateId:nextStateId++,trans:trans,hash:trans?"t":"f"};
stateHash=null;};this.addMaterial=function(material){materialState={_stateId:nextStateId++,material:{baseColor:material.baseColor||[0,0,0],highlightBaseColor:material.highlightBaseColor||material.baseColor||[0,0,0],specularColor:material.specularColor||[0.5,0.5,0.5],specular:material.specular!=undefined?material.specular:2,shine:material.shine!=undefined?material.shine:0.5,reflect:material.reflect!=undefined?material.reflect:0,alpha:material.alpha!=undefined?material.alpha:1,emit:material.emit!=undefined?material.emit:0},hash:""};
stateHash=null;return materialState;};this.updateMaterial=function(materialState,material){materialState.material={baseColor:material.baseColor||[0,0,0],highlightBaseColor:material.highlightBaseColor||material.baseColor||[0,0,0],specularColor:material.specularColor||[0.5,0.5,0.5],specular:material.specular!=undefined?material.specular:2,shine:material.shine!=undefined?material.shine:0.5,reflect:material.reflect!=undefined?material.reflect:0,alpha:material.alpha!=undefined?material.alpha:1,emit:material.emit!=undefined?material.emit:0};
};SceneJS._eventModule.addListener(SceneJS._eventModule.PICK_COLOR_EXPORTED,function(params){pickState={_stateId:nextStateId++,pickColor:params.pickColor,hash:""};stateHash=null;});this.addFog=function(fog){fogState={_stateId:nextStateId++,fog:fog,hash:fog?fog.mode:""};stateHash=null;return fogState;
};this.updateFog=function(fogState,fog){if(fogState.fog.mode!=fog.mode){throw"Shader fog update not compatible with fog - different modes";}fogState.fog=fog;};this.addClips=function(clips){var hash=[];for(var i=0;i<clips.length;i++){var clip=clips[i];hash.push(clip.mode);}clipState={_stateId:nextStateId++,clips:clips,hash:hash.join("")};
stateHash=null;return clipState;};this.updateClips=function(clipsState,clips){clipsState.clips=clips;};this.addDeform=function(deform){deformState={_stateId:nextStateId++,deform:deform,hash:deform?"d"+deform.verts.length:""};stateHash=null;return deformState;};this.updateDeform=function(deformState,deform){if(deformState.verts.length!=deform.verts.length){throw"Shader deform update not compatible with deform";
}deformState.deform=deform;};this.addMorph=function(morph){var hash;if(morph){hash=[];var target1=morph.target1;hash=([target1.vertexBuf?"t":"f",target1.normalBuf?"t":"f",target1.uvBuf?"t":"f",target1.uvBuf2?"t":"f"]).join("");}else{hash="";}morphState={_stateId:nextStateId++,morph:morph,hash:hash};stateHash=null;
return morphState;};this.updateMorph=function(morphState,morph){var newHash=([morph.target1.vertexBuf?"t":"f",morph.target1.normalBuf?"t":"f",morph.target1.uvBuf?"t":"f",morph.target1.uvBuf2?"t":"f"]).join("");if(morphState.hash!=newHash){throw"Shader morph update not compatible with morph";}morphState.morph=morph;
};this.addModelMatrices=function(modelMat,normalMat){modelXFormState={_stateId:nextStateId++,mat:modelMat,normalMat:normalMat};stateHash=null;};this.updateModelMatrices=function(modelXFormState,modelMat,normalMat){modelXFormState.mat=modelMat;modelXFormState.normalMat=normalMat;};this.addViewMatrices=function(viewMat,normalMat){viewXFormState={_stateId:nextStateId++,mat:viewMat,normalMat:normalMat};
stateHash=null;return viewXFormState;};this.updateViewMatrices=function(viewXFormState,viewMat,normalMat){viewXFormState.mat=viewMat;viewXFormState.normalMat=normalMat;};this.addProjectionMatrix=function(projMat){projXFormState={_stateId:nextStateId++,mat:projMat};stateHash=null;return projXFormState;
};this.updateProjectionMatrix=function(projXFormState,projMat){projXFormState.mat=projMat;};this.addImageBuf=function(imageBuf){imageBufState={_stateId:nextStateId++,imageBuf:imageBuf};stateHash=null;};this.setGeometry=function(geo){var layer;var layerName=SceneJS._layerModule.getLayer();if(layerName){if(!layers[layerName]){createLayer(layerName);
}layer=layers[layerName];}else{layer=layers[SceneJS._layerModule.DEFAULT_LAYER_NAME];}geoState={_stateId:nextStateId++,geo:geo,hash:([geo.normalBuf?"t":"f",geo.uvBuf?"t":"f",geo.uvBuf2?"t":"f"]).join("")};SceneJS._eventModule.fireEvent(SceneJS._eventModule.SHADER_RENDERING);if(!stateHash){stateHash=getSceneHash();
}var program=getProgram(stateHash);var node={program:{id:stateHash,program:program},boundaryState:boundaryState,geoState:geoState,flagsState:flagsState,rendererState:rendererState,lightState:lightState,colortransState:colortransState,materialState:materialState,fogState:fogState,modelXFormState:modelXFormState,viewXFormState:viewXFormState,projXFormState:projXFormState,texState:texState,pickState:pickState,imageBufState:imageBufState,clipState:clipState,deformState:deformState,morphState:morphState};
if(flagsState.flags.transparent===true){layer.binSet.transpNodes.push(node);}else{layer.binSet.opaqueNodes.push(node);}};SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_DEACTIVATED,function(){NodeRenderer.init();var layerOrder=SceneJS._layerModule.getLayerOrder();var layer;for(var i=0,len=layerOrder.length;
i<len;i++){layer=layers[layerOrder[i].name];if(layer){renderBinSet(layer.binSet);}}NodeRenderer.cleanup();canvas=null;});function renderBinSet(binSet){var nTransparent=binSet.transpNodes.length;if(nTransparent==0){renderOpaqueNodes(binSet.opaqueNodes);}else{renderOpaqueNodes(binSet.opaqueNodes);renderTransparentNodes(binSet.transpNodes);
}}function renderOpaqueNodes(opaqueNodes){var context=canvas.context;for(var i=0,len=opaqueNodes.length;i<len;i++){NodeRenderer.renderNode(opaqueNodes[i]);}}function renderTransparentNodes(transpNodes){var context=canvas.context;context.enable(context.BLEND);context.blendFunc(context.SRC_ALPHA,context.ONE);
for(var i=0,len=transpNodes.length;i<len;i++){NodeRenderer.renderNode(transpNodes[i]);}context.disable(context.BLEND);}const NodeRenderer=new (function(){this.init=function(){this._program=null;this._lastRendererState=null;this._lastImageBufState=null;};this.renderNode=function(node){var context=canvas.context;
if((!this._program)||(node.program.id!=this._lastProgramId)){if(this._program){this._program.unbind();}this._program=node.program.program;this._program.bind();this._lastFlagsStateId=-1;this._lastGeoStateId=-1;this._lastLightStateId=-1;this._lastClipStateId=-1;this._lastDeformStateId=-1;this._lastMorphStateId=-1;
this._lastTexStateId=-1;this._lastMaterialStateId=-1;this._lastViewXFormStateId=-1;this._lastModelXFormStateId=-1;this._lastProjXFormStateId=-1;this._lastPickStateId=-1;this._lastImageBufStateId=-1;this._lastFogStateId=-1;this._lastProgramId=node.program.id;}if(!node._lastFlagsState||node.flagsState._stateId!=this._lastFlagsState._stateId){this._lastFlagsState=node.flagsState;
}if(!node._lastImageBufState||node.imageBufState._stateId!=this._lastImageBufState._stateId){if(this._lastImageBufState&&this._lastImageBufState.imageBuf){context.flush();this._lastImageBufState.imageBuf.unbind();}if(node.imageBufState.imageBuf){node.imageBufState.imageBuf.bind();}this._lastImageBufState=node.imageBufState;
}if((node.geoState._stateId!=this._lastGeoStateId)||(node.morphState.morph&&node.morphState._stateId!=this._lastMorphStateId)){for(var k=0;k<8;k++){context.disableVertexAttribArray(k);}var vertexBufBound=false;var normalBufBound=false;var uvBufBound=false;var uvBuf2Bound=false;var morph;var target1,target2;
var geo=node.geoState.geo;if(node.morphState.morph&&node.morphState._stateId!=this._lastMorphStateId){morph=node.morphState.morph;target1=morph.target1;target2=morph.target2;if(target1.vertexBuf){this._program.bindFloatArrayBuffer("aVertex",target1.vertexBuf);this._program.bindFloatArrayBuffer("aMorphVertex",target2.vertexBuf);
vertexBufBound=true;}if(target1.normalBuf){this._program.bindFloatArrayBuffer("aNormal",target1.normalBuf);this._program.bindFloatArrayBuffer("aMorphNormal",target2.normalBuf);normalBufBound=true;}if(target1.uvBuf){this._program.bindFloatArrayBuffer("aUVCoord",target1.uvBuf);this._program.bindFloatArrayBuffer("aMorphUVCoord",target2.uvBuf);
uvBufBound=true;}if(target1.uvBuf2){this._program.bindFloatArrayBuffer("aUVCoord2",target1.uvBuf);this._program.bindFloatArrayBuffer("aMorphUVCoord2",target2.uvBuf);uvBuf2Bound=true;}this._program.setUniform("uMorphFactor",morph.factor);this._lastMorphStateId=node.morphState._stateId;}this._lastGeoStateId=node.geoState._stateId;
if(!vertexBufBound&&geo.vertexBuf){this._program.bindFloatArrayBuffer("aVertex",geo.vertexBuf);}if(!normalBufBound&&geo.normalBuf){this._program.bindFloatArrayBuffer("aNormal",geo.normalBuf);}if(node.texState&&node.texState.texture.layers.length>0){if(geo.uvBuf){this._program.bindFloatArrayBuffer("aUVCoord",geo.uvBuf);
}if(geo.uvBuf2){this._program.bindFloatArrayBuffer("aUVCoord2",geo.uvBuf2);}}geo.indexBuf.bind();}if(node.rendererState){if(!this._lastRendererState||node.rendererState._stateId!=this._lastRendererState._stateId){if(this._lastRendererState){this._lastRendererState.props.restoreProps(context);}node.rendererState.props.setProps(context);
this._lastRendererState=node.rendererState;}var clearColor=node.rendererState.props.props.clearColor;clearColor=clearColor?[clearColor.r,clearColor.g,clearColor.b]:[0,0,0];this._program.setUniform("uAmbient",clearColor);}if(node.texState&&node.texState._stateId!=this._lastTexStateId){var layer;for(var j=0;
j<node.texState.texture.layers.length;j++){layer=node.texState.texture.layers[j];this._program.bindTexture("uSampler"+j,layer.texture,j);if(layer.matrixAsArray){this._program.setUniform("uLayer"+j+"Matrix",layer.matrixAsArray);}}this._lastTexStateId=node.texState._stateId;}else{if(!node.texState){this._lastTexStateId=-1;
}}if(node.fogState&&node.fogState.fog&&node.fogState._stateId!=this._lastFogStateId){var fog=node.fogState.fog;if(node.flagsState.flags.fog===false||fog.mode=="disabled"){this._program.setUniform("uFogMode",0);}else{if(fog.mode=="constant"){this._program.setUniform("uFogMode",4);this._program.setUniform("uFogColor",fog.color);
this._program.setUniform("uFogDensity",fog.density);}else{if(fog.mode=="linear"){this._program.setUniform("uFogMode",1);}else{if(fog.mode=="exp"){this._program.setUniform("uFogMode",2);}else{if(fog.mode=="exp2"){this._program.setUniform("uFogMode",3);}}}this._program.setUniform("uFogColor",fog.color);
this._program.setUniform("uFogDensity",fog.density);this._program.setUniform("uFogStart",fog.start);this._program.setUniform("uFogEnd",fog.end);}}this._lastFogStateId=node.fogState._stateId;}if(node.viewXFormState._stateId!=this._lastViewXFormStateId){this._program.setUniform("uVMatrix",node.viewXFormState.mat);
this._program.setUniform("uVNMatrix",node.viewXFormState.normalMat);this._lastViewXFormStateId=node.viewXFormState._stateId;}if(node.modelXFormState._stateId!=this._lastModelXFormStateId){this._program.setUniform("uMMatrix",node.modelXFormState.mat);this._program.setUniform("uMNMatrix",node.modelXFormState.normalMat);
this._lastModelXFormStateId=node.modelXFormState._stateId;}if(node.projXFormState._stateId!=this._lastProjXFormStateId){this._program.setUniform("uPMatrix",node.projXFormState.mat);this._lastProjXFormStateId=node.projXFormState._stateId;}if(node.lightState&&node.lightState._stateId!=this._lastLightStateId){var ambient;
var light;for(var k=0;k<node.lightState.lights.length;k++){light=node.lightState.lights[k];this._program.setUniform("uLightColor"+k,light.color);this._program.setUniform("uLightDiffuse"+k,light.diffuse);if(light.mode=="dir"){this._program.setUniform("uLightDir"+k,light.viewDir);}else{if(light.mode=="ambient"){ambient=ambient?[ambient[0]+light.color[0],ambient[1]+light.color[1],ambient[2]+light.color[2]]:light.color;
}else{if(light.mode=="point"){this._program.setUniform("uLightPos"+k,light.viewPos);}if(light.mode=="spot"){this._program.setUniform("uLightPos"+k,light.viewPos);this._program.setUniform("uLightDir"+k,light.viewDir);this._program.setUniform("uLightSpotCosCutOff"+k,light.spotCosCutOff);this._program.setUniform("uLightSpotExp"+k,light.spotExponent);
}this._program.setUniform("uLightAttenuation"+k,[light.constantAttenuation,light.linearAttenuation,light.quadraticAttenuation]);}}}this._lastLightStateId=node.lightState._stateId;}if(node.clipState&&node.clipState._stateId!=this._lastClipStateId){var clip;for(var k=0;k<node.clipState.clips.length;k++){clip=node.clipState.clips[k];
this._program.setUniform("uClipNormal"+k,clip.normal);this._program.setUniform("uClipDist"+k,clip.dist);if(node.rendererState.props.props.enableClip===false){this._program.setUniform("uClipMode"+k,0);}else{if(clip.mode=="inside"){this._program.setUniform("uClipMode"+k,2);}else{if(clip.mode=="outside"){this._program.setUniform("uClipMode"+k,1);
}else{this._program.setUniform("uClipMode"+k,0);}}}}this._lastClipStateId=node.clipState._stateId;}if(node.deformState&&node.deformState.deform&&node.deformState._stateId!=this._lastDeformStateId){var verts=node.deformState.deform.verts;var vert;for(var k=0,len=verts.length;k<len;k++){vert=verts[k];this._program.setUniform("uDeformVertex"+k,vert.pos);
this._program.setUniform("uDeformWeight"+k,vert.weight);if(vert.mode=="linear"){this._program.setUniform("uDeformMode"+k,0);}else{if(vert.mode=="exp"){this._program.setUniform("uDeformMode"+k,1);}}}this._lastDeformStateId=node.deformState._stateId;}if(node.colortransState&&node.colortransState.trans&&node.colortransState!=this._lastColortransStateId){if(node.flagsState.flags.colortrans===false){this._program.setUniform("uColortransMode",0);
}else{var trans=node.colortransState.trans;var scale=trans.scale;var add=trans.add;this._program.setUniform("uColortransMode",1);this._program.setUniform("uColortransScale",[scale.r,scale.g,scale.b,scale.a]);this._program.setUniform("uColortransAdd",[add.r,add.g,add.b,add.a]);this._program.setUniform("uColortransSaturation",trans.saturation);
this._lastColortransStateId=node.colortransState._stateId;}}if(node.materialState&&node.materialState!=this._lastMaterialStateId){var material=node.materialState.material;this._program.setUniform("uMaterialBaseColor",material.baseColor);this._program.setUniform("uMaterialSpecularColor",material.specularColor);
this._program.setUniform("uMaterialSpecular",material.specular);this._program.setUniform("uMaterialShine",material.shine);this._program.setUniform("uMaterialEmit",material.emit);this._program.setUniform("uMaterialAlpha",material.alpha);this._lastMaterialStateId=node.materialState._stateId;if(node.flagsState&&node.flagsState.flags.highlight){this._program.setUniform("uMaterialBaseColor",material.highlightBaseColor);
this._lastMaterialStateId=null;}}if(node.pickState&&node.pickState._stateId!=this._lastPickStateId){this._program.setUniform("uPickColor",node.pickState.pickColor);}var primitive=node.geoState.geo.primitive;if(node.rendererState&&node.rendererState.props.props.wireframe){if(primitive==context.TRIANGLES||primitive==context.TRIANGLE_STRIP||primitive==context.TRIANGLE_FAN){primitive=context.LINES;
}}context.drawElements(primitive,node.geoState.geo.indexBuf.numItems,context.UNSIGNED_SHORT,0);};this.cleanup=function(){canvas.context.flush();};})();function getSceneHash(){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){return([canvas.canvasId,"picking"]).join(";");}else{return([canvas.canvasId,rendererState.hash,fogState.hash,lightState.hash,texState.hash,clipState.hash,deformState.hash,morphState.hash,geoState.hash]).join(";");
}}function getProgram(stateHash){if(!programs[stateHash]){SceneJS._loggingModule.info("Creating shader: '"+stateHash+"'");var vertexShaderSrc=composeVertexShader();var fragmentShaderSrc=composeFragmentShader();SceneJS._memoryModule.allocate(canvas.context,"shader",function(){try{programs[stateHash]=new SceneJS._webgl_Program(stateHash,time,canvas.context,[vertexShaderSrc],[fragmentShaderSrc],SceneJS._loggingModule);
}catch(e){SceneJS._loggingModule.debug("Vertex shader:");SceneJS._loggingModule.debug(getShaderLoggingSource(vertexShaderSrc.split(";")));SceneJS._loggingModule.debug("Fragment shader:");SceneJS._loggingModule.debug(getShaderLoggingSource(fragmentShaderSrc.split(";")));throw SceneJS._errorModule.fatalError(e);
}});}var program=programs[stateHash];program.lastUsed=time;return program;}function getShaderLoggingSource(src){return src.join("");}function composeVertexShader(){return SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_RENDER?composeRenderingVertexShader():composePickingVertexShader();}function composeFragmentShader(){return SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_RENDER?composeRenderingFragmentShader():composePickingFragmentShader();
}function composePickingVertexShader(){var src=["#ifdef GL_ES"," precision highp float;","#endif","attribute vec3 aVertex;","uniform mat4 uMMatrix;","uniform mat4 uVMatrix;","uniform mat4 uPMatrix;"];src.push("varying vec4 vViewVertex;");src.push("void main(void) {");src.push(" vec4 tmpVertex = uVMatrix * (uMMatrix * vec4(aVertex, 1.0)); ");
src.push(" vViewVertex = tmpVertex;");src.push(" gl_Position = uPMatrix * vViewVertex;");src.push("}");if(debugCfg.logScripts==true){SceneJS._loggingModule.info(src);}return src.join("\n");}function composePickingFragmentShader(){var clipping=clipState&&clipState.clips.length>0;var src=["#ifdef GL_ES"," precision highp float;","#endif"];
src.push("uniform vec3 uPickColor;");if(clipping){src.push("varying vec4 vViewVertex;");for(var i=0;i<clipState.clips.length;i++){src.push("uniform float uClipMode"+i+";");src.push("uniform vec3 uClipNormal"+i+";");src.push("uniform float uClipDist"+i+";");}}src.push("void main(void) {");if(clipping){src.push(" float dist;");
for(var i=0;i<clipState.clips.length;i++){src.push(" if (uClipMode"+i+" != 0.0) {");src.push(" dist = dot(vViewVertex.xyz, uClipNormal"+i+") - uClipDist"+i+";");src.push(" if (uClipMode"+i+" == 1.0) {");src.push(" if (dist < 0.0) { discard; }");src.push(" }");src.push(" if (uClipMode"+i+" == 2.0) {");
src.push(" if (dist > 0.0) { discard; }");src.push(" }");src.push(" }");}}src.push(" gl_FragColor = vec4(uPickColor.rgb, 1.0); ");src.push("}");if(debugCfg.logScripts==true){SceneJS._loggingModule.info(src);}return src.join("\n");}function isTexturing(){if(texState.texture.layers.length>0){if(geoState.geo.uvBuf||geoState.geo.uvBuf2){return true;
}if(morphState.morph&&(morphState.morph.target1.uvBuf||morphState.morph.target1.uvBuf2)){return true;}}return false;}function isLighting(){if(lightState.lights.length>0){if(geoState.geo.normalBuf){return true;}if(morphState.morph&&morphState.morph.target1.normalBuf){return true;}}return false;}function composeRenderingVertexShader(){var texturing=isTexturing();
var lighting=isLighting();var deforming=deformState.deform&&true;var morphing=morphState.morph&&true;var src=["#ifdef GL_ES"," precision highp float;","#endif"];src.push("attribute vec3 aVertex;");if(lighting){src.push("attribute vec3 aNormal;");src.push("uniform mat4 uMNMatrix;");src.push("uniform mat4 uVNMatrix;");
src.push("varying vec3 vNormal;");src.push("varying vec3 vEyeVec;");for(var i=0;i<lightState.lights.length;i++){var light=lightState.lights[i];if(light.mode=="dir"){src.push("uniform vec3 uLightDir"+i+";");}if(light.mode=="point"){src.push("uniform vec4 uLightPos"+i+";");}if(light.mode=="spot"){src.push("uniform vec4 uLightPos"+i+";");
}src.push("varying vec3 vLightVec"+i+";");src.push("varying float vLightDist"+i+";");}}if(texturing){if(geoState.geo.uvBuf){src.push("attribute vec2 aUVCoord;");}if(geoState.geo.uvBuf2){src.push("attribute vec2 aUVCoord2;");}}src.push("uniform mat4 uMMatrix;");src.push("uniform mat4 uVMatrix;");src.push("uniform mat4 uPMatrix;");
src.push("varying vec4 vViewVertex;");if(texturing){if(geoState.geo.uvBuf){src.push("varying vec2 vUVCoord;");}if(geoState.geo.uvBuf2){src.push("varying vec2 vUVCoord2;");}}if(morphing){src.push("uniform float uMorphFactor;");if(morphState.morph.target1.vertexBuf){src.push("attribute vec3 aMorphVertex;");
}if(lighting){if(morphState.morph.target1.normalBuf){src.push("attribute vec3 aMorphNormal;");}}}if(deforming){for(var i=0,len=deformState.deform.verts.length;i<len;i++){src.push("uniform float uDeformMode"+i+";");src.push("uniform vec3 uDeformVertex"+i+";");src.push("uniform float uDeformWeight"+i+";");
}}src.push("void main(void) {");src.push(" vec4 tmpVertex = uVMatrix * (uMMatrix * vec4(aVertex, 1.0)); ");if(lighting){src.push(" vec4 tmpNormal = uVNMatrix * (uMNMatrix * vec4(aNormal, 1.0)); ");}if(morphing){if(morphState.morph.target1.vertexBuf){src.push(" vec4 vMorphVertex = uVMatrix * (uMMatrix * vec4(aMorphVertex, 1.0)); ");
src.push(" tmpVertex = vec4(tmpVertex.xyz + mix(tmpVertex.xyz, vMorphVertex.xyz, uMorphFactor), 1.0); ");}if(lighting){if(morphState.morph.target1.normalBuf){src.push(" vec4 vMorphNormal = uVMatrix * (uMMatrix * vec4(aMorphNormal, 1.0)); ");src.push(" tmpNormal = vec4(tmpNormal.xyz + mix(tmpNormal.xyz, vMorphNormal.xyz, 0.0), 1.0); ");
}}}if(deforming){src.push(" vec3 deformVec;");src.push(" float deformLen;");src.push(" vec3 deformVecSum = vec3(0.0, 0.0, 0.0);");src.push(" float deformScalar;");for(var i=0,len=deformState.deform.verts.length;i<len;i++){src.push("deformVec = uDeformVertex"+i+".xyz - tmpVertex.xyz;");src.push("deformLen = length(deformVec);");
src.push("if (uDeformMode"+i+" == 0.0) {");src.push(" deformScalar = deformLen;");src.push("} else {");src.push(" deformScalar = deformLen * deformLen;");src.push("}");src.push("deformVecSum += deformVec * -uDeformWeight"+i+" * (1.0 / deformScalar);");}src.push("tmpVertex = vec4(deformVecSum.xyz + tmpVertex.xyz, 1.0);");
}if(lighting){src.push(" vNormal = normalize(tmpNormal.xyz);");}src.push(" vViewVertex = tmpVertex;");src.push(" gl_Position = uPMatrix * vViewVertex;");src.push(" vec3 tmpVec;");if(lighting){for(var i=0;i<lightState.lights.length;i++){var light=lightState.lights[i];if(light.mode=="dir"){src.push("tmpVec = -uLightDir"+i+";");
}if(light.mode=="point"){src.push("tmpVec = -(uLightPos"+i+".xyz - tmpVertex.xyz);");src.push("vLightDist"+i+" = length(tmpVec);");}if(light.mode=="spot"){src.push("tmpVec = -(uLightPos"+i+".xyz - tmpVertex.xyz);");src.push("vLightDist"+i+" = length(tmpVec);");}src.push("vLightVec"+i+" = tmpVec;");}src.push("vEyeVec = normalize(-vViewVertex.xyz);");
}if(texturing){if(geoState.geo.uvBuf){src.push("vUVCoord = aUVCoord;");}if(geoState.geo.uvBuf2){src.push("vUVCoord2 = aUVCoord2;");}}src.push("}");if(debugCfg.logScripts===true){SceneJS._loggingModule.info(src);}return src.join("\n");}function composeRenderingFragmentShader(){var texturing=isTexturing();
var lighting=isLighting();var fogging=fogState.fog&&true;var clipping=clipState&&clipState.clips.length>0;var colortrans=colortransState&&colortransState.trans;var src=["\n"];src.push("#ifdef GL_ES");src.push(" precision highp float;");src.push("#endif");src.push("varying vec4 vViewVertex;");if(clipping){for(var i=0;
i<clipState.clips.length;i++){src.push("uniform float uClipMode"+i+";");src.push("uniform vec3 uClipNormal"+i+";");src.push("uniform float uClipDist"+i+";");}}if(texturing){if(geoState.geo.uvBuf){src.push("varying vec2 vUVCoord;");}if(geoState.geo.uvBuf2){src.push("varying vec2 vUVCoord2;");}for(var i=0;
i<texState.texture.layers.length;i++){var layer=texState.texture.layers[i];src.push("uniform sampler2D uSampler"+i+";");if(layer.matrix){src.push("uniform mat4 uLayer"+i+"Matrix;");}}}src.push("uniform vec3 uMaterialBaseColor;");src.push("uniform float uMaterialAlpha;");src.push("uniform vec3 uAmbient;");
src.push("uniform float uMaterialEmit;");src.push(" vec3 ambientValue=uAmbient;");src.push(" float emit = uMaterialEmit;");if(lighting){src.push("varying vec3 n;");src.push("varying vec3 vNormal;");src.push("varying vec3 vEyeVec;");src.push("uniform vec3 uMaterialSpecularColor;");src.push("uniform float uMaterialSpecular;");
src.push("uniform float uMaterialShine;");for(var i=0;i<lightState.lights.length;i++){var light=lightState.lights[i];src.push("uniform vec3 uLightColor"+i+";");if(light.mode=="point"){src.push("uniform vec4 uLightPos"+i+";");}if(light.mode=="dir"){src.push("uniform vec3 uLightDir"+i+";");}if(light.mode=="spot"){src.push("uniform vec4 uLightPos"+i+";");
src.push("uniform vec3 uLightDir"+i+";");src.push("uniform float uLightSpotCosCutOff"+i+";");src.push("uniform float uLightSpotExp"+i+";");}src.push("uniform vec3 uLightAttenuation"+i+";");src.push("varying vec3 vLightVec"+i+";");src.push("varying float vLightDist"+i+";");}}if(fogging){src.push("uniform float uFogMode;");
src.push("uniform vec3 uFogColor;");src.push("uniform float uFogDensity;");src.push("uniform float uFogStart;");src.push("uniform float uFogEnd;");}if(colortrans){src.push("uniform float uColortransMode ;");src.push("uniform vec4 uColortransAdd;");src.push("uniform vec4 uColortransScale;");src.push("uniform float uColortransSaturation;");
}src.push("void main(void) {");src.push(" vec3 color = uMaterialBaseColor;");src.push(" float alpha = uMaterialAlpha;");if(clipping){src.push(" float dist;");for(var i=0;i<clipState.clips.length;i++){src.push(" if (uClipMode"+i+" != 0.0) {");src.push(" dist = dot(vViewVertex.xyz, uClipNormal"+i+") - uClipDist"+i+";");
src.push(" if (uClipMode"+i+" == 1.0) {");src.push(" if (dist < 0.0) { discard; }");src.push(" }");src.push(" if (uClipMode"+i+" == 2.0) {");src.push(" if (dist > 0.0) { discard; }");src.push(" }");src.push(" }");}}if(lighting){src.push(" float specular=uMaterialSpecular;");
src.push(" vec3 specularColor=uMaterialSpecularColor;");src.push(" float shine=uMaterialShine;");src.push(" float attenuation = 1.0;");src.push(" vec3 normalVec=vNormal;");}if(texturing){src.push(" vec4 texturePos;");src.push(" vec2 textureCoord=vec2(0.0,0.0);");for(var i=0;i<texState.texture.layers.length;
i++){var layer=texState.texture.layers[i];if(layer.applyFrom=="normal"&&lighting){if(geoState.geo.normalBuf){src.push("texturePos=vec4(normalVec.xyz, 1.0);");}else{SceneJS._loggingModule.warn("Texture layer applyFrom='normal' but geo has no normal vectors");continue;}}if(layer.applyFrom=="uv"){if(geoState.geo.uvBuf){src.push("texturePos = vec4(vUVCoord.s, vUVCoord.t, 1.0, 1.0);");
}else{SceneJS._loggingModule.warn("Texture layer applyTo='uv' but geometry has no UV coordinates");continue;}}if(layer.applyFrom=="uv2"){if(geoState.geo.uvBuf2){src.push("texturePos = vec4(vUVCoord2.s, vUVCoord2.t, 1.0, 1.0);");}else{SceneJS._loggingModule.warn("Texture layer applyTo='uv2' but geometry has no UV2 coordinates");
continue;}}if(layer.matrixAsArray){src.push("textureCoord=(uLayer"+i+"Matrix * texturePos).xy;");}else{src.push("textureCoord=texturePos.xy;");}if(layer.applyTo=="baseColor"){if(layer.blendMode=="multiply"){src.push("color = color * texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).rgb;");
}else{src.push("color = color + texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).rgb;");}}if(layer.applyTo=="emit"){if(layer.blendMode=="multiply"){src.push("emit = emit * texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).r;");}else{src.push("emit = emit + texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).r;");
}}if(layer.applyTo=="specular"&&lighting){if(layer.blendMode=="multiply"){src.push("specular = specular * (1.0-texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");}else{src.push("specular = specular + (1.0- texture2D(uSampler"+i+", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");
}}if(layer.applyTo=="normals"){src.push("vec3 bump = normalize(texture2D(uSampler"+i+", textureCoord).xyz * 2.0 - 1.0);");src.push("normalVec *= bump;");}}}if(lighting){src.push(" vec3 lightValue = uAmbient;");src.push(" vec3 specularValue = vec3(0.0, 0.0, 0.0);");src.push(" vec3 lightVec;");
src.push(" float dotN;");src.push(" float spotFactor;");src.push(" float pf;");for(var i=0;i<lightState.lights.length;i++){var light=lightState.lights[i];src.push("lightVec = normalize(vLightVec"+i+");");if(light.mode=="point"){src.push("dotN = max(dot(normalVec, lightVec),0.0);");src.push("if (dotN > 0.0) {");
src.push(" attenuation = 1.0 / ("+" uLightAttenuation"+i+"[0] + "+" uLightAttenuation"+i+"[1] * vLightDist"+i+" + "+" uLightAttenuation"+i+"[2] * vLightDist"+i+" * vLightDist"+i+");");if(light.diffuse){src.push(" lightValue += dotN * uLightColor"+i+" * attenuation;");}if(light.specular){src.push("specularValue += attenuation * specularColor * uLightColor"+i+" * specular * pow(max(dot(reflect(lightVec, normalVec), vEyeVec),0.0), shine);");
}src.push("}");}if(light.mode=="dir"){src.push("dotN = max(dot(normalVec,lightVec),0.0);");if(light.diffuse){src.push("lightValue += dotN * uLightColor"+i+";");}if(light.specular){src.push("specularValue += specularColor * uLightColor"+i+" * specular * pow(max(dot(reflect(lightVec, normalVec),normalize(vEyeVec)),0.0), shine);");
}}if(light.mode=="spot"){src.push("spotFactor = max(dot(normalize(uLightDir"+i+"), lightVec));");src.push("if ( spotFactor > 20) {");src.push(" spotFactor = pow(spotFactor, uLightSpotExp"+i+");");src.push(" dotN = max(dot(normalVec,normalize(lightVec)),0.0);");src.push(" if(dotN>0.0){");src.push(" attenuation = 1;");
if(light.diffuse){src.push("lightValue += dotN * uLightColor"+i+" * attenuation;");}if(light.specular){src.push("specularValue += attenuation * specularColor * uLightColor"+i+" * specular * pow(max(dot(reflect(normalize(lightVec), normalVec),normalize(vEyeVec)),0.0), shine);");}src.push(" }");
src.push("}");}}src.push("if (emit>0.0) lightValue = vec3(1.0, 1.0, 1.0);");src.push("vec4 fragColor = vec4(specularValue.rgb + color.rgb * (emit+1.0) * lightValue.rgb, alpha);");}else{src.push("vec4 fragColor = vec4(emit * color.rgb, alpha);");}if(fogging){src.push("if (uFogMode != 0.0) {");src.push(" float fogFact = (1.0 - uFogDensity);");
src.push(" if (uFogMode != 4.0) {");src.push(" if (uFogMode == 1.0) {");src.push(" fogFact *= clamp(pow(max((uFogEnd - length(-vViewVertex.xyz)) / (uFogEnd - uFogStart), 0.0), 2.0), 0.0, 1.0);");src.push(" } else {");src.push(" fogFact *= clamp((uFogEnd - length(-vViewVertex.xyz)) / (uFogEnd - uFogStart), 0.0, 1.0);");
src.push(" }");src.push(" }");src.push(" fragColor = fragColor * (fogFact + vec4(uFogColor, 1)) * (1.0 - fogFact);");src.push("}");}if(colortrans){src.push(" if (uColortransMode != 0.0) {");src.push(" if (uColortransSaturation < 0.0) {");src.push(" float intensity = 0.3 * fragColor.r + 0.59 * fragColor.g + 0.11 * fragColor.b;");
src.push(" fragColor = vec4((intensity * -uColortransSaturation) + fragColor.rgb * (1.0 + uColortransSaturation), 1.0);");src.push(" }");src.push(" fragColor = (fragColor * uColortransScale) + uColortransAdd;");src.push(" }");}if(debugCfg.whitewash==true){src.push(" gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);");
}else{src.push(" gl_FragColor = fragColor;");}src.push("}");if(debugCfg.logScripts==true){SceneJS._loggingModule.info(src);}return src.join("\n");}})();SceneJS._rendererModule=new (function(){var canvas;var propStack;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._eventModule.fireEvent(SceneJS._eventModule.RENDERER_EXPORTED,propStack[propStack.length-1]);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;
});var _this=this;SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(c){canvas=c;propStack=[];var props=_this.createProps({clear:{depth:true,color:true},clearDepth:1,enableDepthTest:true,enableCullFace:false,frontFace:"ccw",cullFace:"back",depthFunc:"less",depthRange:{zNear:0,zFar:1},enableScissorTest:false,viewport:{x:1,y:1,width:c.canvas.width,height:canvas.canvas.height},wireframe:false,highlight:false,enableClip:undefined,enableBlend:false,blendFunc:{sfactor:"srcAlpha",dfactor:"less"}});
setProperties(canvas.context,props);_this.pushProps(props);});this.createProps=function(props){var restore;if(propStack.length>0){restore={};for(var name in props){if(props.hasOwnProperty(name)){if(!(props[name]==undefined)){restore[name]=getSuperProperty(name);}}}}props=processProps(props);return{props:props,setProps:function(context){setProperties(context,props);
},restoreProps:function(context){if(restore){restoreProperties(context,restore);}}};};var getSuperProperty=function(name){var props;var prop;for(var i=propStack.length-1;i>=0;i--){props=propStack[i].props;prop=props[name];if(prop!=undefined&&prop!=null){return props[name];}}return null;};function processProps(props){var prop;
for(var name in props){if(props.hasOwnProperty(name)){prop=props[name];if(prop!=undefined&&prop!=null){if(glModeSetters[name]){props[name]=glModeSetters[name](null,prop);}else{if(glStateSetters[name]){props[name]=glStateSetters[name](null,prop);}}}}}return props;}var setProperties=function(context,props){for(var key in props){if(props.hasOwnProperty(key)){var setter=glModeSetters[key];
if(setter){setter(context,props[key]);}}}if(props.viewport){glStateSetters.viewport(context,props.viewport);}if(props.scissor){glStateSetters.clear(context,props.scissor);}if(props.clear){glStateSetters.clear(context,props.clear);}};var restoreProperties=function(context,props){var value;for(var key in props){if(props.hasOwnProperty(key)){value=props[key];
if(value!=undefined&&value!=null){var setter=glModeSetters[key];if(setter){setter(context,value);}}}}if(props.viewport){glStateSetters.viewport(context,props.viewport);}if(props.scissor){glStateSetters.clear(context,props.scissor);}};this.pushProps=function(props){propStack.push(props);if(props.props.viewport){SceneJS._eventModule.fireEvent(SceneJS._eventModule.VIEWPORT_UPDATED,props.props.viewport);
}dirty=true;};var glEnum=function(context,name){if(!name){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException('Null SceneJS.renderer node config: "'+name+'"'));}var result=SceneJS._webgl_enumMap[name];if(!result){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException('Unrecognised SceneJS.renderer node config value: "'+name+'"'));
}var value=context[result];if(!value){throw SceneJS._errorModule.fatalError(new SceneJS.errors.WebGLUnsupportedNodeConfigException("This browser's WebGL does not support renderer node config value: \""+name+'"'));}return value;};var glModeSetters={enableBlend:function(context,flag){if(!context){if(flag==null||flag==undefined){flag=false;
}return flag;}if(flag){context.enable(context.BLEND);}else{context.disable(context.BLEND);}},blendColor:function(context,color){if(!context){color=color||{};return{r:color.r||0,g:color.g||0,b:color.b||0,a:(color.a==undefined||color.a==null)?1:color.a};}context.blendColor(color.r,color.g,color.b,color.a);
},blendEquation:function(context,eqn){if(!context){return eqn||"funcAdd";}context.blendEquation(context,glEnum(context,eqn));},blendEquationSeparate:function(context,eqn){if(!context){eqn=eqn||{};return{rgb:eqn.rgb||"funcAdd",alpha:eqn.alpha||"funcAdd"};}context.blendEquation(glEnum(context,eqn.rgb),glEnum(context,eqn.alpha));
},blendFunc:function(context,funcs){if(!context){funcs=funcs||{};return{sfactor:funcs.sfactor||"srcAlpha",dfactor:funcs.dfactor||"less"};}context.blendFunc(glEnum(context,funcs.sfactor||"one"),glEnum(context,funcs.dfactor||"zero"));},blendFuncSeparate:function(context,func){if(!context){func=func||{};
return{srcRGB:func.srcRGB||"zero",dstRGB:func.dstRGB||"zero",srcAlpha:func.srcAlpha||"zero",dstAlpha:func.dstAlpha||"zero"};}context.blendFuncSeparate(glEnum(context,func.srcRGB||"zero"),glEnum(context,func.dstRGB||"zero"),glEnum(context,func.srcAlpha||"zero"),glEnum(context,func.dstAlpha||"zero"));},clearColor:function(context,color){if(!context){color=color||{};
return{r:color.r||0,g:color.g||0,b:color.b||0,a:(color.a==undefined||color.a==null)?1:color.a};}context.clearColor(color.r,color.g,color.b,color.a);},clearDepth:function(context,depth){if(!context){return(depth==null||depth==undefined)?1:depth;}context.clearDepth(depth);},clearStencil:function(context,clearValue){if(!context){return clearValue||0;
}context.clearStencil(clearValue);},colorMask:function(context,color){if(!context){color=color||{};return{r:color.r||0,g:color.g||0,b:color.b||0,a:(color.a==undefined||color.a==null)?1:color.a};}context.colorMask(color.r,color.g,color.b,color.a);},enableCullFace:function(context,flag){if(!context){return flag;
}if(flag){context.enable(context.CULL_FACE);}else{flag=false;context.disable(context.CULL_FACE);}},cullFace:function(context,mode){if(!context){return mode||"back";}context.cullFace(glEnum(context,mode));},enableDepthTest:function(context,flag){if(!context){if(flag==null||flag==undefined){flag=true;}return flag;
}if(flag){context.enable(context.DEPTH_TEST);}else{context.disable(context.DEPTH_TEST);}},depthFunc:function(context,func){if(!context){return func||"less";}context.depthFunc(glEnum(context,func));},enableDepthMask:function(context,flag){if(!context){if(flag==null||flag==undefined){flag=true;}return flag;
}context.depthMask(flag);},depthRange:function(context,range){if(!context){range=range||{};return{zNear:(range.zNear==undefined||range.zNear==null)?0:range.zNear,zFar:(range.zFar==undefined||range.zFar==null)?1:range.zFar};}context.depthRange(range.zNear,range.zFar);},frontFace:function(context,mode){if(!context){return mode||"ccw";
}context.frontFace(glEnum(context,mode));},lineWidth:function(context,width){if(!context){return width||1;}context.lineWidth(width);},enableScissorTest:function(context,flag){if(!context){return flag;}if(flag){context.enable(context.SCISSOR_TEST);}else{flag=false;context.disable(context.SCISSOR_TEST);
}}};var glStateSetters={viewport:function(context,v){if(!context){v=v||{};return{x:v.x||1,y:v.y||1,width:v.width||canvas.width,height:v.height||canvas.height};}context.viewport(v.x,v.y,v.width,v.height);SceneJS._eventModule.fireEvent(SceneJS._eventModule.VIEWPORT_UPDATED,v);},scissor:function(context,s){if(!context){s=s||{};
return{x:s.x||0,y:s.y||0,width:s.width||1,height:s.height||1};}context.scissor(s.x,s.y,s.width,s.height);},clear:function(context,mask){if(!context){mask=mask||{};return mask;}var m;if(mask.color){m=context.COLOR_BUFFER_BIT;}if(mask.depth){m=m|context.DEPTH_BUFFER_BIT;}if(mask.stencil){m=m|context.STENCIL_BUFFER_BIT;
}if(m){context.clear(m);}}};this.popProps=function(){var oldProps=propStack[propStack.length-1];propStack.pop();var newProps=propStack[propStack.length-1];if(oldProps.props.viewport){SceneJS._eventModule.fireEvent(SceneJS._eventModule.VIEWPORT_UPDATED,newProps.props.viewport);}dirty=true;};})();SceneJS.Renderer=SceneJS.createNodeType("renderer");
SceneJS.Renderer.prototype._init=function(params){for(var key in params){if(params.hasOwnProperty(key)){this._attr[key]=params[key];}}};SceneJS.Renderer.prototype.setViewport=function(viewport){this._attr.viewport=viewport?{x:viewport.x||1,y:viewport.y||1,width:viewport.width||1000,height:viewport.height||1000}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getViewport=function(){return this._attr.viewport?{x:this._attr.viewport.x,y:this._attr.viewport.y,width:this._attr.viewport.width,height:this._attr.viewport.height}:undefined;};SceneJS.Renderer.prototype.setScissor=function(scissor){this._attr.scissor=scissor?{x:scissor.x||1,y:scissor.y||1,width:scissor.width||1000,height:scissor.height||1000}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getScissor=function(){return this._attr.scissor?{x:this._attr.scissor.x,y:this._attr.scissor.y,width:this._attr.scissor.width,height:this._attr.scissor.height}:undefined;};SceneJS.Renderer.prototype.setClear=function(clear){this._attr.clear=clear?{r:clear.r||0,g:clear.g||0,b:clear.b||0}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getClear=function(){return this._attr.clear?{r:this._attr.clear.r,g:this._attr.clear.g,b:this._attr.clear.b}:null;};SceneJS.Renderer.prototype.setEnableBlend=function(enableBlend){this._attr.enableBlend=enableBlend;this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableBlend=function(){return this._attr.enableBlend;
};SceneJS.Renderer.prototype.setBlendColor=function(color){this._attr.blendColor=color?{r:color.r||0,g:color.g||0,b:color.b||0,a:(color.a==undefined||color.a==null)?1:color.a}:undefined;this._memoLevel=0;};SceneJS.Renderer.prototype.getBlendColor=function(){return this._attr.blendColor?{r:this._attr.blendColor.r,g:this._attr.blendColor.g,b:this._attr.blendColor.b,a:this._attr.blendColor.a}:undefined;
};SceneJS.Renderer.prototype.setBlendEquation=function(eqn){this._attr.blendEquation=eqn;this._memoLevel=0;};SceneJS.Renderer.prototype.getBlendEquation=function(){return this._attr.blendEquation;};SceneJS.Renderer.prototype.setBlendEquationSeparate=function(eqn){this._attr.blendEquationSeparate=eqn?{rgb:eqn.rgb||"funcAdd",alpha:eqn.alpha||"funcAdd"}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getBlendEquationSeparate=function(){return this._attr.blendEquationSeparate?{rgb:this._attr.rgb,alpha:this._attr.alpha}:undefined;};SceneJS.Renderer.prototype.setBlendFunc=function(funcs){this._attr.blendFunc=funcs?{sfactor:funcs.sfactor||"srcAlpha",dfactor:funcs.dfactor||"less"}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getBlendFunc=function(){return this._attr.blendFunc?{sfactor:this._attr.sfactor,dfactor:this._attr.dfactor}:undefined;};SceneJS.Renderer.prototype.setBlendFuncSeparate=function(eqn){this._attr.blendFuncSeparate=eqn?{srcRGB:eqn.srcRGB||"zero",dstRGB:eqn.dstRGB||"zero",srcAlpha:eqn.srcAlpha||"zero",dstAlpha:eqn.dstAlpha||"zero"}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getBlendFuncSeparate=function(){return this._attr.blendFuncSeparate?{srcRGB:this._attr.blendFuncSeparate.srcRGB,dstRGB:this._attr.blendFuncSeparate.dstRGB,srcAlpha:this._attr.blendFuncSeparate.srcAlpha,dstAlpha:this._attr.blendFuncSeparate.dstAlpha}:undefined;
};SceneJS.Renderer.prototype.setEnableCullFace=function(enableCullFace){this._attr.enableCullFace=enableCullFace;this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableCullFace=function(){return this._attr.enableCullFace;};SceneJS.Renderer.prototype.setCullFace=function(cullFace){this._attr.cullFace=cullFace;
this._memoLevel=0;};SceneJS.Renderer.prototype.getCullFace=function(){return this._attr.cullFace;};SceneJS.Renderer.prototype.setEnableDepthTest=function(enableDepthTest){this._attr.enableDepthTest=enableDepthTest;this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableDepthTest=function(){return this._attr.enableDepthTest;
};SceneJS.Renderer.prototype.setDepthFunc=function(depthFunc){this._attr.depthFunc=depthFunc;this._memoLevel=0;};SceneJS.Renderer.prototype.getDepthFunc=function(){return this._attr.depthFunc;};SceneJS.Renderer.prototype.setEnableDepthMask=function(enableDepthMask){this._attr.enableDepthMask=enableDepthMask;
this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableDepthMask=function(){return this._attr.enableDepthMask;};SceneJS.Renderer.prototype.setClearDepth=function(clearDepth){this._attr.clearDepth=clearDepth;this._memoLevel=0;};SceneJS.Renderer.prototype.getClearDepth=function(){return this.attr.clearDepth;
};SceneJS.Renderer.prototype.setDepthRange=function(range){this._attr.depthRange=range?{zNear:(range.zNear==undefined||range.zNear==null)?0:range.zNear,zFar:(range.zFar==undefined||range.zFar==null)?1:range.zFar}:undefined;this._memoLevel=0;};SceneJS.Renderer.prototype.getDepthRange=function(){return this._attr.depthRange?{zNear:this._attr.depthRange.zNear,zFar:this._attr.depthRange.zFar}:undefined;
};SceneJS.Renderer.prototype.setFrontFace=function(frontFace){this._attr.frontFace=frontFace;this._memoLevel=0;};SceneJS.Renderer.prototype.getFrontFace=function(){return this.attr.frontFace;};SceneJS.Renderer.prototype.setLineWidth=function(lineWidth){this._attr.lineWidth=lineWidth;this._memoLevel=0;
};SceneJS.Renderer.prototype.getLineWidth=function(){return this.attr.lineWidth;};SceneJS.Renderer.prototype.setEnableScissorTest=function(enableScissorTest){this._attr.enableScissorTest=enableScissorTest;this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableScissorTest=function(){return this.attr.enableScissorTest;
};SceneJS.Renderer.prototype.setClearStencil=function(clearStencil){this._attr.clearStencil=clearStencil;this._memoLevel=0;};SceneJS.Renderer.prototype.getClearStencil=function(){return this.attr.clearStencil;};SceneJS.Renderer.prototype.setColorMask=function(color){this._attr.colorMask=color?{r:color.r||0,g:color.g||0,b:color.b||0,a:(color.a==undefined||color.a==null)?1:color.a}:undefined;
this._memoLevel=0;};SceneJS.Renderer.prototype.getColorMask=function(){return this._attr.colorMask?{r:this._attr.colorMask.r,g:this._attr.colorMask.g,b:this._attr.colorMask.b,a:this._attr.colorMask.a}:undefined;};SceneJS.Renderer.prototype.setWireframe=function(wireframe){this._attr.wireframe=wireframe;
this._memoLevel=0;};SceneJS.Renderer.prototype.getWireframe=function(){return this.attr.wireframe;};SceneJS.Renderer.prototype.setHighlight=function(highlight){this._attr.highlight=highlight;this._memoLevel=0;};SceneJS.Renderer.prototype.getHighlight=function(){return this._attr.highlight;};SceneJS.Renderer.prototype.setEnableClip=function(enableClip){this._attr.enableClip=enableClip;
this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableClip=function(){return this._attr.enableClip;};SceneJS.Renderer.prototype.setEnableFog=function(enableFog){this._attr.enableFog=enableFog;this._memoLevel=0;};SceneJS.Renderer.prototype.getEnableFog=function(){return this._attr.enableFog;};SceneJS.Renderer.prototype._render=function(traversalContext){if(this._memoLevel==0){this._props=SceneJS._rendererModule.createProps(this._attr);
this._memoLevel=1;}SceneJS._rendererModule.pushProps(this._props);this._renderNodes(traversalContext);SceneJS._rendererModule.popProps(this._props);};SceneJS._flagsModule=new (function(){var flagStack=new Array(255);var stackLen=0;var dirty;this.flags={};function createFlags(flags){if(flagStack.length==0){return flags;
}var topFlags=flagStack[stackLen-1];var flag;for(var name in topFlags){if(topFlags.hasOwnProperty(name)){flag=flags[name];if(flag==null||flag==undefined){flags[name]=topFlags[name];}}}return flags;}var self=this;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){self.flags={fog:true,colortrans:true,picking:true,enabled:true,visible:true};
flagStack[0]=self.flags;stackLen=1;dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.setFlags(self.flags);dirty=false;}});this.pushFlags=function(f){this.flags=createFlags(f);flagStack[stackLen++]=this.flags;dirty=true;};this.popFlags=function(){stackLen--;
this.flags=flagStack[stackLen-1];dirty=true;};})();SceneJS.Flags=SceneJS.createNodeType("flags");SceneJS.Flags.prototype._init=function(params){this.setFlags(params.flags);};SceneJS.Flags.prototype.setFlags=function(flags){this._attr.flags=SceneJS._shallowClone(flags);};SceneJS.Flags.prototype.getFlags=function(){return SceneJS._shallowClone(this._attr.flags);
};SceneJS.Flags.prototype._render=function(traversalContext){SceneJS._flagsModule.pushFlags(this._attr.flags);this._renderNodes(traversalContext);SceneJS._flagsModule.popFlags();};SceneJS._loadStatusModule=new (function(){this.status={numNodesLoading:0,numNodesLoaded:0};var self=this;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){self.status={numNodesLoading:0,numNodesLoaded:0};
});this.getStatusSnapshot=function(){return{numNodesLoading:this.status.numNodesLoading,numNodesLoaded:this.status.numNodesLoaded};};this.diffStatus=function(statusSnapshot){return{numNodesLoading:this.status.numNodesLoading-statusSnapshot.numNodesLoading,numNodesLoaded:this.status.numNodesLoaded-statusSnapshot.numNodesLoaded};
};})();SceneJS._geometryModule=new (function(){var time=(new Date()).getTime();var canvas;var geoMaps={};var currentGeoMap=null;var geoStack=[];SceneJS._eventModule.addListener(SceneJS._eventModule.TIME_UPDATED,function(t){time=t;});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){canvas=null;
currentGeoMap=null;geoStack=[];});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(c){if(!geoMaps[c.canvasId]){geoMaps[c.canvasId]={};}canvas=c;currentGeoMap=geoMaps[c.canvasId];});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_DEACTIVATED,function(){canvas=null;
currentGeoMap=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){for(var canvasId in geoMaps){if(geoMaps.hasOwnProperty(canvasId)){var geoMap=geoMaps[canvasId];
for(var resource in geoMap){if(geoMap.hasOwnProperty(resource)){var geometry=geoMap[resource];destroyGeometry(geometry);}}}}canvas=null;geoMaps={};currentGeoMap=null;});function destroyGeometry(geo){if(document.getElementById(geo.canvas.canvasId)){if(geo.vertexBuf){geo.vertexBuf.destroy();}if(geo.normalBuf){geo.normalBuf.destroy();
}if(geo.indexBuf){geo.indexBuf.destroy();}if(geo.uvBuf){geo.uvBuf.destroy();}if(geo.uvBuf2){geo.uvBuf2.destroy();}}var geoMap=geoMaps[geo.canvas.canvasId];if(geoMap){geoMap[geo.resource]=null;}}SceneJS._memoryModule.registerEvictor(function(){var earliest=time;var evictee;for(var canvasId in geoMaps){if(geoMaps.hasOwnProperty(canvasId)){var geoMap=geoMaps[canvasId];
if(geoMap){for(var resource in geoMap){if(geoMap.hasOwnProperty(resource)){var geometry=geoMap[resource];if(geometry){if(geometry.lastUsed<earliest&&document.getElementById(geometry.canvas.canvasId)){evictee=geometry;earliest=geometry.lastUsed;}}}}}}}if(evictee){SceneJS._loggingModule.warn("Evicting geometry from memory: "+evictee.resource);
destroyGeometry(evictee);return true;}return false;});function createArrayBuffer(description,context,bufType,values,numItems,itemSize,usage){var buf;SceneJS._memoryModule.allocate(context,description,function(){buf=new SceneJS._webgl_ArrayBuffer(context,bufType,values,numItems,itemSize,usage);});return buf;
}function getPrimitiveType(context,primitive){switch(primitive){case"points":return context.POINTS;case"lines":return context.LINES;case"line-loop":return context.LINE_LOOP;case"line-strip":return context.LINE_STRIP;case"triangles":return context.TRIANGLES;case"triangle-strip":return context.TRIANGLE_STRIP;
case"triangle-fan":return context.TRIANGLE_FAN;default:throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.geometry primitive unsupported: '"+primitive+"' - supported types are: 'points', 'lines', 'line-loop', "+"'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'"));
}}this.testGeometryExists=function(resource){return currentGeoMap[resource]?true:false;};this.createGeometry=function(resource,data){if(!resource){resource=SceneJS._createKeyForMap(currentGeoMap,"t");}if(!data.primitive){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NodeConfigExpectedException("SceneJS.geometry node property expected : primitive"));
}var context=canvas.context;var usage=context.STATIC_DRAW;var vertexBuf;var normalBuf;var uvBuf;var uvBuf2;var indexBuf;try{if(data.positions&&data.positions.length>0){vertexBuf=createArrayBuffer("geometry vertex buffer",context,context.ARRAY_BUFFER,new Float32Array(data.positions),data.positions.length,3,usage);
}if(data.normals&&data.normals.length>0){normalBuf=createArrayBuffer("geometry normal buffer",context,context.ARRAY_BUFFER,new Float32Array(data.normals),data.normals.length,3,usage);}if(data.uv&&data.uv.length>0){if(data.uv){uvBuf=createArrayBuffer("geometry UV buffer",context,context.ARRAY_BUFFER,new Float32Array(data.uv),data.uv.length,2,usage);
}}if(data.uv2&&data.uv2.length>0){if(data.uv2){uvBuf2=createArrayBuffer("geometry UV2 buffer",context,context.ARRAY_BUFFER,new Float32Array(data.uv2),data.uv2.length,2,usage);}}var primitive;if(data.indices&&data.indices.length>0){primitive=getPrimitiveType(context,data.primitive);indexBuf=createArrayBuffer("geometry index buffer",context,context.ELEMENT_ARRAY_BUFFER,new Uint16Array(data.indices),data.indices.length,3,usage);
}var geo={fixed:true,primitive:primitive,resource:resource,lastUsed:time,canvas:canvas,context:context,vertexBuf:vertexBuf,normalBuf:normalBuf,indexBuf:indexBuf,uvBuf:uvBuf,uvBuf2:uvBuf2};currentGeoMap[resource]=geo;return resource;}catch(e){if(vertexBuf){vertexBuf.destroy();}if(normalBuf){normalBuf.destroy();
}if(uvBuf){uvBuf.destroy();}if(uvBuf2){uvBuf2.destroy();}if(indexBuf){indexBuf.destroy();}throw e;}};this.pushGeometry=function(resource){var geo=currentGeoMap[resource];geo.lastUsed=time;if(!geo.vertexBuf){geo=inheritVertices(geo);}if(geo.indexBuf){SceneJS._shaderModule.setGeometry(geo);}geoStack.push(geo);
};function inheritVertices(geo){var geo2={primitive:geo.primitive,normalBuf:geo.normalBuf,uvBuf:geo.uvBuf,uvBuf2:geo.uvBuf2,indexBuf:geo.indexBuf};for(var i=geoStack.length-1;i>=0;i--){if(geoStack[i].vertexBuf){geo2.vertexBuf=geoStack[i].vertexBuf;geo2.normalBuf=geoStack[i].normalBuf;geo2.uvBuf=geoStack[i].uvBuf;
geo2.uvBuf2=geoStack[i].uvBuf2;return geo2;}}return geo2;}this.popGeometry=function(){geoStack.pop();};})();SceneJS.Geometry=SceneJS.createNodeType("geometry");SceneJS.Geometry.prototype._init=function(params){this._create=null;this._handle=null;this._resource=params.resource;if(params.create instanceof Function){this._create=params.create;
}else{this._attr.positions=params.positions||[];this._attr.normals=params.normals||[];this._attr.colors=params.colors||[];this._attr.indices=params.indices||[];this._attr.uv=params.uv||[];this._attr.uv2=params.uv2||[];this._attr.primitive=params.primitive||"triangles";}};SceneJS.Geometry.prototype.getPositions=function(){return this._attr.positions;
};SceneJS.Geometry.prototype.getNormals=function(){return this._attr.normals;};SceneJS.Geometry.prototype.getColors=function(){return this._attr.colors;};SceneJS.Geometry.prototype.getIndices=function(){return this._attr.indices;};SceneJS.Geometry.prototype.getUv=function(){return this._attr.uv;};SceneJS.Geometry.prototype.getUv2=function(){return this._attr.uv2;
};SceneJS.Geometry.prototype.getPrimitive=function(){return this._attr.primitive;};SceneJS.Geometry.prototype.getBoundary=function(){var boundary={xmin:Number.MAX_VALUE,ymin:Number.MAX_VALUE,zmin:Number.MAX_VALUE,xmax:Number.MIN_VALUE,ymax:Number.MIN_VALUE,zmax:Number.MIN_VALUE};var x,y,z;for(var i=0,len=this._attr.positions.length-3;
i<len;i+=3){x=this._attr.positions[i];y=this._attr.positions[i+1];z=this._attr.positions[i+2];if(x<boundary.xmin){boundary.xmin=x;}if(y<boundary.ymin){boundary.ymin=y;}if(z<boundary.zmin){boundary.zmin=z;}if(x>boundary.xmax){boundary.xmax=x;}if(y>boundary.ymax){boundary.ymax=y;}if(z>boundary.zmax){boundary.zmax=z;
}}return boundary;};SceneJS.Geometry.prototype._render=function(traversalContext){if(this._handle){if(!SceneJS._geometryModule.testGeometryExists(this._handle)){this._handle=null;}}if(!this._handle){if(this._create){var attr=this._create();this._attr.positions=attr.positions;this._attr.normals=attr.normals;
this._attr.colors=attr.colors;this._attr.indices=attr.indices;this._attr.uv=attr.uv;this._attr.uv2=attr.uv2;this._attr.primitive=attr.primitive;this._handle=SceneJS._geometryModule.createGeometry(this._resource,this._attr);}else{this._handle=SceneJS._geometryModule.createGeometry(this._resource,this._attr);
}}if(!SceneJS._flagsModule.flags.visible){this._renderNodes(traversalContext);}else{SceneJS._geometryModule.pushGeometry(this._handle);this._renderNodes(traversalContext);SceneJS._geometryModule.popGeometry();}};SceneJS.Teapot=function(){SceneJS.Geometry.apply(this,arguments);this._attr.nodeType="teapot";
this._resource="teapot";this._create=function(){var positions=[[-3,1.65,0],[-2.98711,1.65,-0.098438],[-2.98711,1.65,0.098438],[-2.98538,1.56732,-0.049219],[-2.98538,1.56732,0.049219],[-2.9835,1.48308,0],[-2.98189,1.72347,-0.049219],[-2.98189,1.72347,0.049219],[-2.97656,1.79853,0],[-2.9709,1.48621,-0.098438],[-2.9709,1.48621,0.098438],[-2.96388,1.79534,-0.098438],[-2.96388,1.79534,0.098438],[-2.96221,1.57017,-0.133594],[-2.96221,1.57017,0.133594],[-2.95864,1.72057,-0.133594],[-2.95864,1.72057,0.133594],[-2.95313,1.65,-0.16875],[-2.95313,1.65,0.16875],[-2.95247,1.40374,-0.049219],[-2.95247,1.40374,0.049219],[-2.9377,1.49447,-0.16875],[-2.9377,1.49447,0.16875],[-2.93523,1.85215,-0.049219],[-2.93523,1.85215,0.049219],[-2.93359,1.32012,0],[-2.93045,1.78693,-0.16875],[-2.93045,1.78693,0.16875],[-2.93037,1.4115,-0.133594],[-2.93037,1.4115,0.133594],[-2.92188,1.32553,-0.098438],[-2.92188,1.32553,0.098438],[-2.91278,1.84417,-0.133594],[-2.91278,1.84417,0.133594],[-2.90625,1.91016,0],[-2.89423,1.90457,-0.098438],[-2.89423,1.90457,0.098438],[-2.89138,1.5791,-0.196875],[-2.89138,1.5791,0.196875],[-2.89099,1.3398,-0.16875],[-2.89099,1.3398,0.16875],[-2.89065,1.71208,-0.196875],[-2.89065,1.71208,0.196875],[-2.88346,1.24579,-0.048343],[-2.88346,1.24579,0.048343],[-2.86346,1.25713,-0.132718],[-2.86346,1.25713,0.132718],[-2.86266,1.43483,-0.196875],[-2.86266,1.43483,0.196875],[-2.86255,1.88983,-0.16875],[-2.86255,1.88983,0.16875],[-2.85,1.65,-0.225],[-2.85,1.65,0.225],[-2.84971,1.16155,0],[-2.8471,1.82082,-0.196875],[-2.8471,1.82082,0.196875],[-2.84194,1.94692,-0.049219],[-2.84194,1.94692,0.049219],[-2.829,1.7614,-0.225],[-2.829,1.7614,0.225],[-2.82867,1.17598,-0.094933],[-2.82867,1.17598,0.094933],[-2.8247,1.52194,-0.225],[-2.8247,1.52194,0.225],[-2.82115,1.9352,-0.133594],[-2.82115,1.9352,0.133594],[-2.81231,1.18719,-0.16875],[-2.81231,1.18719,0.16875],[-2.80501,1.28997,-0.196875],[-2.80501,1.28997,0.196875],[-2.79727,1.38311,-0.225],[-2.79727,1.38311,0.225],[-2.78906,1.99014,0],[-2.78836,1.69932,-0.196875],[-2.78836,1.69932,0.196875],[-2.77821,1.98283,-0.098438],[-2.77821,1.98283,0.098438],[-2.77442,1.52738,-0.196875],[-2.77442,1.52738,0.196875],[-2.77356,1.0986,-0.084375],[-2.77356,1.0986,0.084375],[-2.76641,1.84512,-0.225],[-2.76641,1.84512,0.225],[-2.76034,1.9009,-0.196875],[-2.76034,1.9009,0.196875],[-2.7496,1.96356,-0.16875],[-2.7496,1.96356,0.16875],[-2.74831,1.7857,-0.196875],[-2.74831,1.7857,0.196875],[-2.74688,1.65,-0.16875],[-2.74688,1.65,0.16875],[-2.73125,1.00781,0],[-2.72756,1.73587,-0.16875],[-2.72756,1.73587,0.16875],[-2.72036,1.69083,-0.133594],[-2.72036,1.69083,0.133594],[-2.71948,1.24977,-0.225],[-2.71948,1.24977,0.225],[-2.71678,1.14468,-0.196875],[-2.71678,1.14468,0.196875],[-2.71289,1.65,-0.098438],[-2.71289,1.65,0.098438],[-2.70899,1.54177,-0.133594],[-2.70899,1.54177,0.133594],[-2.70354,1.42641,-0.16875],[-2.70354,1.42641,0.16875],[-2.70098,1.03784,-0.16875],[-2.70098,1.03784,0.16875],[-2.7,1.65,0],[-2.69965,2.01079,-0.048346],[-2.69965,2.01079,0.048346],[-2.69712,1.68793,-0.049219],[-2.69712,1.68793,0.049219],[-2.69413,1.72746,-0.098438],[-2.69413,1.72746,0.098438],[-2.68662,1.54669,-0.049219],[-2.68662,1.54669,0.049219],[-2.68263,1.76235,-0.133594],[-2.68263,1.76235,0.133594],[-2.68148,1.99646,-0.132721],[-2.68148,1.99646,0.132721],[-2.68144,1.72427,0],[-2.67574,1.27085,-0.196875],[-2.67574,1.27085,0.196875],[-2.67265,1.44068,-0.098438],[-2.67265,1.44068,0.098438],[-2.67026,1.8004,-0.16875],[-2.67026,1.8004,0.16875],[-2.6678,1.84623,-0.196875],[-2.6678,1.84623,0.196875],[-2.66279,1.9051,-0.225],[-2.66279,1.9051,0.225],[-2.66094,1.44609,0],[-2.66018,1.75437,-0.049219],[-2.66018,1.75437,0.049219],[-2.63858,1.78567,-0.098438],[-2.63858,1.78567,0.098438],[-2.63438,1.10391,-0.225],[-2.63438,1.10391,0.225],[-2.63074,1.95674,-0.196875],[-2.63074,1.95674,0.196875],[-2.62656,1.78008,0],[-2.625,2.04375,0],[-2.62464,1.30502,-0.132813],[-2.62464,1.30502,0.132813],[-2.60642,1.31745,-0.048438],[-2.60642,1.31745,0.048438],[-2.60632,2.02644,-0.094945],[-2.60632,2.02644,0.094945],[-2.5918,2.01299,-0.16875],[-2.5918,2.01299,0.16875],[-2.57173,1.83429,-0.16875],[-2.57173,1.83429,0.16875],[-2.56777,1.16997,-0.16875],[-2.56777,1.16997,0.16875],[-2.5546,1.18304,-0.095315],[-2.5546,1.18304,0.095315],[-2.54975,1.89059,-0.196875],[-2.54975,1.89059,0.196875],[-2.54954,0.878984,-0.084375],[-2.54954,0.878984,0.084375],[-2.54643,1.83197,-0.132721],[-2.54643,1.83197,0.132721],[-2.5375,1.2,0],[-2.52721,1.8192,-0.048346],[-2.52721,1.8192,0.048346],[-2.51875,1.94531,-0.225],[-2.51875,1.94531,0.225],[-2.51683,0.932671,-0.196875],[-2.51683,0.932671,0.196875],[-2.47184,1.00649,-0.196875],[-2.47184,1.00649,0.196875],[-2.4457,1.87764,-0.16875],[-2.4457,1.87764,0.16875],[-2.43913,1.06018,-0.084375],[-2.43913,1.06018,0.084375],[-2.43118,1.86418,-0.094945],[-2.43118,1.86418,0.094945],[-2.4125,1.84687,0],[-2.38828,0.716602,0],[-2.38225,0.737663,-0.095854],[-2.38225,0.737663,0.095854],[-2.37884,2.05202,-0.084375],[-2.37884,2.05202,0.084375],[-2.37766,0.75368,-0.16875],[-2.37766,0.75368,0.16875],[-2.36475,0.798761,-0.199836],[-2.36475,0.798761,0.199836],[-2.3543,0.835254,-0.225],[-2.3543,0.835254,0.225],[-2.34384,0.871747,-0.199836],[-2.34384,0.871747,0.199836],[-2.34115,1.99972,-0.196875],[-2.34115,1.99972,0.196875],[-2.33093,0.916827,-0.16875],[-2.33093,0.916827,0.16875],[-2.32031,0.953906,0],[-2.28932,1.92782,-0.196875],[-2.28932,1.92782,0.196875],[-2.25162,1.87552,-0.084375],[-2.25162,1.87552,0.084375],[-2.24741,0.882285,-0.084375],[-2.24741,0.882285,0.084375],[-2.17363,0.844043,0],[-2.16853,0.826951,-0.097184],[-2.16853,0.826951,0.097184],[-2.16477,0.814364,-0.16875],[-2.16477,0.814364,0.16875],[-2.15688,0.786694,-0.187068],[-2.15688,0.786694,0.187068],[-2.15625,2.09297,0],[-2.15412,0.74052,-0.215193],[-2.15412,0.74052,0.215193],[-2.15017,0.694734,-0.215193],[-2.15017,0.694734,0.215193],[-2.14742,0.64856,-0.187068],[-2.14742,0.64856,0.187068],[-2.14496,0.612777,-0.132948],[-2.14496,0.612777,0.132948],[-2.14371,0.591789,-0.048573],[-2.14371,0.591789,0.048573],[-2.14233,2.05836,-0.16875],[-2.14233,2.05836,0.16875],[-2.11172,1.98223,-0.225],[-2.11172,1.98223,0.225],[-2.08447,0.789526,-0.048905],[-2.08447,0.789526,0.048905],[-2.0811,1.90609,-0.16875],[-2.0811,1.90609,0.16875],[-2.07834,0.770387,-0.13328],[-2.07834,0.770387,0.13328],[-2.06719,1.87148,0],[-2,0.75,0],[-1.9957,0.737109,-0.098438],[-1.9957,0.737109,0.098438],[-1.98438,0.703125,-0.16875],[-1.98438,0.703125,0.16875],[-1.97852,0.59165,0],[-1.96937,0.670825,-0.202656],[-1.96937,0.670825,0.202656],[-1.96836,0.655078,-0.210938],[-1.96836,0.655078,0.210938],[-1.96,0.75,-0.4075],[-1.96,0.75,0.4075],[-1.95873,0.925195,-0.201561],[-1.95873,0.925195,0.201561],[-1.95703,1.10039,0],[-1.95,0.6,-0.225],[-1.95,0.6,0.225],[-1.93895,0.59165,-0.403123],[-1.93895,0.59165,0.403123],[-1.93164,0.544922,-0.210938],[-1.93164,0.544922,0.210938],[-1.93069,0.522583,-0.198676],[-1.93069,0.522583,0.198676],[-1.92188,0.453516,0],[-1.91789,1.10039,-0.398745],[-1.91789,1.10039,0.398745],[-1.91562,0.496875,-0.16875],[-1.91562,0.496875,0.16875],[-1.9043,0.462891,-0.098438],[-1.9043,0.462891,0.098438],[-1.9,0.45,0],[-1.89228,0.670825,-0.593047],[-1.89228,0.670825,0.593047],[-1.88344,0.453516,-0.391582],[-1.88344,0.453516,0.391582],[-1.88206,0.925195,-0.589845],[-1.88206,0.925195,0.589845],[-1.88139,1.28613,-0.193602],[-1.88139,1.28613,0.193602],[-1.85512,0.522583,-0.581402],[-1.85512,0.522583,0.581402],[-1.845,0.75,-0.785],[-1.845,0.75,0.785],[-1.84375,1.47187,0],[-1.83317,1.89068,-0.084375],[-1.83317,1.89068,0.084375],[-1.8318,1.94649,-0.196875],[-1.8318,1.94649,0.196875],[-1.82992,2.02323,-0.196875],[-1.82992,2.02323,0.196875],[-1.82855,2.07904,-0.084375],[-1.82855,2.07904,0.084375],[-1.82518,0.59165,-0.776567],[-1.82518,0.59165,0.776567],[-1.81758,0.343945,-0.187036],[-1.81758,0.343945,0.187036],[-1.80775,1.28613,-0.566554],[-1.80775,1.28613,0.566554],[-1.80687,1.47187,-0.375664],[-1.80687,1.47187,0.375664],[-1.80536,1.10039,-0.768135],[-1.80536,1.10039,0.768135],[-1.77293,0.453516,-0.754336],[-1.77293,0.453516,0.754336],[-1.75,0.234375,0],[-1.74644,0.343945,-0.547339],[-1.74644,0.343945,0.547339],[-1.74433,0.670825,-0.949871],[-1.74433,0.670825,0.949871],[-1.73491,0.925195,-0.944741],[-1.73491,0.925195,0.944741],[-1.715,0.234375,-0.356563],[-1.715,0.234375,0.356562],[-1.71008,0.522583,-0.931218],[-1.71008,0.522583,0.931218],[-1.70086,1.47187,-0.723672],[-1.70086,1.47187,0.723672],[-1.6664,1.28613,-0.907437],[-1.6664,1.28613,0.907437],[-1.6625,0.75,-1.125],[-1.6625,0.75,1.125],[-1.65516,1.86094,-0.170322],[-1.65516,1.86094,0.170322],[-1.64742,0.159961,-0.169526],[-1.64742,0.159961,0.169526],[-1.64464,0.59165,-1.11292],[-1.64464,0.59165,1.11292],[-1.62678,1.10039,-1.10083],[-1.62678,1.10039,1.10083],[-1.61437,0.234375,-0.686875],[-1.61437,0.234375,0.686875],[-1.60989,0.343945,-0.87666],[-1.60989,0.343945,0.87666],[-1.6,1.875,0],[-1.59756,0.453516,-1.08106],[-1.59756,0.453516,1.08106],[-1.59037,1.86094,-0.498428],[-1.59037,1.86094,0.498428],[-1.58438,1.91016,-0.16875],[-1.58438,1.91016,0.16875],[-1.58294,0.159961,-0.496099],[-1.58294,0.159961,0.496099],[-1.57813,0.085547,0],[-1.55,1.9875,-0.225],[-1.55,1.9875,0.225],[-1.54656,0.085547,-0.321543],[-1.54656,0.085547,0.321543],[-1.53297,0.670825,-1.26567],[-1.53297,0.670825,1.26567],[-1.53262,1.47187,-1.03711],[-1.53262,1.47187,1.03711],[-1.52469,0.925195,-1.25883],[-1.52469,0.925195,1.25883],[-1.52367,0.042773,-0.156792],[-1.52367,0.042773,0.156792],[-1.51563,2.06484,-0.16875],[-1.51563,2.06484,0.16875],[-1.50287,0.522583,-1.24081],[-1.50287,0.522583,1.24081],[-1.5,0,0],[-1.5,2.1,0],[-1.5,2.25,0],[-1.47,0,-0.305625],[-1.47,0,0.305625],[-1.47,2.25,-0.305625],[-1.47,2.25,0.305625],[-1.46602,1.86094,-0.79832],[-1.46602,1.86094,0.79832],[-1.46449,1.28613,-1.20912],[-1.46449,1.28613,1.20912],[-1.46403,0.042773,-0.458833],[-1.46403,0.042773,0.458833],[-1.45986,2.28691,-0.150226],[-1.45986,2.28691,0.150226],[-1.45917,0.159961,-0.79459],[-1.45917,0.159961,0.79459],[-1.45582,0.085547,-0.619414],[-1.45582,0.085547,0.619414],[-1.45469,0.234375,-0.984375],[-1.45469,0.234375,0.984375],[-1.44922,2.32383,0],[-1.42023,2.32383,-0.295278],[-1.42023,2.32383,0.295278],[-1.42,0.75,-1.42],[-1.42,0.75,1.42],[-1.41482,0.343945,-1.16812],[-1.41482,0.343945,1.16812],[-1.41191,2.33613,-0.145291],[-1.41191,2.33613,0.145291],[-1.40475,0.59165,-1.40475],[-1.40475,0.59165,1.40475],[-1.40313,2.34844,0],[-1.40272,2.28691,-0.439618],[-1.40272,2.28691,0.439618],[-1.4,2.25,0],[-1.38949,1.10039,-1.38949],[-1.38949,1.10039,1.38949],[-1.38375,0,-0.58875],[-1.38375,0,0.58875],[-1.38375,2.25,-0.58875],[-1.38375,2.25,0.58875],[-1.38047,2.32383,0],[-1.37788,2.33613,-0.141789],[-1.37788,2.33613,0.141789],[-1.37633,2.28691,-0.14163],[-1.37633,2.28691,0.14163],[-1.37506,2.34844,-0.285887],[-1.37506,2.34844,0.285887],[-1.372,2.25,-0.28525],[-1.372,2.25,0.28525],[-1.36453,0.453516,-1.36453],[-1.36453,0.453516,1.36453],[-1.35665,2.33613,-0.425177],[-1.35665,2.33613,0.425177],[-1.35286,2.32383,-0.281271],[-1.35286,2.32383,0.281271],[-1.34957,0.042773,-0.734902],[-1.34957,0.042773,0.734902],[-1.3369,2.32383,-0.568818],[-1.3369,2.32383,0.568818],[-1.32395,2.33613,-0.414929],[-1.32395,2.33613,0.414929],[-1.32246,2.28691,-0.414464],[-1.32246,2.28691,0.414464],[-1.31182,0.085547,-0.887695],[-1.31182,0.085547,0.887695],[-1.30906,1.47187,-1.30906],[-1.30906,1.47187,1.30906],[-1.3,2.25,0],[-1.29438,2.34844,-0.550727],[-1.29438,2.34844,0.550727],[-1.29305,2.28691,-0.704126],[-1.29305,2.28691,0.704126],[-1.2915,2.25,-0.5495],[-1.2915,2.25,0.5495],[-1.28839,1.86094,-1.06373],[-1.28839,1.86094,1.06373],[-1.28237,0.159961,-1.05876],[-1.28237,0.159961,1.05876],[-1.274,2.25,-0.264875],[-1.274,2.25,0.264875],[-1.27348,2.32383,-0.541834],[-1.27348,2.32383,0.541834],[-1.26766,2.2749,-0.130448],[-1.26766,2.2749,0.130448],[-1.26567,0.670825,-1.53297],[-1.26567,0.670825,1.53297],[-1.26094,2.2998,0],[-1.25883,0.925195,-1.52469],[-1.25883,0.925195,1.52469],[-1.25057,2.33613,-0.680997],[-1.25057,2.33613,0.680997],[-1.24688,0,-0.84375],[-1.24688,0,0.84375],[-1.24688,2.25,-0.84375],[-1.24688,2.25,0.84375],[-1.2425,0.234375,-1.2425],[-1.2425,0.234375,1.2425],[-1.24081,0.522583,-1.50287],[-1.24081,0.522583,1.50287],[-1.23572,2.2998,-0.256916],[-1.23572,2.2998,0.256916],[-1.22043,2.33613,-0.664583],[-1.22043,2.33613,0.664583],[-1.21906,2.28691,-0.663837],[-1.21906,2.28691,0.663837],[-1.21805,2.2749,-0.38174],[-1.21805,2.2749,0.38174],[-1.20912,1.28613,-1.46449],[-1.20912,1.28613,1.46449],[-1.20466,2.32383,-0.815186],[-1.20466,2.32383,0.815186],[-1.19925,2.25,-0.51025],[-1.19925,2.25,0.51025],[-1.19651,2.31943,-0.123125],[-1.19651,2.31943,0.123125],[-1.18604,0.042773,-0.979229],[-1.18604,0.042773,0.979229],[-1.16812,0.343945,-1.41482],[-1.16812,0.343945,1.41482],[-1.16635,2.34844,-0.789258],[-1.16635,2.34844,0.789258],[-1.16375,2.25,-0.7875],[-1.16375,2.25,0.7875],[-1.16322,2.2998,-0.494918],[-1.16322,2.2998,0.494918],[-1.15625,2.33906,0],[-1.14968,2.31943,-0.360312],[-1.14968,2.31943,0.360312],[-1.14752,2.32383,-0.776514],[-1.14752,2.32383,0.776514],[-1.13637,2.28691,-0.93822],[-1.13637,2.28691,0.93822],[-1.13312,2.33906,-0.235586],[-1.13312,2.33906,0.235586],[-1.125,0.75,-1.6625],[-1.125,0.75,1.6625],[-1.12281,2.2749,-0.611424],[-1.12281,2.2749,0.611424],[-1.12047,0.085547,-1.12047],[-1.12047,0.085547,1.12047],[-1.11292,0.59165,-1.64464],[-1.11292,0.59165,1.64464],[-1.10083,1.10039,-1.62678],[-1.10083,1.10039,1.62678],[-1.09904,2.33613,-0.907402],[-1.09904,2.33613,0.907402],[-1.08106,0.453516,-1.59756],[-1.08106,0.453516,1.59756],[-1.08063,2.25,-0.73125],[-1.08063,2.25,0.73125],[-1.07255,2.33613,-0.885531],[-1.07255,2.33613,0.885531],[-1.07135,2.28691,-0.884537],[-1.07135,2.28691,0.884537],[-1.06664,2.33906,-0.453828],[-1.06664,2.33906,0.453828],[-1.065,0,-1.065],[-1.065,0,1.065],[-1.065,2.25,-1.065],[-1.065,2.25,1.065],[-1.06373,1.86094,-1.28839],[-1.06373,1.86094,1.28839],[-1.05979,2.31943,-0.577104],[-1.05979,2.31943,0.577104],[-1.05876,0.159961,-1.28237],[-1.05876,0.159961,1.28237],[-1.04815,2.2998,-0.709277],[-1.04815,2.2998,0.709277],[-1.03711,1.47187,-1.53262],[-1.03711,1.47187,1.53262],[-1.02894,2.32383,-1.02894],[-1.02894,2.32383,1.02894],[-0.996219,2.34844,-0.996219],[-0.996219,2.34844,0.996219],[-0.994,2.25,-0.994],[-0.994,2.25,0.994],[-0.986761,2.2749,-0.814698],[-0.986761,2.2749,0.814698],[-0.984375,0.234375,-1.45469],[-0.984375,0.234375,1.45469],[-0.980719,2.36953,-0.10092],[-0.980719,2.36953,0.10092],[-0.980133,2.32383,-0.980133],[-0.980133,2.32383,0.980133],[-0.979229,0.042773,-1.18604],[-0.979229,0.042773,1.18604],[-0.961133,2.33906,-0.650391],[-0.961133,2.33906,0.650391],[-0.949871,0.670825,-1.74433],[-0.949871,0.670825,1.74433],[-0.944741,0.925195,-1.73491],[-0.944741,0.925195,1.73491],[-0.942332,2.36953,-0.29533],[-0.942332,2.36953,0.29533],[-0.93822,2.28691,-1.13637],[-0.93822,2.28691,1.13637],[-0.931373,2.31943,-0.768968],[-0.931373,2.31943,0.768968],[-0.931218,0.522583,-1.71008],[-0.931218,0.522583,1.71008],[-0.923,2.25,-0.923],[-0.923,2.25,0.923],[-0.907437,1.28613,-1.6664],[-0.907437,1.28613,1.6664],[-0.907402,2.33613,-1.09904],[-0.907402,2.33613,1.09904],[-0.895266,2.2998,-0.895266],[-0.895266,2.2998,0.895266],[-0.887695,0.085547,-1.31182],[-0.887695,0.085547,1.31182],[-0.885531,2.33613,-1.07255],[-0.885531,2.33613,1.07255],[-0.884537,2.28691,-1.07135],[-0.884537,2.28691,1.07135],[-0.87666,0.343945,-1.60989],[-0.87666,0.343945,1.60989],[-0.868654,2.36953,-0.473023],[-0.868654,2.36953,0.473023],[-0.84375,0,-1.24688],[-0.84375,0,1.24688],[-0.84375,2.25,-1.24688],[-0.84375,2.25,1.24688],[-0.825,2.4,0],[-0.820938,2.33906,-0.820938],[-0.820938,2.33906,0.820938],[-0.815186,2.32383,-1.20466],[-0.815186,2.32383,1.20466],[-0.814698,2.2749,-0.986761],[-0.814698,2.2749,0.986761],[-0.8085,2.4,-0.168094],[-0.8085,2.4,0.168094],[-0.79832,1.86094,-1.46602],[-0.79832,1.86094,1.46602],[-0.79459,0.159961,-1.45917],[-0.79459,0.159961,1.45917],[-0.789258,2.34844,-1.16635],[-0.789258,2.34844,1.16635],[-0.7875,2.25,-1.16375],[-0.7875,2.25,1.16375],[-0.785,0.75,-1.845],[-0.785,0.75,1.845],[-0.776567,0.59165,-1.82518],[-0.776567,0.59165,1.82518],[-0.776514,2.32383,-1.14752],[-0.776514,2.32383,1.14752],[-0.768968,2.31943,-0.931373],[-0.768968,2.31943,0.931373],[-0.768135,1.10039,-1.80536],[-0.768135,1.10039,1.80536],[-0.7634,2.36953,-0.630285],[-0.7634,2.36953,0.630285],[-0.761063,2.4,-0.323813],[-0.761063,2.4,0.323813],[-0.754336,0.453516,-1.77293],[-0.754336,0.453516,1.77293],[-0.734902,0.042773,-1.34957],[-0.734902,0.042773,1.34957],[-0.73125,2.25,-1.08063],[-0.73125,2.25,1.08063],[-0.723672,1.47187,-1.70086],[-0.723672,1.47187,1.70086],[-0.709277,2.2998,-1.04815],[-0.709277,2.2998,1.04815],[-0.704126,2.28691,-1.29305],[-0.704126,2.28691,1.29305],[-0.686875,0.234375,-1.61437],[-0.686875,0.234375,1.61437],[-0.685781,2.4,-0.464063],[-0.685781,2.4,0.464063],[-0.680997,2.33613,-1.25057],[-0.680997,2.33613,1.25057],[-0.664583,2.33613,-1.22043],[-0.664583,2.33613,1.22043],[-0.663837,2.28691,-1.21906],[-0.663837,2.28691,1.21906],[-0.650391,2.33906,-0.961133],[-0.650391,2.33906,0.961133],[-0.631998,2.43047,-0.064825],[-0.631998,2.43047,0.064825],[-0.630285,2.36953,-0.7634],[-0.630285,2.36953,0.7634],[-0.619414,0.085547,-1.45582],[-0.619414,0.085547,1.45582],[-0.611424,2.2749,-1.12281],[-0.611424,2.2749,1.12281],[-0.607174,2.43047,-0.190548],[-0.607174,2.43047,0.190548],[-0.593047,0.670825,-1.89228],[-0.593047,0.670825,1.89228],[-0.589845,0.925195,-1.88206],[-0.589845,0.925195,1.88206],[-0.58875,0,-1.38375],[-0.58875,0,1.38375],[-0.58875,2.25,-1.38375],[-0.58875,2.25,1.38375],[-0.58575,2.4,-0.58575],[-0.58575,2.4,0.58575],[-0.581402,0.522583,-1.85512],[-0.581402,0.522583,1.85512],[-0.577104,2.31943,-1.05979],[-0.577104,2.31943,1.05979],[-0.568818,2.32383,-1.3369],[-0.568818,2.32383,1.3369],[-0.566554,1.28613,-1.80775],[-0.566554,1.28613,1.80775],[-0.559973,2.43047,-0.304711],[-0.559973,2.43047,0.304711],[-0.550727,2.34844,-1.29438],[-0.550727,2.34844,1.29438],[-0.5495,2.25,-1.2915],[-0.5495,2.25,1.2915],[-0.547339,0.343945,-1.74644],[-0.547339,0.343945,1.74644],[-0.541834,2.32383,-1.27348],[-0.541834,2.32383,1.27348],[-0.51025,2.25,-1.19925],[-0.51025,2.25,1.19925],[-0.498428,1.86094,-1.59037],[-0.498428,1.86094,1.59037],[-0.496099,0.159961,-1.58294],[-0.496099,0.159961,1.58294],[-0.494918,2.2998,-1.16322],[-0.494918,2.2998,1.16322],[-0.491907,2.43047,-0.40641],[-0.491907,2.43047,0.40641],[-0.473023,2.36953,-0.868654],[-0.473023,2.36953,0.868654],[-0.464063,2.4,-0.685781],[-0.464063,2.4,0.685781],[-0.458833,0.042773,-1.46403],[-0.458833,0.042773,1.46403],[-0.45625,2.46094,0],[-0.453828,2.33906,-1.06664],[-0.453828,2.33906,1.06664],[-0.439618,2.28691,-1.40272],[-0.439618,2.28691,1.40272],[-0.438241,2.46094,-0.091207],[-0.438241,2.46094,0.091207],[-0.425177,2.33613,-1.35665],[-0.425177,2.33613,1.35665],[-0.420891,2.46094,-0.179078],[-0.420891,2.46094,0.179078],[-0.414929,2.33613,-1.32395],[-0.414929,2.33613,1.32395],[-0.414464,2.28691,-1.32246],[-0.414464,2.28691,1.32246],[-0.4075,0.75,-1.96],[-0.4075,0.75,1.96],[-0.40641,2.43047,-0.491907],[-0.40641,2.43047,0.491907],[-0.403123,0.59165,-1.93895],[-0.403123,0.59165,1.93895],[-0.398745,1.10039,-1.91789],[-0.398745,1.10039,1.91789],[-0.391582,0.453516,-1.88344],[-0.391582,0.453516,1.88344],[-0.38174,2.2749,-1.21805],[-0.38174,2.2749,1.21805],[-0.375664,1.47187,-1.80687],[-0.375664,1.47187,1.80687],[-0.372159,2.46094,-0.251889],[-0.372159,2.46094,0.251889],[-0.362109,2.89717,0],[-0.360312,2.31943,-1.14968],[-0.360312,2.31943,1.14968],[-0.356563,0.234375,1.715],[-0.356562,0.234375,-1.715],[-0.340625,2.95078,0],[-0.337859,2.92397,-0.069278],[-0.337859,2.92397,0.069278],[-0.334238,2.89717,-0.142705],[-0.334238,2.89717,0.142705],[-0.330325,2.86421,-0.067672],[-0.330325,2.86421,0.067672],[-0.325,2.83125,0],[-0.323938,2.46094,-0.323938],[-0.323938,2.46094,0.323938],[-0.323813,2.4,-0.761063],[-0.323813,2.4,0.761063],[-0.321543,0.085547,-1.54656],[-0.321543,0.085547,1.54656],[-0.31541,2.50547,-0.064395],[-0.31541,2.50547,0.064395],[-0.314464,2.95078,-0.134407],[-0.314464,2.95078,0.134407],[-0.305625,0,-1.47],[-0.305625,0,1.47],[-0.305625,2.25,-1.47],[-0.305625,2.25,1.47],[-0.304711,2.43047,-0.559973],[-0.304711,2.43047,0.559973],[-0.299953,2.83125,-0.127984],[-0.299953,2.83125,0.127984],[-0.29533,2.36953,-0.942332],[-0.29533,2.36953,0.942332],[-0.295278,2.32383,-1.42023],[-0.295278,2.32383,1.42023],[-0.287197,2.92397,-0.1943],[-0.287197,2.92397,0.1943],[-0.285887,2.34844,-1.37506],[-0.285887,2.34844,1.37506],[-0.28525,2.25,-1.372],[-0.28525,2.25,1.372],[-0.281271,2.32383,-1.35286],[-0.281271,2.32383,1.35286],[-0.280732,2.86421,-0.189856],[-0.280732,2.86421,0.189856],[-0.274421,2.9688,-0.05638],[-0.274421,2.9688,0.05638],[-0.267832,2.50547,-0.180879],[-0.267832,2.50547,0.180879],[-0.264875,2.25,-1.274],[-0.264875,2.25,1.274],[-0.25761,2.89717,-0.25761],[-0.25761,2.89717,0.25761],[-0.256916,2.2998,-1.23572],[-0.256916,2.2998,1.23572],[-0.251889,2.46094,-0.372159],[-0.251889,2.46094,0.372159],[-0.250872,2.75742,-0.051347],[-0.250872,2.75742,0.051347],[-0.242477,2.95078,-0.242477],[-0.242477,2.95078,0.242477],[-0.235586,2.33906,-1.13312],[-0.235586,2.33906,1.13312],[-0.233382,2.9688,-0.158018],[-0.233382,2.9688,0.158018],[-0.231125,2.83125,-0.231125],[-0.231125,2.83125,0.231125],[-0.230078,2.98682,0],[-0.213159,2.75742,-0.144103],[-0.213159,2.75742,0.144103],[-0.212516,2.98682,-0.091113],[-0.212516,2.98682,0.091113],[-0.202656,0.670825,-1.96937],[-0.202656,0.670825,1.96937],[-0.201561,0.925195,-1.95873],[-0.201561,0.925195,1.95873],[-0.2,2.55,0],[-0.198676,0.522583,-1.93069],[-0.198676,0.522583,1.93069],[-0.196875,2.68359,0],[-0.1943,2.92397,-0.287197],[-0.1943,2.92397,0.287197],[-0.193602,1.28613,-1.88139],[-0.193602,1.28613,1.88139],[-0.190548,2.43047,-0.607174],[-0.190548,2.43047,0.607174],[-0.189856,2.86421,-0.280732],[-0.189856,2.86421,0.280732],[-0.187036,0.343945,-1.81758],[-0.187036,0.343945,1.81758],[-0.1845,2.55,-0.0785],[-0.1845,2.55,0.0785],[-0.181661,2.68359,-0.077405],[-0.181661,2.68359,0.077405],[-0.180879,2.50547,-0.267832],[-0.180879,2.50547,0.267832],[-0.179078,2.46094,-0.420891],[-0.179078,2.46094,0.420891],[-0.176295,2.5812,-0.036001],[-0.176295,2.5812,0.036001],[-0.174804,2.648,-0.035727],[-0.174804,2.648,0.035727],[-0.170322,1.86094,-1.65516],[-0.170322,1.86094,1.65516],[-0.169526,0.159961,-1.64742],[-0.169526,0.159961,1.64742],[-0.168094,2.4,-0.8085],[-0.168094,2.4,0.8085],[-0.166797,2.6124,0],[-0.164073,2.98682,-0.164073],[-0.164073,2.98682,0.164073],[-0.158018,2.9688,-0.233382],[-0.158018,2.9688,0.233382],[-0.156792,0.042773,-1.52367],[-0.156792,0.042773,1.52367],[-0.153882,2.6124,-0.065504],[-0.153882,2.6124,0.065504],[-0.150226,2.28691,-1.45986],[-0.150226,2.28691,1.45986],[-0.14971,2.5812,-0.101116],[-0.14971,2.5812,0.101116],[-0.148475,2.648,-0.100316],[-0.148475,2.648,0.100316],[-0.145291,2.33613,-1.41191],[-0.145291,2.33613,1.41191],[-0.144103,2.75742,-0.213159],[-0.144103,2.75742,0.213159],[-0.142705,2.89717,-0.334238],[-0.142705,2.89717,0.334238],[-0.142,2.55,-0.142],[-0.142,2.55,0.142],[-0.141789,2.33613,-1.37788],[-0.141789,2.33613,1.37788],[-0.14163,2.28691,-1.37633],[-0.14163,2.28691,1.37633],[-0.139898,2.68359,-0.139898],[-0.139898,2.68359,0.139898],[-0.134407,2.95078,-0.314464],[-0.134407,2.95078,0.314464],[-0.130448,2.2749,-1.26766],[-0.130448,2.2749,1.26766],[-0.127984,2.83125,-0.299953],[-0.127984,2.83125,0.299953],[-0.123125,2.31943,-1.19651],[-0.123125,2.31943,1.19651],[-0.118458,2.6124,-0.118458],[-0.118458,2.6124,0.118458],[-0.110649,2.99341,-0.022778],[-0.110649,2.99341,0.022778],[-0.101116,2.5812,-0.14971],[-0.101116,2.5812,0.14971],[-0.10092,2.36953,-0.980719],[-0.10092,2.36953,0.980719],[-0.100316,2.648,-0.148475],[-0.100316,2.648,0.148475],[-0.094147,2.99341,-0.063797],[-0.094147,2.99341,0.063797],[-0.091207,2.46094,-0.438241],[-0.091207,2.46094,0.438241],[-0.091113,2.98682,-0.212516],[-0.091113,2.98682,0.212516],[-0.0785,2.55,-0.1845],[-0.0785,2.55,0.1845],[-0.077405,2.68359,-0.181661],[-0.077405,2.68359,0.181661],[-0.069278,2.92397,-0.337859],[-0.069278,2.92397,0.337859],[-0.067672,2.86421,-0.330325],[-0.067672,2.86421,0.330325],[-0.065504,2.6124,-0.153882],[-0.065504,2.6124,0.153882],[-0.064825,2.43047,-0.631998],[-0.064825,2.43047,0.631998],[-0.064395,2.50547,-0.31541],[-0.064395,2.50547,0.31541],[-0.063797,2.99341,-0.094147],[-0.063797,2.99341,0.094147],[-0.05638,2.9688,-0.274421],[-0.05638,2.9688,0.274421],[-0.051347,2.75742,-0.250872],[-0.051347,2.75742,0.250872],[-0.036001,2.5812,-0.176295],[-0.036001,2.5812,0.176295],[-0.035727,2.648,-0.174804],[-0.035727,2.648,0.174804],[-0.022778,2.99341,-0.110649],[-0.022778,2.99341,0.110649],[0,0,-1.5],[0,0,1.5],[0,0.085547,-1.57813],[0,0.085547,1.57813],[0,0.234375,-1.75],[0,0.234375,1.75],[0,0.453516,-1.92188],[0,0.453516,1.92188],[0,0.59165,-1.97852],[0,0.59165,1.97852],[0,0.75,-2],[0,0.75,2],[0,1.10039,-1.95703],[0,1.10039,1.95703],[0,1.47187,-1.84375],[0,1.47187,1.84375],[0,2.25,-1.5],[0,2.25,-1.4],[0,2.25,-1.3],[0,2.25,1.3],[0,2.25,1.4],[0,2.25,1.5],[0,2.2998,-1.26094],[0,2.2998,1.26094],[0,2.32383,-1.44922],[0,2.32383,-1.38047],[0,2.32383,1.38047],[0,2.32383,1.44922],[0,2.33906,-1.15625],[0,2.33906,1.15625],[0,2.34844,-1.40313],[0,2.34844,1.40313],[0,2.4,-0.825],[0,2.4,0.825],[0,2.46094,-0.45625],[0,2.46094,0.45625],[0,2.55,-0.2],[0,2.55,0.2],[0,2.6124,-0.166797],[0,2.6124,0.166797],[0,2.68359,-0.196875],[0,2.68359,0.196875],[0,2.83125,-0.325],[0,2.83125,0.325],[0,2.89717,-0.362109],[0,2.89717,0.362109],[0,2.95078,-0.340625],[0,2.95078,0.340625],[0,2.98682,-0.230078],[0,2.98682,0.230078],[0,3,0],[0.022778,2.99341,-0.110649],[0.022778,2.99341,0.110649],[0.035727,2.648,-0.174804],[0.035727,2.648,0.174804],[0.036001,2.5812,-0.176295],[0.036001,2.5812,0.176295],[0.051347,2.75742,-0.250872],[0.051347,2.75742,0.250872],[0.05638,2.9688,-0.274421],[0.05638,2.9688,0.274421],[0.063797,2.99341,-0.094147],[0.063797,2.99341,0.094147],[0.064395,2.50547,-0.31541],[0.064395,2.50547,0.31541],[0.064825,2.43047,-0.631998],[0.064825,2.43047,0.631998],[0.065504,2.6124,-0.153882],[0.065504,2.6124,0.153882],[0.067672,2.86421,-0.330325],[0.067672,2.86421,0.330325],[0.069278,2.92397,-0.337859],[0.069278,2.92397,0.337859],[0.077405,2.68359,-0.181661],[0.077405,2.68359,0.181661],[0.0785,2.55,-0.1845],[0.0785,2.55,0.1845],[0.091113,2.98682,-0.212516],[0.091113,2.98682,0.212516],[0.091207,2.46094,-0.438241],[0.091207,2.46094,0.438241],[0.094147,2.99341,-0.063797],[0.094147,2.99341,0.063797],[0.100316,2.648,-0.148475],[0.100316,2.648,0.148475],[0.10092,2.36953,-0.980719],[0.10092,2.36953,0.980719],[0.101116,2.5812,-0.14971],[0.101116,2.5812,0.14971],[0.110649,2.99341,-0.022778],[0.110649,2.99341,0.022778],[0.118458,2.6124,-0.118458],[0.118458,2.6124,0.118458],[0.123125,2.31943,-1.19651],[0.123125,2.31943,1.19651],[0.127984,2.83125,-0.299953],[0.127984,2.83125,0.299953],[0.130448,2.2749,-1.26766],[0.130448,2.2749,1.26766],[0.134407,2.95078,-0.314464],[0.134407,2.95078,0.314464],[0.139898,2.68359,-0.139898],[0.139898,2.68359,0.139898],[0.14163,2.28691,-1.37633],[0.14163,2.28691,1.37633],[0.141789,2.33613,-1.37788],[0.141789,2.33613,1.37788],[0.142,2.55,-0.142],[0.142,2.55,0.142],[0.142705,2.89717,-0.334238],[0.142705,2.89717,0.334238],[0.144103,2.75742,-0.213159],[0.144103,2.75742,0.213159],[0.145291,2.33613,-1.41191],[0.145291,2.33613,1.41191],[0.148475,2.648,-0.100316],[0.148475,2.648,0.100316],[0.14971,2.5812,-0.101116],[0.14971,2.5812,0.101116],[0.150226,2.28691,-1.45986],[0.150226,2.28691,1.45986],[0.153882,2.6124,-0.065504],[0.153882,2.6124,0.065504],[0.156792,0.042773,-1.52367],[0.156792,0.042773,1.52367],[0.158018,2.9688,-0.233382],[0.158018,2.9688,0.233382],[0.164073,2.98682,-0.164073],[0.164073,2.98682,0.164073],[0.166797,2.6124,0],[0.168094,2.4,-0.8085],[0.168094,2.4,0.8085],[0.169526,0.159961,-1.64742],[0.169526,0.159961,1.64742],[0.170322,1.86094,-1.65516],[0.170322,1.86094,1.65516],[0.174804,2.648,-0.035727],[0.174804,2.648,0.035727],[0.176295,2.5812,-0.036001],[0.176295,2.5812,0.036001],[0.179078,2.46094,-0.420891],[0.179078,2.46094,0.420891],[0.180879,2.50547,-0.267832],[0.180879,2.50547,0.267832],[0.181661,2.68359,-0.077405],[0.181661,2.68359,0.077405],[0.1845,2.55,-0.0785],[0.1845,2.55,0.0785],[0.187036,0.343945,-1.81758],[0.187036,0.343945,1.81758],[0.189856,2.86421,-0.280732],[0.189856,2.86421,0.280732],[0.190548,2.43047,-0.607174],[0.190548,2.43047,0.607174],[0.193602,1.28613,-1.88139],[0.193602,1.28613,1.88139],[0.1943,2.92397,-0.287197],[0.1943,2.92397,0.287197],[0.196875,2.68359,0],[0.198676,0.522583,-1.93069],[0.198676,0.522583,1.93069],[0.2,2.55,0],[0.201561,0.925195,-1.95873],[0.201561,0.925195,1.95873],[0.202656,0.670825,-1.96937],[0.202656,0.670825,1.96937],[0.212516,2.98682,-0.091113],[0.212516,2.98682,0.091113],[0.213159,2.75742,-0.144103],[0.213159,2.75742,0.144103],[0.230078,2.98682,0],[0.231125,2.83125,-0.231125],[0.231125,2.83125,0.231125],[0.233382,2.9688,-0.158018],[0.233382,2.9688,0.158018],[0.235586,2.33906,-1.13312],[0.235586,2.33906,1.13312],[0.242477,2.95078,-0.242477],[0.242477,2.95078,0.242477],[0.250872,2.75742,-0.051347],[0.250872,2.75742,0.051347],[0.251889,2.46094,-0.372159],[0.251889,2.46094,0.372159],[0.256916,2.2998,-1.23572],[0.256916,2.2998,1.23572],[0.25761,2.89717,-0.25761],[0.25761,2.89717,0.25761],[0.264875,2.25,-1.274],[0.264875,2.25,1.274],[0.267832,2.50547,-0.180879],[0.267832,2.50547,0.180879],[0.274421,2.9688,-0.05638],[0.274421,2.9688,0.05638],[0.280732,2.86421,-0.189856],[0.280732,2.86421,0.189856],[0.281271,2.32383,-1.35286],[0.281271,2.32383,1.35286],[0.28525,2.25,-1.372],[0.28525,2.25,1.372],[0.285887,2.34844,-1.37506],[0.285887,2.34844,1.37506],[0.287197,2.92397,-0.1943],[0.287197,2.92397,0.1943],[0.295278,2.32383,-1.42023],[0.295278,2.32383,1.42023],[0.29533,2.36953,-0.942332],[0.29533,2.36953,0.942332],[0.299953,2.83125,-0.127984],[0.299953,2.83125,0.127984],[0.304711,2.43047,-0.559973],[0.304711,2.43047,0.559973],[0.305625,0,-1.47],[0.305625,0,1.47],[0.305625,2.25,-1.47],[0.305625,2.25,1.47],[0.314464,2.95078,-0.134407],[0.314464,2.95078,0.134407],[0.31541,2.50547,-0.064395],[0.31541,2.50547,0.064395],[0.321543,0.085547,-1.54656],[0.321543,0.085547,1.54656],[0.323813,2.4,-0.761063],[0.323813,2.4,0.761063],[0.323938,2.46094,-0.323938],[0.323938,2.46094,0.323938],[0.325,2.83125,0],[0.330325,2.86421,-0.067672],[0.330325,2.86421,0.067672],[0.334238,2.89717,-0.142705],[0.334238,2.89717,0.142705],[0.337859,2.92397,-0.069278],[0.337859,2.92397,0.069278],[0.340625,2.95078,0],[0.356562,0.234375,1.715],[0.356563,0.234375,-1.715],[0.360312,2.31943,-1.14968],[0.360312,2.31943,1.14968],[0.362109,2.89717,0],[0.372159,2.46094,-0.251889],[0.372159,2.46094,0.251889],[0.375664,1.47187,-1.80687],[0.375664,1.47187,1.80687],[0.38174,2.2749,-1.21805],[0.38174,2.2749,1.21805],[0.391582,0.453516,-1.88344],[0.391582,0.453516,1.88344],[0.398745,1.10039,-1.91789],[0.398745,1.10039,1.91789],[0.403123,0.59165,-1.93895],[0.403123,0.59165,1.93895],[0.40641,2.43047,-0.491907],[0.40641,2.43047,0.491907],[0.4075,0.75,-1.96],[0.4075,0.75,1.96],[0.414464,2.28691,-1.32246],[0.414464,2.28691,1.32246],[0.414929,2.33613,-1.32395],[0.414929,2.33613,1.32395],[0.420891,2.46094,-0.179078],[0.420891,2.46094,0.179078],[0.425177,2.33613,-1.35665],[0.425177,2.33613,1.35665],[0.438241,2.46094,-0.091207],[0.438241,2.46094,0.091207],[0.439618,2.28691,-1.40272],[0.439618,2.28691,1.40272],[0.453828,2.33906,-1.06664],[0.453828,2.33906,1.06664],[0.45625,2.46094,0],[0.458833,0.042773,-1.46403],[0.458833,0.042773,1.46403],[0.464063,2.4,-0.685781],[0.464063,2.4,0.685781],[0.473023,2.36953,-0.868654],[0.473023,2.36953,0.868654],[0.491907,2.43047,-0.40641],[0.491907,2.43047,0.40641],[0.494918,2.2998,-1.16322],[0.494918,2.2998,1.16322],[0.496099,0.159961,-1.58294],[0.496099,0.159961,1.58294],[0.498428,1.86094,-1.59037],[0.498428,1.86094,1.59037],[0.51025,2.25,-1.19925],[0.51025,2.25,1.19925],[0.541834,2.32383,-1.27348],[0.541834,2.32383,1.27348],[0.547339,0.343945,-1.74644],[0.547339,0.343945,1.74644],[0.5495,2.25,-1.2915],[0.5495,2.25,1.2915],[0.550727,2.34844,-1.29438],[0.550727,2.34844,1.29438],[0.559973,2.43047,-0.304711],[0.559973,2.43047,0.304711],[0.566554,1.28613,-1.80775],[0.566554,1.28613,1.80775],[0.568818,2.32383,-1.3369],[0.568818,2.32383,1.3369],[0.577104,2.31943,-1.05979],[0.577104,2.31943,1.05979],[0.581402,0.522583,-1.85512],[0.581402,0.522583,1.85512],[0.58575,2.4,-0.58575],[0.58575,2.4,0.58575],[0.58875,0,-1.38375],[0.58875,0,1.38375],[0.58875,2.25,-1.38375],[0.58875,2.25,1.38375],[0.589845,0.925195,-1.88206],[0.589845,0.925195,1.88206],[0.593047,0.670825,-1.89228],[0.593047,0.670825,1.89228],[0.607174,2.43047,-0.190548],[0.607174,2.43047,0.190548],[0.611424,2.2749,-1.12281],[0.611424,2.2749,1.12281],[0.619414,0.085547,-1.45582],[0.619414,0.085547,1.45582],[0.630285,2.36953,-0.7634],[0.630285,2.36953,0.7634],[0.631998,2.43047,-0.064825],[0.631998,2.43047,0.064825],[0.650391,2.33906,-0.961133],[0.650391,2.33906,0.961133],[0.663837,2.28691,-1.21906],[0.663837,2.28691,1.21906],[0.664583,2.33613,-1.22043],[0.664583,2.33613,1.22043],[0.680997,2.33613,-1.25057],[0.680997,2.33613,1.25057],[0.685781,2.4,-0.464063],[0.685781,2.4,0.464063],[0.686875,0.234375,-1.61437],[0.686875,0.234375,1.61437],[0.704126,2.28691,-1.29305],[0.704126,2.28691,1.29305],[0.709277,2.2998,-1.04815],[0.709277,2.2998,1.04815],[0.723672,1.47187,-1.70086],[0.723672,1.47187,1.70086],[0.73125,2.25,-1.08063],[0.73125,2.25,1.08063],[0.734902,0.042773,-1.34957],[0.734902,0.042773,1.34957],[0.754336,0.453516,-1.77293],[0.754336,0.453516,1.77293],[0.761063,2.4,-0.323813],[0.761063,2.4,0.323813],[0.7634,2.36953,-0.630285],[0.7634,2.36953,0.630285],[0.768135,1.10039,-1.80536],[0.768135,1.10039,1.80536],[0.768968,2.31943,-0.931373],[0.768968,2.31943,0.931373],[0.776514,2.32383,-1.14752],[0.776514,2.32383,1.14752],[0.776567,0.59165,-1.82518],[0.776567,0.59165,1.82518],[0.785,0.75,-1.845],[0.785,0.75,1.845],[0.7875,2.25,-1.16375],[0.7875,2.25,1.16375],[0.789258,2.34844,-1.16635],[0.789258,2.34844,1.16635],[0.79459,0.159961,-1.45917],[0.79459,0.159961,1.45917],[0.79832,1.86094,-1.46602],[0.79832,1.86094,1.46602],[0.8085,2.4,-0.168094],[0.8085,2.4,0.168094],[0.814698,2.2749,-0.986761],[0.814698,2.2749,0.986761],[0.815186,2.32383,-1.20466],[0.815186,2.32383,1.20466],[0.820938,2.33906,-0.820938],[0.820938,2.33906,0.820938],[0.825,2.4,0],[0.84375,0,-1.24688],[0.84375,0,1.24688],[0.84375,2.25,-1.24688],[0.84375,2.25,1.24688],[0.868654,2.36953,-0.473023],[0.868654,2.36953,0.473023],[0.87666,0.343945,-1.60989],[0.87666,0.343945,1.60989],[0.884537,2.28691,-1.07135],[0.884537,2.28691,1.07135],[0.885531,2.33613,-1.07255],[0.885531,2.33613,1.07255],[0.887695,0.085547,-1.31182],[0.887695,0.085547,1.31182],[0.895266,2.2998,-0.895266],[0.895266,2.2998,0.895266],[0.907402,2.33613,-1.09904],[0.907402,2.33613,1.09904],[0.907437,1.28613,-1.6664],[0.907437,1.28613,1.6664],[0.923,2.25,-0.923],[0.923,2.25,0.923],[0.931218,0.522583,-1.71008],[0.931218,0.522583,1.71008],[0.931373,2.31943,-0.768968],[0.931373,2.31943,0.768968],[0.93822,2.28691,-1.13637],[0.93822,2.28691,1.13637],[0.942332,2.36953,-0.29533],[0.942332,2.36953,0.29533],[0.944741,0.925195,-1.73491],[0.944741,0.925195,1.73491],[0.949871,0.670825,-1.74433],[0.949871,0.670825,1.74433],[0.961133,2.33906,-0.650391],[0.961133,2.33906,0.650391],[0.979229,0.042773,-1.18604],[0.979229,0.042773,1.18604],[0.980133,2.32383,-0.980133],[0.980133,2.32383,0.980133],[0.980719,2.36953,-0.10092],[0.980719,2.36953,0.10092],[0.984375,0.234375,-1.45469],[0.984375,0.234375,1.45469],[0.986761,2.2749,-0.814698],[0.986761,2.2749,0.814698],[0.994,2.25,-0.994],[0.994,2.25,0.994],[0.996219,2.34844,-0.996219],[0.996219,2.34844,0.996219],[1.02894,2.32383,-1.02894],[1.02894,2.32383,1.02894],[1.03711,1.47187,-1.53262],[1.03711,1.47187,1.53262],[1.04815,2.2998,-0.709277],[1.04815,2.2998,0.709277],[1.05876,0.159961,-1.28237],[1.05876,0.159961,1.28237],[1.05979,2.31943,-0.577104],[1.05979,2.31943,0.577104],[1.06373,1.86094,-1.28839],[1.06373,1.86094,1.28839],[1.065,0,-1.065],[1.065,0,1.065],[1.065,2.25,-1.065],[1.065,2.25,1.065],[1.06664,2.33906,-0.453828],[1.06664,2.33906,0.453828],[1.07135,2.28691,-0.884537],[1.07135,2.28691,0.884537],[1.07255,2.33613,-0.885531],[1.07255,2.33613,0.885531],[1.08063,2.25,-0.73125],[1.08063,2.25,0.73125],[1.08106,0.453516,-1.59756],[1.08106,0.453516,1.59756],[1.09904,2.33613,-0.907402],[1.09904,2.33613,0.907402],[1.10083,1.10039,-1.62678],[1.10083,1.10039,1.62678],[1.11292,0.59165,-1.64464],[1.11292,0.59165,1.64464],[1.12047,0.085547,-1.12047],[1.12047,0.085547,1.12047],[1.12281,2.2749,-0.611424],[1.12281,2.2749,0.611424],[1.125,0.75,-1.6625],[1.125,0.75,1.6625],[1.13312,2.33906,-0.235586],[1.13312,2.33906,0.235586],[1.13637,2.28691,-0.93822],[1.13637,2.28691,0.93822],[1.14752,2.32383,-0.776514],[1.14752,2.32383,0.776514],[1.14968,2.31943,-0.360312],[1.14968,2.31943,0.360312],[1.15625,2.33906,0],[1.16322,2.2998,-0.494918],[1.16322,2.2998,0.494918],[1.16375,2.25,-0.7875],[1.16375,2.25,0.7875],[1.16635,2.34844,-0.789258],[1.16635,2.34844,0.789258],[1.16812,0.343945,-1.41482],[1.16812,0.343945,1.41482],[1.18604,0.042773,-0.979229],[1.18604,0.042773,0.979229],[1.19651,2.31943,-0.123125],[1.19651,2.31943,0.123125],[1.19925,2.25,-0.51025],[1.19925,2.25,0.51025],[1.20466,2.32383,-0.815186],[1.20466,2.32383,0.815186],[1.20912,1.28613,-1.46449],[1.20912,1.28613,1.46449],[1.21805,2.2749,-0.38174],[1.21805,2.2749,0.38174],[1.21906,2.28691,-0.663837],[1.21906,2.28691,0.663837],[1.22043,2.33613,-0.664583],[1.22043,2.33613,0.664583],[1.23572,2.2998,-0.256916],[1.23572,2.2998,0.256916],[1.24081,0.522583,-1.50287],[1.24081,0.522583,1.50287],[1.2425,0.234375,-1.2425],[1.2425,0.234375,1.2425],[1.24688,0,-0.84375],[1.24688,0,0.84375],[1.24688,2.25,-0.84375],[1.24688,2.25,0.84375],[1.25057,2.33613,-0.680997],[1.25057,2.33613,0.680997],[1.25883,0.925195,-1.52469],[1.25883,0.925195,1.52469],[1.26094,2.2998,0],[1.26567,0.670825,-1.53297],[1.26567,0.670825,1.53297],[1.26766,2.2749,-0.130448],[1.26766,2.2749,0.130448],[1.27348,2.32383,-0.541834],[1.27348,2.32383,0.541834],[1.274,2.25,-0.264875],[1.274,2.25,0.264875],[1.28237,0.159961,-1.05876],[1.28237,0.159961,1.05876],[1.28839,1.86094,-1.06373],[1.28839,1.86094,1.06373],[1.2915,2.25,-0.5495],[1.2915,2.25,0.5495],[1.29305,2.28691,-0.704126],[1.29305,2.28691,0.704126],[1.29438,2.34844,-0.550727],[1.29438,2.34844,0.550727],[1.3,2.25,0],[1.30906,1.47187,-1.30906],[1.30906,1.47187,1.30906],[1.31182,0.085547,-0.887695],[1.31182,0.085547,0.887695],[1.32246,2.28691,-0.414464],[1.32246,2.28691,0.414464],[1.32395,2.33613,-0.414929],[1.32395,2.33613,0.414929],[1.3369,2.32383,-0.568818],[1.3369,2.32383,0.568818],[1.34957,0.042773,-0.734902],[1.34957,0.042773,0.734902],[1.35286,2.32383,-0.281271],[1.35286,2.32383,0.281271],[1.35665,2.33613,-0.425177],[1.35665,2.33613,0.425177],[1.36453,0.453516,-1.36453],[1.36453,0.453516,1.36453],[1.372,2.25,-0.28525],[1.372,2.25,0.28525],[1.37506,2.34844,-0.285887],[1.37506,2.34844,0.285887],[1.37633,2.28691,-0.14163],[1.37633,2.28691,0.14163],[1.37788,2.33613,-0.141789],[1.37788,2.33613,0.141789],[1.38047,2.32383,0],[1.38375,0,-0.58875],[1.38375,0,0.58875],[1.38375,2.25,-0.58875],[1.38375,2.25,0.58875],[1.38949,1.10039,-1.38949],[1.38949,1.10039,1.38949],[1.4,2.25,0],[1.40272,2.28691,-0.439618],[1.40272,2.28691,0.439618],[1.40313,2.34844,0],[1.40475,0.59165,-1.40475],[1.40475,0.59165,1.40475],[1.41191,2.33613,-0.145291],[1.41191,2.33613,0.145291],[1.41482,0.343945,-1.16812],[1.41482,0.343945,1.16812],[1.42,0.75,-1.42],[1.42,0.75,1.42],[1.42023,2.32383,-0.295278],[1.42023,2.32383,0.295278],[1.44922,2.32383,0],[1.45469,0.234375,-0.984375],[1.45469,0.234375,0.984375],[1.45582,0.085547,-0.619414],[1.45582,0.085547,0.619414],[1.45917,0.159961,-0.79459],[1.45917,0.159961,0.79459],[1.45986,2.28691,-0.150226],[1.45986,2.28691,0.150226],[1.46403,0.042773,-0.458833],[1.46403,0.042773,0.458833],[1.46449,1.28613,-1.20912],[1.46449,1.28613,1.20912],[1.46602,1.86094,-0.79832],[1.46602,1.86094,0.79832],[1.47,0,-0.305625],[1.47,0,0.305625],[1.47,2.25,-0.305625],[1.47,2.25,0.305625],[1.5,0,0],[1.5,2.25,0],[1.50287,0.522583,-1.24081],[1.50287,0.522583,1.24081],[1.52367,0.042773,-0.156792],[1.52367,0.042773,0.156792],[1.52469,0.925195,-1.25883],[1.52469,0.925195,1.25883],[1.53262,1.47187,-1.03711],[1.53262,1.47187,1.03711],[1.53297,0.670825,-1.26567],[1.53297,0.670825,1.26567],[1.54656,0.085547,-0.321543],[1.54656,0.085547,0.321543],[1.57813,0.085547,0],[1.58294,0.159961,-0.496099],[1.58294,0.159961,0.496099],[1.59037,1.86094,-0.498428],[1.59037,1.86094,0.498428],[1.59756,0.453516,-1.08106],[1.59756,0.453516,1.08106],[1.60989,0.343945,-0.87666],[1.60989,0.343945,0.87666],[1.61437,0.234375,-0.686875],[1.61437,0.234375,0.686875],[1.62678,1.10039,-1.10083],[1.62678,1.10039,1.10083],[1.64464,0.59165,-1.11292],[1.64464,0.59165,1.11292],[1.64742,0.159961,-0.169526],[1.64742,0.159961,0.169526],[1.65516,1.86094,-0.170322],[1.65516,1.86094,0.170322],[1.6625,0.75,-1.125],[1.6625,0.75,1.125],[1.6664,1.28613,-0.907437],[1.6664,1.28613,0.907437],[1.7,0.45,0],[1.7,0.485449,-0.216563],[1.7,0.485449,0.216563],[1.7,0.578906,-0.37125],[1.7,0.578906,0.37125],[1.7,0.711035,-0.464063],[1.7,0.711035,0.464063],[1.7,0.8625,-0.495],[1.7,0.8625,0.495],[1.7,1.01397,-0.464063],[1.7,1.01397,0.464063],[1.7,1.14609,-0.37125],[1.7,1.14609,0.37125],[1.7,1.23955,-0.216563],[1.7,1.23955,0.216563],[1.7,1.275,0],[1.70086,1.47187,-0.723672],[1.70086,1.47187,0.723672],[1.71008,0.522583,-0.931218],[1.71008,0.522583,0.931218],[1.715,0.234375,-0.356562],[1.715,0.234375,0.356563],[1.73491,0.925195,-0.944741],[1.73491,0.925195,0.944741],[1.74433,0.670825,-0.949871],[1.74433,0.670825,0.949871],[1.74644,0.343945,-0.547339],[1.74644,0.343945,0.547339],[1.75,0.234375,0],[1.77293,0.453516,-0.754336],[1.77293,0.453516,0.754336],[1.80536,1.10039,-0.768135],[1.80536,1.10039,0.768135],[1.80687,1.47187,-0.375664],[1.80687,1.47187,0.375664],[1.80775,1.28613,-0.566554],[1.80775,1.28613,0.566554],[1.80868,0.66944,-0.415335],[1.80868,0.66944,0.415335],[1.81523,0.556498,-0.292881],[1.81523,0.556498,0.292881],[1.81758,0.343945,-0.187036],[1.81758,0.343945,0.187036],[1.8185,0.493823,-0.107904],[1.8185,0.493823,0.107904],[1.82518,0.59165,-0.776567],[1.82518,0.59165,0.776567],[1.84375,1.47187,0],[1.84408,1.27311,-0.106836],[1.84408,1.27311,0.106836],[1.845,0.75,-0.785],[1.845,0.75,0.785],[1.84989,1.21245,-0.289984],[1.84989,1.21245,0.289984],[1.85512,0.522583,-0.581402],[1.85512,0.522583,0.581402],[1.86007,1.10628,-0.412082],[1.86007,1.10628,0.412082],[1.87286,0.97282,-0.473131],[1.87286,0.97282,0.473131],[1.88139,1.28613,-0.193602],[1.88139,1.28613,0.193602],[1.88206,0.925195,-0.589845],[1.88206,0.925195,0.589845],[1.88344,0.453516,-0.391582],[1.88344,0.453516,0.391582],[1.88652,0.830257,-0.473131],[1.88652,0.830257,0.473131],[1.89228,0.670825,-0.593047],[1.89228,0.670825,0.593047],[1.90898,0.762851,-0.457368],[1.90898,0.762851,0.457368],[1.91789,1.10039,-0.398745],[1.91789,1.10039,0.398745],[1.92188,0.453516,0],[1.92572,0.624968,-0.36866],[1.92572,0.624968,0.36866],[1.93069,0.522583,-0.198676],[1.93069,0.522583,0.198676],[1.9352,0.536667,-0.215052],[1.9352,0.536667,0.215052],[1.93879,0.503174,0],[1.93895,0.59165,-0.403123],[1.93895,0.59165,0.403123],[1.95703,1.10039,0],[1.95873,0.925195,-0.201561],[1.95873,0.925195,0.201561],[1.96,0.75,-0.4075],[1.96,0.75,0.4075],[1.96937,0.670825,-0.202656],[1.96937,0.670825,0.202656],[1.97852,0.59165,0],[1.98496,1.30459,0],[1.99136,1.27331,-0.210782],[1.99136,1.27331,0.210782],[2,0.75,0],[2.00799,0.721263,-0.409761],[2.00799,0.721263,0.409761],[2.00821,1.19084,-0.36134],[2.00821,1.19084,0.36134],[2.02471,0.614949,-0.288958],[2.02471,0.614949,0.288958],[2.03205,1.07424,-0.451675],[2.03205,1.07424,0.451675],[2.03379,0.556062,-0.106458],[2.03379,0.556062,0.106458],[2.05938,0.940576,-0.481787],[2.05938,0.940576,0.481787],[2.08644,1.33048,-0.101581],[2.08644,1.33048,0.101581],[2.0867,0.806915,-0.451675],[2.0867,0.806915,0.451675],[2.10141,1.27815,-0.27572],[2.10141,1.27815,0.27572],[2.11053,0.690317,-0.36134],[2.11053,0.690317,0.36134],[2.12739,0.607845,-0.210782],[2.12739,0.607845,0.210782],[2.1276,1.18656,-0.391812],[2.1276,1.18656,0.391812],[2.13379,0.576563,0],[2.16054,1.07143,-0.449859],[2.16054,1.07143,0.449859],[2.16922,0.790259,-0.39936],[2.16922,0.790259,0.39936],[2.17969,1.38516,0],[2.18976,1.35887,-0.195542],[2.18976,1.35887,0.195542],[2.19481,0.691761,-0.281559],[2.19481,0.691761,0.281559],[2.19571,0.948444,-0.449859],[2.19571,0.948444,0.449859],[2.20837,0.637082,-0.103732],[2.20837,0.637082,0.103732],[2.21631,1.28957,-0.335215],[2.21631,1.28957,0.335215],[2.2202,0.891314,-0.434457],[2.2202,0.891314,0.434457],[2.24857,1.433,-0.092384],[2.24857,1.433,0.092384],[2.25384,1.1916,-0.419019],[2.25384,1.1916,0.419019],[2.25944,0.772489,-0.349967],[2.25944,0.772489,0.349967],[2.26857,1.39016,-0.250758],[2.26857,1.39016,0.250758],[2.28189,0.696393,-0.204147],[2.28189,0.696393,0.204147],[2.29041,0.667529,0],[2.29688,1.0793,-0.446953],[2.29688,1.0793,0.446953],[2.29925,0.874953,-0.384664],[2.29925,0.874953,0.384664],[2.30358,1.3152,-0.35634],[2.30358,1.3152,0.35634],[2.30644,1.5044,0],[2.31838,1.48356,-0.173996],[2.31838,1.48356,0.173996],[2.33069,0.784406,-0.271218],[2.33069,0.784406,0.271218],[2.33991,0.966989,-0.419019],[2.33991,0.966989,0.419019],[2.34759,0.734271,-0.099922],[2.34759,0.734271,0.099922],[2.34759,1.22096,-0.409131],[2.34759,1.22096,0.409131],[2.34984,1.42864,-0.298279],[2.34984,1.42864,0.298279],[2.35318,1.56816,-0.080823],[2.35318,1.56816,0.080823],[2.37575,1.53531,-0.219377],[2.37575,1.53531,0.219377],[2.37744,0.869019,-0.335215],[2.37744,0.869019,0.335215],[2.3875,1.65,0],[2.39432,1.35098,-0.372849],[2.39432,1.35098,0.372849],[2.3946,1.1203,-0.409131],[2.3946,1.1203,0.409131],[2.40039,1.63469,-0.149297],[2.40039,1.63469,0.149297],[2.40399,0.799722,-0.195542],[2.40399,0.799722,0.195542],[2.41406,0.773438,0],[2.41524,1.47781,-0.311747],[2.41524,1.47781,0.311747],[2.43438,1.59434,-0.255938],[2.43438,1.59434,0.255938],[2.43861,1.02606,-0.35634],[2.43861,1.02606,0.35634],[2.44531,1.26196,-0.397705],[2.44531,1.26196,0.397705],[2.45168,1.80534,-0.063087],[2.45168,1.80534,0.063087],[2.46489,1.40552,-0.357931],[2.46489,1.40552,0.357931],[2.47362,0.951099,-0.250758],[2.47362,0.951099,0.250758],[2.47768,1.78638,-0.171237],[2.47768,1.78638,0.171237],[2.48242,1.53728,-0.319922],[2.48242,1.53728,0.319922],[2.49362,0.908264,-0.092384],[2.49362,0.908264,0.092384],[2.4963,1.17295,-0.372849],[2.4963,1.17295,0.372849],[2.50156,1.97109,0],[2.51727,1.96555,-0.103052],[2.51727,1.96555,0.103052],[2.51792,1.32831,-0.357931],[2.51792,1.32831,0.357931],[2.52318,1.75322,-0.243336],[2.52318,1.75322,0.243336],[2.5375,1.47187,-0.34125],[2.5375,1.47187,0.34125],[2.54078,1.09529,-0.298279],[2.54078,1.09529,0.298279],[2.54911,2.04464,-0.047716],[2.54911,2.04464,0.047716],[2.55869,1.95095,-0.17666],[2.55869,1.95095,0.17666],[2.56757,1.25603,-0.311747],[2.56757,1.25603,0.311747],[2.57225,1.04036,-0.173996],[2.57225,1.04036,0.173996],[2.5791,2.12197,0],[2.58039,1.71153,-0.279386],[2.58039,1.71153,0.279386],[2.58101,2.03773,-0.129515],[2.58101,2.03773,0.129515],[2.58418,1.01953,0],[2.59258,1.40647,-0.319922],[2.59258,1.40647,0.319922],[2.59849,2.11992,-0.087812],[2.59849,2.11992,0.087812],[2.60178,1.55472,-0.304019],[2.60178,1.55472,0.304019],[2.60707,1.19853,-0.219377],[2.60707,1.19853,0.219377],[2.61162,1.69128,-0.287908],[2.61162,1.69128,0.287908],[2.61725,1.93031,-0.220825],[2.61725,1.93031,0.220825],[2.62963,1.16568,-0.080823],[2.62963,1.16568,0.080823],[2.63788,2.02555,-0.180818],[2.63788,2.02555,0.180818],[2.64063,1.34941,-0.255938],[2.64063,1.34941,0.255938],[2.6496,2.11451,-0.150535],[2.6496,2.11451,0.150535],[2.65084,2.18547,-0.042461],[2.65084,2.18547,0.042461],[2.65391,1.5042,-0.264113],[2.65391,1.5042,0.264113],[2.66542,1.64925,-0.266995],[2.66542,1.64925,0.266995],[2.67461,1.30906,-0.149297],[2.67461,1.30906,0.149297],[2.67823,1.78254,-0.252819],[2.67823,1.78254,0.252819],[2.68438,1.90664,-0.235547],[2.68438,1.90664,0.235547],[2.6875,1.29375,0],[2.6919,2.18361,-0.115251],[2.6919,2.18361,0.115251],[2.69645,1.4638,-0.185857],[2.69645,1.4638,0.185857],[2.7,2.25,0],[2.70808,2.01037,-0.208084],[2.70808,2.01037,0.208084],[2.71703,1.61167,-0.213596],[2.71703,1.61167,0.213596],[2.72076,1.44072,-0.068474],[2.72076,1.44072,0.068474],[2.72578,2.25,-0.082031],[2.72578,2.25,0.082031],[2.72599,2.10643,-0.17525],[2.72599,2.10643,0.17525],[2.736,1.75155,-0.219519],[2.736,1.75155,0.219519],[2.75021,2.26919,-0.039734],[2.75021,2.26919,0.039734],[2.7515,1.88297,-0.220825],[2.7515,1.88297,0.220825],[2.75354,1.58508,-0.124598],[2.75354,1.58508,0.124598],[2.76738,1.575,0],[2.77556,2.284,0],[2.78099,1.99437,-0.208084],[2.78099,1.99437,0.208084],[2.78303,1.7267,-0.154476],[2.78303,1.7267,0.154476],[2.79375,2.25,-0.140625],[2.79375,2.25,0.140625],[2.79782,2.27175,-0.107849],[2.79782,2.27175,0.107849],[2.79949,2.29275,-0.076904],[2.79949,2.29275,0.076904],[2.8,2.25,0],[2.80469,2.0981,-0.200713],[2.80469,2.0981,0.200713],[2.8099,1.7125,-0.056912],[2.8099,1.7125,0.056912],[2.81006,1.86233,-0.17666],[2.81006,1.86233,0.17666],[2.81201,2.17815,-0.169843],[2.81201,2.17815,0.169843],[2.81274,2.29754,-0.035632],[2.81274,2.29754,0.035632],[2.81719,2.25,-0.049219],[2.81719,2.25,0.049219],[2.825,2.30625,0],[2.83011,2.27129,-0.025891],[2.83011,2.27129,0.025891],[2.84063,2.29219,0],[2.84479,2.29964,-0.029993],[2.84479,2.29964,0.029993],[2.85092,2.30716,-0.065625],[2.85092,2.30716,0.065625],[2.85118,1.97919,-0.180818],[2.85118,1.97919,0.180818],[2.85148,1.84773,-0.103052],[2.85148,1.84773,0.103052],[2.86048,2.30093,-0.096716],[2.86048,2.30093,0.096716],[2.8625,2.25,-0.084375],[2.8625,2.25,0.084375],[2.86263,2.29298,-0.054346],[2.86263,2.29298,0.054346],[2.86574,2.27201,-0.070276],[2.86574,2.27201,0.070276],[2.86719,1.84219,0],[2.87228,2.29425,-0.131836],[2.87228,2.29425,0.131836],[2.88339,2.08977,-0.17525],[2.88339,2.08977,0.17525],[2.88836,2.30119,-0.081409],[2.88836,2.30119,0.081409],[2.89827,2.17088,-0.194382],[2.89827,2.17088,0.194382],[2.90805,1.967,-0.129515],[2.90805,1.967,0.129515],[2.91924,2.30955,-0.1125],[2.91924,2.30955,0.1125],[2.92064,2.29507,-0.093164],[2.92064,2.29507,0.093164],[2.93279,2.13103,-0.172211],[2.93279,2.13103,0.172211],[2.9398,2.27326,-0.158936],[2.9398,2.27326,0.158936],[2.93996,1.9601,-0.047716],[2.93996,1.9601,0.047716],[2.95978,2.08168,-0.150535],[2.95978,2.08168,0.150535],[2.96995,2.27412,-0.103564],[2.96995,2.27412,0.103564],[3,2.25,-0.1875],[3,2.25,-0.1125],[3,2.25,0.1125],[3,2.25,0.1875],[3.00281,2.30484,-0.142529],[3.00281,2.30484,0.142529],[3.01089,2.07627,-0.087812],[3.01089,2.07627,0.087812],[3.01578,2.30571,-0.119971],[3.01578,2.30571,0.119971],[3.03027,2.07422,0],[3.0415,2.12567,-0.116276],[3.0415,2.12567,0.116276],[3.04323,2.21108,-0.166431],[3.04323,2.21108,0.166431],[3.06842,2.17345,-0.143215],[3.06842,2.17345,0.143215],[3.07929,2.12306,-0.042838],[3.07929,2.12306,0.042838],[3.09316,2.29878,-0.175781],[3.09316,2.29878,0.175781],[3.09668,2.30142,-0.124219],[3.09668,2.30142,0.124219],[3.12656,2.3168,-0.15],[3.12656,2.3168,0.15],[3.12672,2.27729,-0.103564],[3.12672,2.27729,0.103564],[3.12691,2.17128,-0.083542],[3.12691,2.17128,0.083542],[3.1375,2.25,-0.084375],[3.1375,2.25,0.084375],[3.1491,2.17046,0],[3.15337,2.27552,-0.158936],[3.15337,2.27552,0.158936],[3.16895,2.21118,-0.112353],[3.16895,2.21118,0.112353],[3.18281,2.25,-0.049219],[3.18281,2.25,0.049219],[3.2,2.25,0],[3.20625,2.25,-0.140625],[3.20625,2.25,0.140625],[3.20746,2.31251,-0.119971],[3.20746,2.31251,0.119971],[3.21256,2.21043,-0.041393],[3.21256,2.21043,0.041393],[3.21692,2.31073,-0.142529],[3.21692,2.31073,0.142529],[3.23094,2.2794,-0.070276],[3.23094,2.2794,0.070276],[3.26724,2.27814,-0.025891],[3.26724,2.27814,0.025891],[3.27272,2.30776,-0.093164],[3.27272,2.30776,0.093164],[3.27422,2.25,-0.082031],[3.27422,2.25,0.082031],[3.29534,2.27703,-0.107849],[3.29534,2.27703,0.107849],[3.3,2.25,0],[3.31405,2.30331,-0.131836],[3.31405,2.30331,0.131836],[3.33073,2.30985,-0.054346],[3.33073,2.30985,0.054346],[3.33389,2.32405,-0.1125],[3.33389,2.32405,0.1125],[3.33489,2.31702,-0.081409],[3.33489,2.31702,0.081409],[3.34236,2.28006,-0.039734],[3.34236,2.28006,0.039734],[3.35543,2.3027,0],[3.35925,2.31465,-0.096716],[3.35925,2.31465,0.096716],[3.37912,2.31658,-0.029993],[3.37912,2.31658,0.029993],[3.38684,2.30481,-0.076904],[3.38684,2.30481,0.076904],[3.40221,2.32644,-0.065625],[3.40221,2.32644,0.065625],[3.40639,2.3185,-0.035632],[3.40639,2.3185,0.035632],[3.40838,2.31543,0],[3.42812,2.32734,0]];
var indices=[[1454,1468,1458],[1448,1454,1458],[1461,1448,1458],[1468,1461,1458],[1429,1454,1440],[1421,1429,1440],[1448,1421,1440],[1454,1448,1440],[1380,1429,1398],[1373,1380,1398],[1421,1373,1398],[1429,1421,1398],[1327,1380,1349],[1319,1327,1349],[1373,1319,1349],[1380,1373,1349],[1448,1461,1460],[1456,1448,1460],[1471,1456,1460],[1461,1471,1460],[1421,1448,1442],[1433,1421,1442],[1456,1433,1442],[1448,1456,1442],[1373,1421,1400],[1382,1373,1400],[1433,1382,1400],[1421,1433,1400],[1319,1373,1351],[1329,1319,1351],[1382,1329,1351],[1373,1382,1351],[1264,1327,1289],[1258,1264,1289],[1319,1258,1289],[1327,1319,1289],[1192,1264,1228],[1188,1192,1228],[1258,1188,1228],[1264,1258,1228],[1100,1192,1157],[1098,1100,1157],[1188,1098,1157],[1192,1188,1157],[922,1100,1006],[928,922,1006],[1098,928,1006],[1100,1098,1006],[1258,1319,1291],[1266,1258,1291],[1329,1266,1291],[1319,1329,1291],[1188,1258,1230],[1194,1188,1230],[1266,1194,1230],[1258,1266,1230],[1098,1188,1159],[1102,1098,1159],[1194,1102,1159],[1188,1194,1159],[928,1098,1008],[933,928,1008],[1102,933,1008],[1098,1102,1008],[1456,1471,1475],[1481,1456,1475],[1482,1481,1475],[1471,1482,1475],[1433,1456,1450],[1444,1433,1450],[1481,1444,1450],[1456,1481,1450],[1382,1433,1412],[1392,1382,1412],[1444,1392,1412],[1433,1444,1412],[1329,1382,1357],[1331,1329,1357],[1392,1331,1357],[1382,1392,1357],[1481,1482,1490],[1500,1481,1490],[1502,1500,1490],[1482,1502,1490],[1444,1481,1470],[1465,1444,1470],[1500,1465,1470],[1481,1500,1470],[1392,1444,1431],[1410,1392,1431],[1465,1410,1431],[1444,1465,1431],[1331,1392,1371],[1345,1331,1371],[1410,1345,1371],[1392,1410,1371],[1266,1329,1297],[1276,1266,1297],[1331,1276,1297],[1329,1331,1297],[1194,1266,1232],[1200,1194,1232],[1276,1200,1232],[1266,1276,1232],[1102,1194,1163],[1106,1102,1163],[1200,1106,1163],[1194,1200,1163],[933,1102,1016],[929,933,1016],[1106,929,1016],[1102,1106,1016],[1276,1331,1307],[1283,1276,1307],[1345,1283,1307],[1331,1345,1307],[1200,1276,1238],[1210,1200,1238],[1283,1210,1238],[1276,1283,1238],[1106,1200,1167],[1116,1106,1167],[1210,1116,1167],[1200,1210,1167],[929,1106,1022],[923,929,1022],[1116,923,1022],[1106,1116,1022],[755,922,849],[757,755,849],[928,757,849],[922,928,849],[663,755,698],[667,663,698],[757,667,698],[755,757,698],[591,663,627],[597,591,627],[667,597,627],[663,667,627],[528,591,566],[536,528,566],[597,536,566],[591,597,566],[757,928,847],[753,757,847],[933,753,847],[928,933,847],[667,757,696],[661,667,696],[753,661,696],[757,753,696],[597,667,625],[589,597,625],[661,589,625],[667,661,625],[536,597,564],[526,536,564],[589,526,564],[597,589,564],[475,528,506],[482,475,506],[536,482,506],[528,536,506],[426,475,457],[434,426,457],[482,434,457],[475,482,457],[401,426,415],[407,401,415],[434,407,415],[426,434,415],[386,401,397],[393,386,397],[407,393,397],[401,407,397],[482,536,504],[473,482,504],[526,473,504],[536,526,504],[434,482,455],[422,434,455],[473,422,455],[482,473,455],[407,434,413],[399,407,413],[422,399,413],[434,422,413],[393,407,395],[383,393,395],[399,383,395],[407,399,395],[753,933,839],[749,753,839],[929,749,839],[933,929,839],[661,753,692],[655,661,692],[749,655,692],[753,749,692],[589,661,623],[579,589,623],[655,579,623],[661,655,623],[526,589,558],[524,526,558],[579,524,558],[589,579,558],[749,929,833],[741,749,833],[923,741,833],[929,923,833],[655,749,688],[647,655,688],[741,647,688],[749,741,688],[579,655,617],[574,579,617],[647,574,617],[655,647,617],[524,579,548],[512,524,548],[574,512,548],[579,574,548],[473,526,498],[463,473,498],[524,463,498],[526,524,498],[422,473,443],[411,422,443],[463,411,443],[473,463,443],[399,422,405],[374,399,405],[411,374,405],[422,411,405],[383,399,380],[372,383,380],[374,372,380],[399,374,380],[463,524,484],[447,463,484],[512,447,484],[524,512,484],[411,463,424],[392,411,424],[447,392,424],[463,447,424],[374,411,385],[357,374,385],[392,357,385],[411,392,385],[372,374,365],[353,372,365],[357,353,365],[374,357,365],[400,386,396],[406,400,396],[393,406,396],[386,393,396],[425,400,414],[433,425,414],[406,433,414],[400,406,414],[474,425,456],[481,474,456],[433,481,456],[425,433,456],[527,474,505],[535,527,505],[481,535,505],[474,481,505],[406,393,394],[398,406,394],[383,398,394],[393,383,394],[433,406,412],[421,433,412],[398,421,412],[406,398,412],[481,433,454],[472,481,454],[421,472,454],[433,421,454],[535,481,503],[525,535,503],[472,525,503],[481,472,503],[590,527,565],[596,590,565],[535,596,565],[527,535,565],[662,590,626],[666,662,626],[596,666,626],[590,596,626],[754,662,697],[756,754,697],[666,756,697],[662,666,697],[919,754,848],[927,919,848],[756,927,848],[754,756,848],[596,535,563],[588,596,563],[525,588,563],[535,525,563],[666,596,624],[660,666,624],[588,660,624],[596,588,624],[756,666,695],[752,756,695],[660,752,695],[666,660,695],[927,756,846],[932,927,846],[752,932,846],[756,752,846],[398,383,379],[373,398,379],[372,373,379],[383,372,379],[421,398,404],[410,421,404],[373,410,404],[398,373,404],[472,421,442],[462,472,442],[410,462,442],[421,410,442],[525,472,497],[523,525,497],[462,523,497],[472,462,497],[373,372,364],[356,373,364],[353,356,364],[372,353,364],[410,373,384],[391,410,384],[356,391,384],[373,356,384],[462,410,423],[446,462,423],[391,446,423],[410,391,423],[523,462,483],[511,523,483],[446,511,483],[462,446,483],[588,525,557],[578,588,557],[523,578,557],[525,523,557],[660,588,622],[654,660,622],[578,654,622],[588,578,622],[752,660,691],[748,752,691],[654,748,691],[660,654,691],[932,752,838],[926,932,838],[748,926,838],[752,748,838],[578,523,547],[573,578,547],[511,573,547],[523,511,547],[654,578,616],[646,654,616],[573,646,616],[578,573,616],[748,654,687],[740,748,687],[646,740,687],[654,646,687],[926,748,832],[918,926,832],[740,918,832],[748,740,832],[1099,919,1005],[1097,1099,1005],[927,1097,1005],[919,927,1005],[1191,1099,1156],[1187,1191,1156],[1097,1187,1156],[1099,1097,1156],[1263,1191,1227],[1257,1263,1227],[1187,1257,1227],[1191,1187,1227],[1326,1263,1288],[1318,1326,1288],[1257,1318,1288],[1263,1257,1288],[1097,927,1007],[1101,1097,1007],[932,1101,1007],[927,932,1007],[1187,1097,1158],[1193,1187,1158],[1101,1193,1158],[1097,1101,1158],[1257,1187,1229],[1265,1257,1229],[1193,1265,1229],[1187,1193,1229],[1318,1257,1290],[1328,1318,1290],[1265,1328,1290],[1257,1265,1290],[1379,1326,1348],[1372,1379,1348],[1318,1372,1348],[1326,1318,1348],[1428,1379,1397],[1420,1428,1397],[1372,1420,1397],[1379,1372,1397],[1453,1428,1439],[1447,1453,1439],[1420,1447,1439],[1428,1420,1439],[1468,1453,1457],[1461,1468,1457],[1447,1461,1457],[1453,1447,1457],[1372,1318,1350],[1381,1372,1350],[1328,1381,1350],[1318,1328,1350],[1420,1372,1399],[1432,1420,1399],[1381,1432,1399],[1372,1381,1399],[1447,1420,1441],[1455,1447,1441],[1432,1455,1441],[1420,1432,1441],[1461,1447,1459],[1471,1461,1459],[1455,1471,1459],[1447,1455,1459],[1101,932,1015],[1105,1101,1015],[926,1105,1015],[932,926,1015],[1193,1101,1162],[1199,1193,1162],[1105,1199,1162],[1101,1105,1162],[1265,1193,1231],[1275,1265,1231],[1199,1275,1231],[1193,1199,1231],[1328,1265,1296],[1330,1328,1296],[1275,1330,1296],[1265,1275,1296],[1105,926,1021],[1115,1105,1021],[918,1115,1021],[926,918,1021],[1199,1105,1166],[1209,1199,1166],[1115,1209,1166],[1105,1115,1166],[1275,1199,1237],[1282,1275,1237],[1209,1282,1237],[1199,1209,1237],[1330,1275,1306],[1344,1330,1306],[1282,1344,1306],[1275,1282,1306],[1381,1328,1356],[1391,1381,1356],[1330,1391,1356],[1328,1330,1356],[1432,1381,1411],[1443,1432,1411],[1391,1443,1411],[1381,1391,1411],[1455,1432,1449],[1480,1455,1449],[1443,1480,1449],[1432,1443,1449],[1471,1455,1474],[1482,1471,1474],[1480,1482,1474],[1455,1480,1474],[1391,1330,1370],[1409,1391,1370],[1344,1409,1370],[1330,1344,1370],[1443,1391,1430],[1464,1443,1430],[1409,1464,1430],[1391,1409,1430],[1480,1443,1469],[1499,1480,1469],[1464,1499,1469],[1443,1464,1469],[1482,1480,1489],[1502,1482,1489],[1499,1502,1489],[1480,1499,1489],[1500,1502,1533],[1572,1500,1533],[1585,1572,1533],[1502,1585,1533],[1465,1500,1519],[1555,1465,1519],[1572,1555,1519],[1500,1572,1519],[1410,1465,1496],[1510,1410,1496],[1555,1510,1496],[1465,1555,1496],[1345,1410,1427],[1436,1345,1427],[1510,1436,1427],[1410,1510,1427],[1283,1345,1341],[1333,1283,1341],[1436,1333,1341],[1345,1436,1341],[1210,1283,1270],[1242,1210,1270],[1333,1242,1270],[1283,1333,1270],[1116,1210,1184],[1143,1116,1184],[1242,1143,1184],[1210,1242,1184],[923,1116,1037],[917,923,1037],[1143,917,1037],[1116,1143,1037],[1572,1585,1599],[1611,1572,1599],[1622,1611,1599],[1585,1622,1599],[1555,1572,1574],[1570,1555,1574],[1611,1570,1574],[1572,1611,1574],[1510,1555,1537],[1527,1510,1537],[1570,1527,1537],[1555,1570,1537],[1436,1510,1494],[1467,1436,1494],[1527,1467,1494],[1510,1527,1494],[1611,1622,1624],[1626,1611,1624],[1633,1626,1624],[1622,1633,1624],[1570,1611,1601],[1589,1570,1601],[1626,1589,1601],[1611,1626,1601],[1527,1570,1561],[1535,1527,1561],[1589,1535,1561],[1570,1589,1561],[1467,1527,1508],[1479,1467,1508],[1535,1479,1508],[1527,1535,1508],[1333,1436,1394],[1359,1333,1394],[1467,1359,1394],[1436,1467,1394],[1242,1333,1299],[1254,1242,1299],[1359,1254,1299],[1333,1359,1299],[1143,1242,1198],[1149,1143,1198],[1254,1149,1198],[1242,1254,1198],[917,1143,1057],[915,917,1057],[1149,915,1057],[1143,1149,1057],[1359,1467,1414],[1367,1359,1414],[1479,1367,1414],[1467,1479,1414],[1254,1359,1311],[1262,1254,1311],[1367,1262,1311],[1359,1367,1311],[1149,1254,1212],[1155,1149,1212],[1262,1155,1212],[1254,1262,1212],[915,1149,1065],[913,915,1065],[1155,913,1065],[1149,1155,1065],[741,923,818],[712,741,818],[917,712,818],[923,917,818],[647,741,671],[613,647,671],[712,613,671],[741,712,671],[574,647,585],[522,574,585],[613,522,585],[647,613,585],[512,574,514],[419,512,514],[522,419,514],[574,522,514],[447,512,428],[342,447,428],[419,342,428],[512,419,428],[392,447,359],[308,392,359],[342,308,359],[447,342,359],[357,392,329],[291,357,329],[308,291,329],[392,308,329],[353,357,314],[275,353,314],[291,275,314],[357,291,314],[712,917,798],[706,712,798],[915,706,798],[917,915,798],[613,712,657],[601,613,657],[706,601,657],[712,706,657],[522,613,556],[496,522,556],[601,496,556],[613,601,556],[419,522,461],[388,419,461],[496,388,461],[522,496,461],[706,915,790],[700,706,790],[913,700,790],[915,913,790],[601,706,643],[593,601,643],[700,593,643],[706,700,643],[496,601,544],[488,496,544],[593,488,544],[601,593,544],[388,496,441],[376,388,441],[488,376,441],[496,488,441],[342,419,361],[320,342,361],[388,320,361],[419,388,361],[308,342,310],[293,308,310],[320,293,310],[342,320,310],[291,308,289],[257,291,289],[293,257,289],[308,293,289],[275,291,270],[246,275,270],[257,246,270],[291,257,270],[320,388,344],[312,320,344],[376,312,344],[388,376,344],[293,320,302],[274,293,302],[312,274,302],[320,312,302],[257,293,268],[243,257,268],[274,243,268],[293,274,268],[246,257,245],[232,246,245],[243,232,245],[257,243,245],[356,353,313],[290,356,313],[275,290,313],[353,275,313],[391,356,328],[307,391,328],[290,307,328],[356,290,328],[446,391,358],[341,446,358],[307,341,358],[391,307,358],[511,446,427],[418,511,427],[341,418,427],[446,341,427],[573,511,513],[521,573,513],[418,521,513],[511,418,513],[646,573,584],[612,646,584],[521,612,584],[573,521,584],[740,646,670],[711,740,670],[612,711,670],[646,612,670],[918,740,817],[916,918,817],[711,916,817],[740,711,817],[290,275,269],[256,290,269],[246,256,269],[275,246,269],[307,290,288],[292,307,288],[256,292,288],[290,256,288],[341,307,309],[319,341,309],[292,319,309],[307,292,309],[418,341,360],[387,418,360],[319,387,360],[341,319,360],[256,246,244],[242,256,244],[232,242,244],[246,232,244],[292,256,267],[273,292,267],[242,273,267],[256,242,267],[319,292,301],[311,319,301],[273,311,301],[292,273,301],[387,319,343],[375,387,343],[311,375,343],[319,311,343],[521,418,460],[495,521,460],[387,495,460],[418,387,460],[612,521,555],[600,612,555],[495,600,555],[521,495,555],[711,612,656],[705,711,656],[600,705,656],[612,600,656],[916,711,797],[914,916,797],[705,914,797],[711,705,797],[495,387,440],[487,495,440],[375,487,440],[387,375,440],[600,495,543],[592,600,543],[487,592,543],[495,487,543],[705,600,642],[699,705,642],[592,699,642],[600,592,642],[914,705,789],[912,914,789],[699,912,789],[705,699,789],[1115,918,1036],[1142,1115,1036],[916,1142,1036],[918,916,1036],[1209,1115,1183],[1241,1209,1183],[1142,1241,1183],[1115,1142,1183],[1282,1209,1269],[1332,1282,1269],[1241,1332,1269],[1209,1241,1269],[1344,1282,1340],[1435,1344,1340],[1332,1435,1340],[1282,1332,1340],[1409,1344,1426],[1509,1409,1426],[1435,1509,1426],[1344,1435,1426],[1464,1409,1495],[1554,1464,1495],[1509,1554,1495],[1409,1509,1495],[1499,1464,1518],[1571,1499,1518],[1554,1571,1518],[1464,1554,1518],[1502,1499,1532],[1585,1502,1532],[1571,1585,1532],[1499,1571,1532],[1142,916,1056],[1148,1142,1056],[914,1148,1056],[916,914,1056],[1241,1142,1197],[1253,1241,1197],[1148,1253,1197],[1142,1148,1197],[1332,1241,1298],[1358,1332,1298],[1253,1358,1298],[1241,1253,1298],[1435,1332,1393],[1466,1435,1393],[1358,1466,1393],[1332,1358,1393],[1148,914,1064],[1154,1148,1064],[912,1154,1064],[914,912,1064],[1253,1148,1211],[1261,1253,1211],[1154,1261,1211],[1148,1154,1211],[1358,1253,1310],[1366,1358,1310],[1261,1366,1310],[1253,1261,1310],[1466,1358,1413],[1478,1466,1413],[1366,1478,1413],[1358,1366,1413],[1509,1435,1493],[1526,1509,1493],[1466,1526,1493],[1435,1466,1493],[1554,1509,1536],[1569,1554,1536],[1526,1569,1536],[1509,1526,1536],[1571,1554,1573],[1610,1571,1573],[1569,1610,1573],[1554,1569,1573],[1585,1571,1598],[1622,1585,1598],[1610,1622,1598],[1571,1610,1598],[1526,1466,1507],[1534,1526,1507],[1478,1534,1507],[1466,1478,1507],[1569,1526,1560],[1588,1569,1560],[1534,1588,1560],[1526,1534,1560],[1610,1569,1600],[1625,1610,1600],[1588,1625,1600],[1569,1588,1600],[1622,1610,1623],[1633,1622,1623],[1625,1633,1623],[1610,1625,1623],[1626,1633,1628],[1621,1626,1628],[1629,1621,1628],[1633,1629,1628],[1589,1626,1607],[1584,1589,1607],[1621,1584,1607],[1626,1621,1607],[1621,1629,1616],[1603,1621,1616],[1612,1603,1616],[1629,1612,1616],[1584,1621,1593],[1568,1584,1593],[1603,1568,1593],[1621,1603,1593],[1535,1589,1563],[1529,1535,1563],[1584,1529,1563],[1589,1584,1563],[1479,1535,1512],[1473,1479,1512],[1529,1473,1512],[1535,1529,1512],[1529,1584,1557],[1521,1529,1557],[1568,1521,1557],[1584,1568,1557],[1473,1529,1504],[1452,1473,1504],[1521,1452,1504],[1529,1521,1504],[1603,1612,1580],[1559,1603,1580],[1566,1559,1580],[1612,1566,1580],[1568,1603,1565],[1525,1568,1565],[1559,1525,1565],[1603,1559,1565],[1521,1568,1523],[1484,1521,1523],[1525,1484,1523],[1568,1525,1523],[1452,1521,1477],[1406,1452,1477],[1484,1406,1477],[1521,1484,1477],[1367,1479,1417],[1361,1367,1417],[1473,1361,1417],[1479,1473,1417],[1262,1367,1313],[1260,1262,1313],[1361,1260,1313],[1367,1361,1313],[1361,1473,1404],[1355,1361,1404],[1452,1355,1404],[1473,1452,1404],[1260,1361,1303],[1248,1260,1303],[1355,1248,1303],[1361,1355,1303],[1155,1262,1214],[1151,1155,1214],[1260,1151,1214],[1262,1260,1214],[913,1155,1067],[911,913,1067],[1151,911,1067],[1155,1151,1067],[1151,1260,1204],[1147,1151,1204],[1248,1147,1204],[1260,1248,1204],[911,1151,1062],[909,911,1062],[1147,909,1062],[1151,1147,1062],[1355,1452,1384],[1323,1355,1384],[1406,1323,1384],[1452,1406,1384],[1248,1355,1287],[1236,1248,1287],[1323,1236,1287],[1355,1323,1287],[1147,1248,1190],[1135,1147,1190],[1236,1135,1190],[1248,1236,1190],[909,1147,1051],[907,909,1051],[1135,907,1051],[1147,1135,1051],[1559,1566,1531],[1514,1559,1531],[1515,1514,1531],[1566,1515,1531],[1525,1559,1517],[1486,1525,1517],[1514,1486,1517],[1559,1514,1517],[1484,1525,1488],[1438,1484,1488],[1486,1438,1488],[1525,1486,1488],[1406,1484,1425],[1363,1406,1425],[1438,1363,1425],[1484,1438,1425],[1514,1515,1506],[1498,1514,1506],[1501,1498,1506],[1515,1501,1506],[1486,1514,1492],[1463,1486,1492],[1498,1463,1492],[1514,1498,1492],[1438,1486,1446],[1408,1438,1446],[1463,1408,1446],[1486,1463,1446],[1363,1438,1386],[1343,1363,1386],[1408,1343,1386],[1438,1408,1386],[1323,1406,1337],[1293,1323,1337],[1363,1293,1337],[1406,1363,1337],[1236,1323,1268],[1220,1236,1268],[1293,1220,1268],[1323,1293,1268],[1135,1236,1182],[1122,1135,1182],[1220,1122,1182],[1236,1220,1182],[907,1135,1035],[905,907,1035],[1122,905,1035],[1135,1122,1035],[1293,1363,1317],[1281,1293,1317],[1343,1281,1317],[1363,1343,1317],[1220,1293,1246],[1208,1220,1246],[1281,1208,1246],[1293,1281,1246],[1122,1220,1172],[1114,1122,1172],[1208,1114,1172],[1220,1208,1172],[905,1122,1026],[903,905,1026],[1114,903,1026],[1122,1114,1026],[700,913,788],[704,700,788],[911,704,788],[913,911,788],[593,700,641],[595,593,641],[704,595,641],[700,704,641],[704,911,793],[708,704,793],[909,708,793],[911,909,793],[595,704,651],[607,595,651],[708,607,651],[704,708,651],[488,593,542],[494,488,542],[595,494,542],[593,595,542],[376,488,438],[382,376,438],[494,382,438],[488,494,438],[494,595,552],[500,494,552],[607,500,552],[595,607,552],[382,494,451],[403,382,451],[500,403,451],[494,500,451],[708,909,804],[718,708,804],[907,718,804],[909,907,804],[607,708,665],[619,607,665],[718,619,665],[708,718,665],[500,607,568],[532,500,568],[619,532,568],[607,619,568],[403,500,471],[449,403,471],[532,449,471],[500,532,471],[312,376,340],[318,312,340],[382,318,340],[376,382,340],[274,312,300],[285,274,300],[318,285,300],[312,318,300],[318,382,350],[327,318,350],[403,327,350],[382,403,350],[285,318,306],[295,285,306],[327,295,306],[318,327,306],[243,274,264],[250,243,264],[285,250,264],[274,285,264],[232,243,239],[237,232,239],[250,237,239],[243,250,239],[250,285,272],[266,250,272],[295,266,272],[285,295,272],[237,250,254],[255,237,254],[266,255,254],[250,266,254],[327,403,378],[371,327,378],[449,371,378],[403,449,378],[295,327,324],[322,295,324],[371,322,324],[327,371,324],[266,295,298],[304,266,298],[322,304,298],[295,322,298],[255,266,287],[296,255,287],[304,296,287],[266,304,287],[718,907,820],[733,718,820],[905,733,820],[907,905,820],[619,718,673],[635,619,673],[733,635,673],[718,733,673],[532,619,587],[562,532,587],[635,562,587],[619,635,587],[449,532,518],[492,449,518],[562,492,518],[532,562,518],[733,905,829],[739,733,829],[903,739,829],[905,903,829],[635,733,683],[645,635,683],[739,645,683],[733,739,683],[562,635,609],[572,562,609],[645,572,609],[635,645,609],[492,562,538],[510,492,538],[572,510,538],[562,572,538],[371,449,430],[417,371,430],[492,417,430],[449,492,430],[322,371,367],[369,322,367],[417,369,367],[371,417,367],[304,322,333],[338,304,333],[369,338,333],[322,369,333],[296,304,316],[334,296,316],[338,334,316],[304,338,316],[417,492,469],[445,417,469],[510,445,469],[492,510,469],[369,417,409],[390,369,409],[445,390,409],[417,445,409],[338,369,363],[355,338,363],[390,355,363],[369,390,363],[334,338,346],[351,334,346],[355,351,346],[338,355,346],[242,232,238],[249,242,238],[237,249,238],[232,237,238],[273,242,263],[284,273,263],[249,284,263],[242,249,263],[249,237,253],[265,249,253],[255,265,253],[237,255,253],[284,249,271],[294,284,271],[265,294,271],[249,265,271],[311,273,299],[317,311,299],[284,317,299],[273,284,299],[375,311,339],[381,375,339],[317,381,339],[311,317,339],[317,284,305],[326,317,305],[294,326,305],[284,294,305],[381,317,349],[402,381,349],[326,402,349],[317,326,349],[265,255,286],[303,265,286],[296,303,286],[255,296,286],[294,265,297],[321,294,297],[303,321,297],[265,303,297],[326,294,323],[370,326,323],[321,370,323],[294,321,323],[402,326,377],[448,402,377],[370,448,377],[326,370,377],[487,375,437],[493,487,437],[381,493,437],[375,381,437],[592,487,541],[594,592,541],[493,594,541],[487,493,541],[493,381,450],[499,493,450],[402,499,450],[381,402,450],[594,493,551],[606,594,551],[499,606,551],[493,499,551],[699,592,640],[703,699,640],[594,703,640],[592,594,640],[912,699,787],[910,912,787],[703,910,787],[699,703,787],[703,594,650],[707,703,650],[606,707,650],[594,606,650],[910,703,792],[908,910,792],[707,908,792],[703,707,792],[499,402,470],[531,499,470],[448,531,470],[402,448,470],[606,499,567],[618,606,567],[531,618,567],[499,531,567],[707,606,664],[719,707,664],[618,719,664],[606,618,664],[908,707,803],[906,908,803],[719,906,803],[707,719,803],[303,296,315],[337,303,315],[334,337,315],[296,334,315],[321,303,332],[368,321,332],[337,368,332],[303,337,332],[370,321,366],[416,370,366],[368,416,366],[321,368,366],[448,370,429],[491,448,429],[416,491,429],[370,416,429],[337,334,345],[354,337,345],[351,354,345],[334,351,345],[368,337,362],[389,368,362],[354,389,362],[337,354,362],[416,368,408],[444,416,408],[389,444,408],[368,389,408],[491,416,468],[509,491,468],[444,509,468],[416,444,468],[531,448,517],[561,531,517],[491,561,517],[448,491,517],[618,531,586],[634,618,586],[561,634,586],[531,561,586],[719,618,672],[732,719,672],[634,732,672],[618,634,672],[906,719,819],[904,906,819],[732,904,819],[719,732,819],[561,491,537],[571,561,537],[509,571,537],[491,509,537],[634,561,608],[644,634,608],[571,644,608],[561,571,608],[732,634,682],[738,732,682],[644,738,682],[634,644,682],[904,732,828],[902,904,828],[738,902,828],[732,738,828],[1154,912,1066],[1150,1154,1066],[910,1150,1066],[912,910,1066],[1261,1154,1213],[1259,1261,1213],[1150,1259,1213],[1154,1150,1213],[1150,910,1061],[1146,1150,1061],[908,1146,1061],[910,908,1061],[1259,1150,1203],[1247,1259,1203],[1146,1247,1203],[1150,1146,1203],[1366,1261,1312],[1360,1366,1312],[1259,1360,1312],[1261,1259,1312],[1478,1366,1416],[1472,1478,1416],[1360,1472,1416],[1366,1360,1416],[1360,1259,1302],[1354,1360,1302],[1247,1354,1302],[1259,1247,1302],[1472,1360,1403],[1451,1472,1403],[1354,1451,1403],[1360,1354,1403],[1146,908,1050],[1136,1146,1050],[906,1136,1050],[908,906,1050],[1247,1146,1189],[1235,1247,1189],[1136,1235,1189],[1146,1136,1189],[1354,1247,1286],[1322,1354,1286],[1235,1322,1286],[1247,1235,1286],[1451,1354,1383],[1405,1451,1383],[1322,1405,1383],[1354,1322,1383],[1534,1478,1511],[1528,1534,1511],[1472,1528,1511],[1478,1472,1511],[1588,1534,1562],[1583,1588,1562],[1528,1583,1562],[1534,1528,1562],[1528,1472,1503],[1520,1528,1503],[1451,1520,1503],[1472,1451,1503],[1583,1528,1556],[1567,1583,1556],[1520,1567,1556],[1528,1520,1556],[1625,1588,1606],[1620,1625,1606],[1583,1620,1606],[1588,1583,1606],[1633,1625,1627],[1629,1633,1627],[1620,1629,1627],[1625,1620,1627],[1620,1583,1592],[1602,1620,1592],[1567,1602,1592],[1583,1567,1592],[1629,1620,1615],[1612,1629,1615],[1602,1612,1615],[1620,1602,1615],[1520,1451,1476],[1483,1520,1476],[1405,1483,1476],[1451,1405,1476],[1567,1520,1522],[1524,1567,1522],[1483,1524,1522],[1520,1483,1522],[1602,1567,1564],[1558,1602,1564],[1524,1558,1564],[1567,1524,1564],[1612,1602,1579],[1566,1612,1579],[1558,1566,1579],[1602,1558,1579],[1136,906,1034],[1121,1136,1034],[904,1121,1034],[906,904,1034],[1235,1136,1181],[1219,1235,1181],[1121,1219,1181],[1136,1121,1181],[1322,1235,1267],[1292,1322,1267],[1219,1292,1267],[1235,1219,1267],[1405,1322,1336],[1362,1405,1336],[1292,1362,1336],[1322,1292,1336],[1121,904,1025],[1113,1121,1025],[902,1113,1025],[904,902,1025],[1219,1121,1171],[1207,1219,1171],[1113,1207,1171],[1121,1113,1171],[1292,1219,1245],[1280,1292,1245],[1207,1280,1245],[1219,1207,1245],[1362,1292,1316],[1342,1362,1316],[1280,1342,1316],[1292,1280,1316],[1483,1405,1424],[1437,1483,1424],[1362,1437,1424],[1405,1362,1424],[1524,1483,1487],[1485,1524,1487],[1437,1485,1487],[1483,1437,1487],[1558,1524,1516],[1513,1558,1516],[1485,1513,1516],[1524,1485,1516],[1566,1558,1530],[1515,1566,1530],[1513,1515,1530],[1558,1513,1530],[1437,1362,1385],[1407,1437,1385],[1342,1407,1385],[1362,1342,1385],[1485,1437,1445],[1462,1485,1445],[1407,1462,1445],[1437,1407,1445],[1513,1485,1491],[1497,1513,1491],[1462,1497,1491],[1485,1462,1491],[1515,1513,1505],[1501,1515,1505],[1497,1501,1505],[1513,1497,1505],[331,325,277],[228,331,277],[231,228,277],[325,231,277],[336,331,279],[224,336,279],[228,224,279],[331,228,279],[228,231,200],[173,228,200],[178,173,200],[231,178,200],[224,228,198],[167,224,198],[173,167,198],[228,173,198],[348,336,281],[222,348,281],[224,222,281],[336,224,281],[352,348,283],[210,352,283],[222,210,283],[348,222,283],[222,224,193],[150,222,193],[167,150,193],[224,167,193],[210,222,183],[142,210,183],[150,142,183],[222,150,183],[177,178,165],[136,177,165],[141,136,165],[178,141,165],[173,177,162],[127,173,162],[136,127,162],[177,136,162],[167,173,158],[131,167,158],[152,131,158],[173,152,158],[131,152,129],[82,131,129],[127,82,129],[152,127,129],[136,141,134],[114,136,134],[121,114,134],[141,121,134],[127,136,118],[93,127,118],[114,93,118],[136,114,118],[114,121,112],[101,114,112],[108,101,112],[121,108,112],[93,114,95],[90,93,95],[101,90,95],[114,101,95],[82,127,88],[59,82,88],[93,59,88],[127,93,88],[59,93,74],[52,59,74],[90,52,74],[93,90,74],[150,167,140],[86,150,140],[131,86,140],[167,131,140],[86,131,84],[50,86,84],[82,50,84],[131,82,84],[148,150,120],[76,148,120],[86,76,120],[150,86,120],[142,148,110],[72,142,110],[76,72,110],[148,76,110],[76,86,65],[36,76,65],[50,36,65],[86,50,65],[72,76,57],[34,72,57],[36,34,57],[76,36,57],[50,82,55],[27,50,55],[59,27,55],[82,59,55],[27,59,42],[18,27,42],[52,18,42],[59,52,42],[36,50,33],[12,36,33],[27,12,33],[50,27,33],[34,36,24],[8,34,24],[12,8,24],[36,12,24],[12,27,16],[2,12,16],[18,2,16],[27,18,16],[8,12,7],[0,8,7],[2,0,7],[12,2,7],[347,352,282],[221,347,282],[210,221,282],[352,210,282],[335,347,280],[223,335,280],[221,223,280],[347,221,280],[221,210,182],[149,221,182],[142,149,182],[210,142,182],[223,221,192],[166,223,192],[149,166,192],[221,149,192],[330,335,278],[227,330,278],[223,227,278],[335,223,278],[325,330,276],[231,325,276],[227,231,276],[330,227,276],[227,223,197],[172,227,197],[166,172,197],[223,166,197],[231,227,199],[178,231,199],[172,178,199],[227,172,199],[147,142,109],[75,147,109],[72,75,109],[142,72,109],[149,147,119],[85,149,119],[75,85,119],[147,75,119],[75,72,56],[35,75,56],[34,35,56],[72,34,56],[85,75,64],[49,85,64],[35,49,64],[75,35,64],[166,149,139],[130,166,139],[85,130,139],[149,85,139],[130,85,83],[81,130,83],[49,81,83],[85,49,83],[35,34,23],[11,35,23],[8,11,23],[34,8,23],[49,35,32],[26,49,32],[11,26,32],[35,11,32],[11,8,6],[1,11,6],[0,1,6],[8,0,6],[26,11,15],[17,26,15],[1,17,15],[11,1,15],[81,49,54],[58,81,54],[26,58,54],[49,26,54],[58,26,41],[51,58,41],[17,51,41],[26,17,41],[172,166,157],[151,172,157],[130,151,157],[166,130,157],[151,130,128],[126,151,128],[81,126,128],[130,81,128],[176,172,161],[135,176,161],[126,135,161],[172,126,161],[178,176,164],[141,178,164],[135,141,164],[176,135,164],[126,81,87],[92,126,87],[58,92,87],[81,58,87],[92,58,73],[89,92,73],[51,89,73],[58,51,73],[135,126,117],[113,135,117],[92,113,117],[126,92,117],[141,135,133],[121,141,133],[113,121,133],[135,113,133],[113,92,94],[100,113,94],[89,100,94],[92,89,94],[121,113,111],[108,121,111],[100,108,111],[113,100,111],[101,108,116],[125,101,116],[132,125,116],[108,132,116],[90,101,103],[105,90,103],[125,105,103],[101,125,103],[52,90,78],[71,52,78],[105,71,78],[90,105,78],[125,132,146],[156,125,146],[163,156,146],[132,163,146],[105,125,144],[154,105,144],[156,154,144],[125,156,144],[71,105,123],[138,71,123],[154,138,123],[105,154,123],[18,52,38],[22,18,38],[63,22,38],[52,63,38],[22,63,48],[40,22,48],[71,40,48],[63,71,48],[2,18,14],[10,2,14],[22,10,14],[18,22,14],[0,2,4],[5,0,4],[10,5,4],[2,10,4],[10,22,29],[31,10,29],[40,31,29],[22,40,29],[5,10,20],[25,5,20],[31,25,20],[10,31,20],[40,71,69],[67,40,69],[97,67,69],[71,97,69],[67,97,99],[107,67,99],[138,107,99],[97,138,99],[31,40,46],[61,31,46],[67,61,46],[40,67,46],[25,31,44],[53,25,44],[61,53,44],[31,61,44],[53,67,80],[91,53,80],[107,91,80],[67,107,80],[154,163,175],[195,154,175],[196,195,175],[163,196,175],[138,154,171],[189,138,171],[195,189,171],[154,195,171],[195,196,202],[207,195,202],[203,207,202],[196,203,202],[205,203,226],[234,205,226],[232,234,226],[203,232,226],[207,205,230],[236,207,230],[234,236,230],[205,234,230],[191,195,209],[241,191,209],[236,241,209],[195,236,209],[189,191,212],[248,189,212],[241,248,212],[191,241,212],[107,138,169],[185,107,169],[189,185,169],[138,189,169],[91,107,160],[179,91,160],[185,179,160],[107,185,160],[187,189,214],[252,187,214],[248,252,214],[189,248,214],[185,187,216],[259,185,216],[252,259,216],[187,252,216],[181,185,218],[261,181,218],[259,261,218],[185,259,218],[179,181,220],[262,179,220],[261,262,220],[181,261,220],[1,0,3],[9,1,3],[5,9,3],[0,5,3],[17,1,13],[21,17,13],[9,21,13],[1,9,13],[9,5,19],[30,9,19],[25,30,19],[5,25,19],[21,9,28],[39,21,28],[30,39,28],[9,30,28],[51,17,37],[62,51,37],[21,62,37],[17,21,37],[62,21,47],[70,62,47],[39,70,47],[21,39,47],[30,25,43],[60,30,43],[53,60,43],[25,53,43],[39,30,45],[66,39,45],[60,66,45],[30,60,45],[66,53,79],[106,66,79],[91,106,79],[53,91,79],[70,39,68],[96,70,68],[66,96,68],[39,66,68],[96,66,98],[137,96,98],[106,137,98],[66,106,98],[89,51,77],[104,89,77],[70,104,77],[51,70,77],[100,89,102],[124,100,102],[104,124,102],[89,104,102],[108,100,115],[132,108,115],[124,132,115],[100,124,115],[104,70,122],[153,104,122],[137,153,122],[70,137,122],[124,104,143],[155,124,143],[153,155,143],[104,153,143],[132,124,145],[163,132,145],[155,163,145],[124,155,145],[106,91,159],[184,106,159],[179,184,159],[91,179,159],[137,106,168],[188,137,168],[184,188,168],[106,184,168],[180,179,219],[260,180,219],[262,260,219],[179,262,219],[184,180,217],[258,184,217],[260,258,217],[180,260,217],[186,184,215],[251,186,215],[258,251,215],[184,258,215],[188,186,213],[247,188,213],[251,247,213],[186,251,213],[153,137,170],[194,153,170],[188,194,170],[137,188,170],[163,153,174],[196,163,174],[194,196,174],[153,194,174],[190,188,211],[240,190,211],[247,240,211],[188,247,211],[194,190,208],[235,194,208],[240,235,208],[190,240,208],[196,194,201],[203,196,201],[206,203,201],[194,206,201],[204,206,229],[233,204,229],[235,233,229],[206,235,229],[203,204,225],[232,203,225],[233,232,225],[204,233,225],[1552,1553,1587],[1632,1552,1587],[1630,1632,1587],[1553,1630,1587],[1550,1552,1591],[1637,1550,1591],[1632,1637,1591],[1552,1632,1591],[1632,1630,1647],[1665,1632,1647],[1663,1665,1647],[1630,1663,1647],[1637,1632,1651],[1673,1637,1651],[1665,1673,1651],[1632,1665,1651],[1548,1550,1595],[1641,1548,1595],[1637,1641,1595],[1550,1637,1595],[1546,1548,1597],[1645,1546,1597],[1641,1645,1597],[1548,1641,1597],[1641,1637,1657],[1679,1641,1657],[1673,1679,1657],[1637,1673,1657],[1645,1641,1660],[1688,1645,1660],[1679,1688,1660],[1641,1679,1660],[1665,1663,1677],[1695,1665,1677],[1693,1695,1677],[1663,1693,1677],[1673,1665,1683],[1705,1673,1683],[1695,1705,1683],[1665,1695,1683],[1695,1693,1707],[1718,1695,1707],[1712,1718,1707],[1693,1712,1707],[1705,1695,1709],[1725,1705,1709],[1718,1725,1709],[1695,1718,1709],[1679,1673,1692],[1714,1679,1692],[1705,1714,1692],[1673,1705,1692],[1688,1679,1703],[1729,1688,1703],[1714,1729,1703],[1679,1714,1703],[1714,1705,1723],[1739,1714,1723],[1725,1739,1723],[1705,1725,1723],[1729,1714,1733],[1752,1729,1733],[1739,1752,1733],[1714,1739,1733],[1544,1546,1605],[1649,1544,1605],[1645,1649,1605],[1546,1645,1605],[1542,1544,1576],[1614,1542,1576],[1609,1614,1576],[1544,1609,1576],[1614,1609,1635],[1653,1614,1635],[1649,1653,1635],[1609,1649,1635],[1649,1645,1669],[1699,1649,1669],[1688,1699,1669],[1645,1688,1669],[1653,1649,1662],[1681,1653,1662],[1675,1681,1662],[1649,1675,1662],[1681,1675,1690],[1711,1681,1690],[1699,1711,1690],[1675,1699,1690],[1540,1542,1578],[1618,1540,1578],[1614,1618,1578],[1542,1614,1578],[1618,1614,1639],[1655,1618,1639],[1653,1655,1639],[1614,1653,1639],[1538,1540,1582],[1619,1538,1582],[1618,1619,1582],[1540,1618,1582],[1619,1618,1643],[1658,1619,1643],[1655,1658,1643],[1618,1655,1643],[1655,1653,1667],[1685,1655,1667],[1681,1685,1667],[1653,1681,1667],[1685,1681,1697],[1720,1685,1697],[1711,1720,1697],[1681,1711,1697],[1658,1655,1671],[1686,1658,1671],[1685,1686,1671],[1655,1685,1671],[1686,1685,1701],[1721,1686,1701],[1720,1721,1701],[1685,1720,1701],[1699,1688,1716],[1743,1699,1716],[1729,1743,1716],[1688,1729,1716],[1711,1699,1727],[1754,1711,1727],[1743,1754,1727],[1699,1743,1727],[1743,1729,1748],[1770,1743,1748],[1752,1770,1748],[1729,1752,1748],[1754,1743,1760],[1786,1754,1760],[1770,1786,1760],[1743,1770,1760],[1720,1711,1735],[1762,1720,1735],[1754,1762,1735],[1711,1754,1735],[1721,1720,1741],[1768,1721,1741],[1762,1768,1741],[1720,1762,1741],[1762,1754,1776],[1796,1762,1776],[1786,1796,1776],[1754,1786,1776],[1768,1762,1782],[1801,1768,1782],[1796,1801,1782],[1762,1796,1782],[1718,1712,1731],[1746,1718,1731],[1744,1746,1731],[1712,1744,1731],[1725,1718,1737],[1758,1725,1737],[1746,1758,1737],[1718,1746,1737],[1739,1725,1750],[1780,1739,1750],[1758,1780,1750],[1725,1758,1750],[1752,1739,1765],[1800,1752,1765],[1780,1800,1765],[1739,1780,1765],[1746,1744,1756],[1772,1746,1756],[1763,1772,1756],[1744,1763,1756],[1758,1746,1767],[1788,1758,1767],[1772,1788,1767],[1746,1772,1767],[1772,1763,1790],[1814,1772,1790],[1806,1814,1790],[1763,1806,1790],[1788,1772,1803],[1832,1788,1803],[1814,1832,1803],[1772,1814,1803],[1780,1758,1784],[1816,1780,1784],[1788,1816,1784],[1758,1788,1784],[1800,1780,1808],[1839,1800,1808],[1816,1839,1808],[1780,1816,1808],[1839,1788,1845],[1898,1839,1845],[1832,1898,1845],[1788,1832,1845],[1770,1752,1774],[1794,1770,1774],[1778,1794,1774],[1752,1778,1774],[1786,1770,1792],[1810,1786,1792],[1794,1810,1792],[1770,1794,1792],[1794,1778,1798],[1822,1794,1798],[1800,1822,1798],[1778,1800,1798],[1810,1794,1818],[1843,1810,1818],[1822,1843,1818],[1794,1822,1818],[1796,1786,1805],[1824,1796,1805],[1810,1824,1805],[1786,1810,1805],[1801,1796,1812],[1825,1801,1812],[1824,1825,1812],[1796,1824,1812],[1824,1810,1830],[1861,1824,1830],[1843,1861,1830],[1810,1843,1830],[1825,1824,1841],[1870,1825,1841],[1861,1870,1841],[1824,1861,1841],[1822,1800,1828],[1874,1822,1828],[1839,1874,1828],[1800,1839,1828],[1843,1822,1859],[1892,1843,1859],[1874,1892,1859],[1822,1874,1859],[1892,1839,1886],[1911,1892,1886],[1878,1911,1886],[1839,1878,1886],[1911,1878,1909],[1935,1911,1909],[1898,1935,1909],[1878,1898,1909],[1861,1843,1880],[1902,1861,1880],[1892,1902,1880],[1843,1892,1880],[1870,1861,1890],[1905,1870,1890],[1902,1905,1890],[1861,1902,1890],[1902,1892,1907],[1923,1902,1907],[1911,1923,1907],[1892,1911,1907],[1923,1911,1930],[1949,1923,1930],[1935,1949,1930],[1911,1935,1930],[1905,1902,1913],[1926,1905,1913],[1923,1926,1913],[1902,1923,1913],[1926,1923,1939],[1952,1926,1939],[1949,1952,1939],[1923,1949,1939],[1539,1538,1581],[1617,1539,1581],[1619,1617,1581],[1538,1619,1581],[1617,1619,1642],[1654,1617,1642],[1658,1654,1642],[1619,1658,1642],[1541,1539,1577],[1613,1541,1577],[1617,1613,1577],[1539,1617,1577],[1613,1617,1638],[1652,1613,1638],[1654,1652,1638],[1617,1654,1638],[1654,1658,1670],[1684,1654,1670],[1686,1684,1670],[1658,1686,1670],[1684,1686,1700],[1719,1684,1700],[1721,1719,1700],[1686,1721,1700],[1652,1654,1666],[1680,1652,1666],[1684,1680,1666],[1654,1684,1666],[1680,1684,1696],[1710,1680,1696],[1719,1710,1696],[1684,1719,1696],[1543,1541,1575],[1608,1543,1575],[1613,1608,1575],[1541,1613,1575],[1608,1613,1634],[1648,1608,1634],[1652,1648,1634],[1613,1652,1634],[1545,1543,1604],[1644,1545,1604],[1648,1644,1604],[1543,1648,1604],[1648,1652,1661],[1674,1648,1661],[1680,1674,1661],[1652,1680,1661],[1674,1680,1689],[1698,1674,1689],[1710,1698,1689],[1680,1710,1689],[1644,1648,1668],[1687,1644,1668],[1698,1687,1668],[1648,1698,1668],[1719,1721,1740],[1761,1719,1740],[1768,1761,1740],[1721,1768,1740],[1710,1719,1734],[1753,1710,1734],[1761,1753,1734],[1719,1761,1734],[1761,1768,1781],[1795,1761,1781],[1801,1795,1781],[1768,1801,1781],[1753,1761,1775],[1785,1753,1775],[1795,1785,1775],[1761,1795,1775],[1698,1710,1726],[1742,1698,1726],[1753,1742,1726],[1710,1753,1726],[1687,1698,1715],[1728,1687,1715],[1742,1728,1715],[1698,1742,1715],[1742,1753,1759],[1769,1742,1759],[1785,1769,1759],[1753,1785,1759],[1728,1742,1747],[1751,1728,1747],[1769,1751,1747],[1742,1769,1747],[1547,1545,1596],[1640,1547,1596],[1644,1640,1596],[1545,1644,1596],[1549,1547,1594],[1636,1549,1594],[1640,1636,1594],[1547,1640,1594],[1640,1644,1659],[1678,1640,1659],[1687,1678,1659],[1644,1687,1659],[1636,1640,1656],[1672,1636,1656],[1678,1672,1656],[1640,1678,1656],[1551,1549,1590],[1631,1551,1590],[1636,1631,1590],[1549,1636,1590],[1553,1551,1586],[1630,1553,1586],[1631,1630,1586],[1551,1631,1586],[1631,1636,1650],[1664,1631,1650],[1672,1664,1650],[1636,1672,1650],[1630,1631,1646],[1663,1630,1646],[1664,1663,1646],[1631,1664,1646],[1678,1687,1702],[1713,1678,1702],[1728,1713,1702],[1687,1728,1702],[1672,1678,1691],[1704,1672,1691],[1713,1704,1691],[1678,1713,1691],[1713,1728,1732],[1738,1713,1732],[1751,1738,1732],[1728,1751,1732],[1704,1713,1722],[1724,1704,1722],[1738,1724,1722],[1713,1738,1722],[1664,1672,1682],[1694,1664,1682],[1704,1694,1682],[1672,1704,1682],[1663,1664,1676],[1693,1663,1676],[1694,1693,1676],[1664,1694,1676],[1694,1704,1708],[1717,1694,1708],[1724,1717,1708],[1704,1724,1708],[1693,1694,1706],[1712,1693,1706],[1717,1712,1706],[1694,1717,1706],[1795,1801,1811],[1823,1795,1811],[1825,1823,1811],[1801,1825,1811],[1785,1795,1804],[1809,1785,1804],[1823,1809,1804],[1795,1823,1804],[1823,1825,1840],[1860,1823,1840],[1870,1860,1840],[1825,1870,1840],[1809,1823,1829],[1842,1809,1829],[1860,1842,1829],[1823,1860,1829],[1769,1785,1791],[1793,1769,1791],[1809,1793,1791],[1785,1809,1791],[1751,1769,1773],[1777,1751,1773],[1793,1777,1773],[1769,1793,1773],[1793,1809,1817],[1821,1793,1817],[1842,1821,1817],[1809,1842,1817],[1777,1793,1797],[1799,1777,1797],[1821,1799,1797],[1793,1821,1797],[1860,1870,1889],[1901,1860,1889],[1905,1901,1889],[1870,1905,1889],[1842,1860,1879],[1891,1842,1879],[1901,1891,1879],[1860,1901,1879],[1901,1905,1912],[1922,1901,1912],[1926,1922,1912],[1905,1926,1912],[1922,1926,1938],[1948,1922,1938],[1952,1948,1938],[1926,1952,1938],[1891,1901,1906],[1910,1891,1906],[1922,1910,1906],[1901,1922,1906],[1910,1922,1929],[1934,1910,1929],[1948,1934,1929],[1922,1948,1929],[1821,1842,1858],[1873,1821,1858],[1891,1873,1858],[1842,1891,1858],[1799,1821,1827],[1838,1799,1827],[1873,1838,1827],[1821,1873,1827],[1838,1891,1885],[1877,1838,1885],[1910,1877,1885],[1891,1910,1885],[1877,1910,1908],[1895,1877,1908],[1934,1895,1908],[1910,1934,1908],[1738,1751,1764],[1779,1738,1764],[1799,1779,1764],[1751,1799,1764],[1724,1738,1749],[1757,1724,1749],[1779,1757,1749],[1738,1779,1749],[1717,1724,1736],[1745,1717,1736],[1757,1745,1736],[1724,1757,1736],[1712,1717,1730],[1744,1712,1730],[1745,1744,1730],[1717,1745,1730],[1779,1799,1807],[1815,1779,1807],[1838,1815,1807],[1799,1838,1807],[1757,1779,1783],[1787,1757,1783],[1815,1787,1783],[1779,1815,1783],[1787,1838,1844],[1831,1787,1844],[1895,1831,1844],[1838,1895,1844],[1745,1757,1766],[1771,1745,1766],[1787,1771,1766],[1757,1787,1766],[1744,1745,1755],[1763,1744,1755],[1771,1763,1755],[1745,1771,1755],[1771,1787,1802],[1813,1771,1802],[1831,1813,1802],[1787,1831,1802],[1763,1771,1789],[1806,1763,1789],[1813,1806,1789],[1771,1813,1789],[1814,1806,1820],[1836,1814,1820],[1826,1836,1820],[1806,1826,1820],[1832,1814,1834],[1872,1832,1834],[1836,1872,1834],[1814,1836,1834],[1898,1832,1888],[1915,1898,1888],[1872,1915,1888],[1832,1872,1888],[1836,1826,1847],[1857,1836,1847],[1850,1857,1847],[1826,1850,1847],[1872,1836,1863],[1882,1872,1863],[1857,1882,1863],[1836,1857,1863],[1915,1872,1900],[1919,1915,1900],[1882,1919,1900],[1872,1882,1900],[1935,1898,1928],[1954,1935,1928],[1915,1954,1928],[1898,1915,1928],[1949,1935,1951],[1969,1949,1951],[1954,1969,1951],[1935,1954,1951],[1952,1949,1962],[1974,1952,1962],[1969,1974,1962],[1949,1969,1962],[1954,1915,1941],[1958,1954,1941],[1919,1958,1941],[1915,1919,1941],[1969,1954,1965],[1971,1969,1965],[1958,1971,1965],[1954,1958,1965],[1974,1969,1973],[1975,1974,1973],[1971,1975,1973],[1969,1971,1973],[1857,1850,1855],[1867,1857,1855],[1853,1867,1855],[1850,1853,1855],[1882,1857,1876],[1884,1882,1876],[1867,1884,1876],[1857,1867,1876],[1919,1882,1904],[1917,1919,1904],[1884,1917,1904],[1882,1884,1904],[1867,1853,1852],[1849,1867,1852],[1837,1849,1852],[1853,1837,1852],[1884,1867,1869],[1865,1884,1869],[1849,1865,1869],[1867,1849,1869],[1917,1884,1894],[1897,1917,1894],[1865,1897,1894],[1884,1865,1894],[1958,1919,1937],[1947,1958,1937],[1917,1947,1937],[1919,1917,1937],[1971,1958,1960],[1956,1971,1960],[1947,1956,1960],[1958,1947,1960],[1975,1971,1967],[1963,1975,1967],[1956,1963,1967],[1971,1956,1967],[1947,1917,1921],[1925,1947,1921],[1897,1925,1921],[1917,1897,1921],[1956,1947,1943],[1932,1956,1943],[1925,1932,1943],[1947,1925,1943],[1963,1956,1945],[1933,1963,1945],[1932,1933,1945],[1956,1932,1945],[1948,1952,1961],[1968,1948,1961],[1974,1968,1961],[1952,1974,1961],[1934,1948,1950],[1953,1934,1950],[1968,1953,1950],[1948,1968,1950],[1895,1934,1927],[1914,1895,1927],[1953,1914,1927],[1934,1953,1927],[1968,1974,1972],[1970,1968,1972],[1975,1970,1972],[1974,1975,1972],[1953,1968,1964],[1957,1953,1964],[1970,1957,1964],[1968,1970,1964],[1914,1953,1940],[1918,1914,1940],[1957,1918,1940],[1953,1957,1940],[1831,1895,1887],[1871,1831,1887],[1914,1871,1887],[1895,1914,1887],[1813,1831,1833],[1835,1813,1833],[1871,1835,1833],[1831,1871,1833],[1806,1813,1819],[1826,1806,1819],[1835,1826,1819],[1813,1835,1819],[1871,1914,1899],[1881,1871,1899],[1918,1881,1899],[1914,1918,1899],[1835,1871,1862],[1856,1835,1862],[1881,1856,1862],[1871,1881,1862],[1826,1835,1846],[1850,1826,1846],[1856,1850,1846],[1835,1856,1846],[1970,1975,1966],[1955,1970,1966],[1963,1955,1966],[1975,1963,1966],[1957,1970,1959],[1946,1957,1959],[1955,1946,1959],[1970,1955,1959],[1918,1957,1936],[1916,1918,1936],[1946,1916,1936],[1957,1946,1936],[1955,1963,1944],[1931,1955,1944],[1933,1931,1944],[1963,1933,1944],[1946,1955,1942],[1924,1946,1942],[1931,1924,1942],[1955,1931,1942],[1916,1946,1920],[1896,1916,1920],[1924,1896,1920],[1946,1924,1920],[1881,1918,1903],[1883,1881,1903],[1916,1883,1903],[1918,1916,1903],[1856,1881,1875],[1866,1856,1875],[1883,1866,1875],[1881,1883,1875],[1850,1856,1854],[1853,1850,1854],[1866,1853,1854],[1856,1866,1854],[1883,1916,1893],[1864,1883,1893],[1896,1864,1893],[1916,1896,1893],[1866,1883,1868],[1848,1866,1868],[1864,1848,1868],[1883,1864,1868],[1853,1866,1851],[1837,1853,1851],[1848,1837,1851],[1866,1848,1851],[1069,952,992],[1072,1069,992],[952,1072,992],[1069,1072,1094],[1118,1069,1094],[1134,1118,1094],[1072,1134,1094],[1030,952,984],[1069,1030,984],[952,1069,984],[1030,1069,1076],[1080,1030,1076],[1118,1080,1076],[1069,1118,1076],[1118,1134,1133],[1131,1118,1133],[1139,1131,1133],[1134,1139,1133],[1131,1139,1129],[1110,1131,1129],[1127,1110,1129],[1139,1127,1129],[1080,1118,1104],[1088,1080,1104],[1131,1088,1104],[1118,1131,1104],[1088,1131,1096],[1074,1088,1096],[1110,1074,1096],[1131,1110,1096],[980,952,964],[1030,980,964],[952,1030,964],[980,1030,1028],[1002,980,1028],[1080,1002,1028],[1030,1080,1028],[951,952,954],[980,951,954],[952,980,954],[951,980,962],[949,951,962],[1002,949,962],[980,1002,962],[1002,1080,1059],[1012,1002,1059],[1088,1012,1059],[1080,1088,1059],[1012,1088,1053],[998,1012,1053],[1074,998,1053],[1088,1074,1053],[949,1002,974],[947,949,974],[1012,947,974],[1002,1012,974],[947,1012,972],[945,947,972],[998,945,972],[1012,998,972],[1110,1127,1082],[1047,1110,1082],[1060,1047,1082],[1127,1060,1082],[1074,1110,1071],[1004,1074,1071],[1047,1004,1071],[1110,1047,1071],[1047,1060,1039],[1024,1047,1039],[1031,1024,1039],[1060,1031,1039],[1024,1031,1041],[1049,1024,1041],[1063,1049,1041],[1031,1063,1041],[1004,1047,1018],[994,1004,1018],[1024,994,1018],[1047,1024,1018],[994,1024,1020],[1010,994,1020],[1049,1010,1020],[1024,1049,1020],[998,1074,1014],[976,998,1014],[1004,976,1014],[1074,1004,1014],[945,998,960],[943,945,960],[976,943,960],[998,976,960],[976,1004,986],[970,976,986],[994,970,986],[1004,994,986],[970,994,990],[978,970,990],[1010,978,990],[994,1010,990],[943,976,956],[941,943,956],[970,941,956],[976,970,956],[941,970,958],[939,941,958],[978,939,958],[970,978,958],[875,952,901],[951,875,901],[952,951,901],[875,951,893],[853,875,893],[949,853,893],[951,949,893],[825,952,891],[875,825,891],[952,875,891],[825,875,827],[775,825,827],[853,775,827],[875,853,827],[853,949,881],[843,853,881],[947,843,881],[949,947,881],[843,947,883],[857,843,883],[945,857,883],[947,945,883],[775,853,796],[767,775,796],[843,767,796],[853,843,796],[767,843,802],[781,767,802],[857,781,802],[843,857,802],[786,952,871],[825,786,871],[952,825,871],[786,825,779],[737,786,779],[775,737,779],[825,775,779],[782,952,863],[786,782,863],[952,786,863],[782,786,761],[720,782,761],[737,720,761],[786,737,761],[737,775,751],[724,737,751],[767,724,751],[775,767,751],[724,767,759],[745,724,759],[781,745,759],[767,781,759],[720,737,722],[715,720,722],[724,715,722],[737,724,722],[715,724,726],[727,715,726],[745,727,726],[724,745,726],[857,945,895],[879,857,895],[943,879,895],[945,943,895],[781,857,841],[851,781,841],[879,851,841],[857,879,841],[879,943,899],[885,879,899],[941,885,899],[943,941,899],[885,941,897],[877,885,897],[939,877,897],[941,939,897],[851,879,869],[861,851,869],[885,861,869],[879,885,869],[861,885,865],[845,861,865],[877,845,865],[885,877,865],[745,781,784],[808,745,784],[851,808,784],[781,851,784],[727,745,773],[794,727,773],[808,794,773],[745,808,773],[808,851,837],[831,808,837],[861,831,837],[851,861,837],[831,861,835],[806,831,835],[845,806,835],[861,845,835],[794,808,816],[823,794,816],[831,823,816],[808,831,816],[823,831,814],[791,823,814],[806,791,814],[831,806,814],[785,952,862],[782,785,862],[952,782,862],[785,782,760],[736,785,760],[720,736,760],[782,720,760],[824,952,870],[785,824,870],[952,785,870],[824,785,778],[774,824,778],[736,774,778],[785,736,778],[736,720,721],[723,736,721],[715,723,721],[720,715,721],[723,715,725],[744,723,725],[727,744,725],[715,727,725],[774,736,750],[766,774,750],[723,766,750],[736,723,750],[766,723,758],[780,766,758],[744,780,758],[723,744,758],[874,952,890],[824,874,890],[952,824,890],[874,824,826],[852,874,826],[774,852,826],[824,774,826],[950,952,900],[874,950,900],[952,874,900],[950,874,892],[948,950,892],[852,948,892],[874,852,892],[852,774,795],[842,852,795],[766,842,795],[774,766,795],[842,766,801],[856,842,801],[780,856,801],[766,780,801],[948,852,880],[946,948,880],[842,946,880],[852,842,880],[946,842,882],[944,946,882],[856,944,882],[842,856,882],[744,727,772],[807,744,772],[794,807,772],[727,794,772],[780,744,783],[850,780,783],[807,850,783],[744,807,783],[807,794,815],[830,807,815],[823,830,815],[794,823,815],[830,823,813],[805,830,813],[791,805,813],[823,791,813],[850,807,836],[860,850,836],[830,860,836],[807,830,836],[860,830,834],[844,860,834],[805,844,834],[830,805,834],[856,780,840],[878,856,840],[850,878,840],[780,850,840],[944,856,894],[942,944,894],[878,942,894],[856,878,894],[878,850,868],[884,878,868],[860,884,868],[850,860,868],[884,860,864],[876,884,864],[844,876,864],[860,844,864],[942,878,898],[940,942,898],[884,940,898],[878,884,898],[940,884,896],[938,940,896],[876,938,896],[884,876,896],[979,952,953],[950,979,953],[952,950,953],[979,950,961],[1001,979,961],[948,1001,961],[950,948,961],[1029,952,963],[979,1029,963],[952,979,963],[1029,979,1027],[1079,1029,1027],[1001,1079,1027],[979,1001,1027],[1001,948,973],[1011,1001,973],[946,1011,973],[948,946,973],[1011,946,971],[997,1011,971],[944,997,971],[946,944,971],[1079,1001,1058],[1087,1079,1058],[1011,1087,1058],[1001,1011,1058],[1087,1011,1052],[1073,1087,1052],[997,1073,1052],[1011,997,1052],[1068,952,983],[1029,1068,983],[952,1029,983],[1068,1029,1075],[1117,1068,1075],[1079,1117,1075],[1029,1079,1075],[1072,952,991],[1068,1072,991],[952,1068,991],[1072,1068,1093],[1134,1072,1093],[1117,1134,1093],[1068,1117,1093],[1117,1079,1103],[1130,1117,1103],[1087,1130,1103],[1079,1087,1103],[1130,1087,1095],[1109,1130,1095],[1073,1109,1095],[1087,1073,1095],[1134,1117,1132],[1139,1134,1132],[1130,1139,1132],[1117,1130,1132],[1139,1130,1128],[1127,1139,1128],[1109,1127,1128],[1130,1109,1128],[997,944,959],[975,997,959],[942,975,959],[944,942,959],[1073,997,1013],[1003,1073,1013],[975,1003,1013],[997,975,1013],[975,942,955],[969,975,955],[940,969,955],[942,940,955],[969,940,957],[977,969,957],[938,977,957],[940,938,957],[1003,975,985],[993,1003,985],[969,993,985],[975,969,985],[993,969,989],[1009,993,989],[977,1009,989],[969,977,989],[1109,1073,1070],[1046,1109,1070],[1003,1046,1070],[1073,1003,1070],[1127,1109,1081],[1060,1127,1081],[1046,1060,1081],[1109,1046,1081],[1046,1003,1017],[1023,1046,1017],[993,1023,1017],[1003,993,1017],[1023,993,1019],[1048,1023,1019],[1009,1048,1019],[993,1009,1019],[1060,1046,1038],[1031,1060,1038],[1023,1031,1038],[1046,1023,1038],[1031,1023,1040],[1063,1031,1040],[1048,1063,1040],[1023,1048,1040],[1049,1063,1120],[1161,1049,1120],[1170,1161,1120],[1063,1170,1120],[1010,1049,1092],[1126,1010,1092],[1161,1126,1092],[1049,1161,1092],[1165,1170,1224],[1272,1165,1224],[1279,1272,1224],[1170,1279,1224],[1161,1165,1216],[1250,1161,1216],[1272,1250,1216],[1165,1272,1216],[1141,1161,1196],[1234,1141,1196],[1250,1234,1196],[1161,1250,1196],[1126,1141,1178],[1206,1126,1178],[1234,1206,1178],[1141,1234,1178],[978,1010,1045],[1043,978,1045],[1126,1043,1045],[1010,1126,1045],[939,978,966],[937,939,966],[1043,937,966],[978,1043,966],[1084,1126,1153],[1174,1084,1153],[1206,1174,1153],[1126,1206,1153],[1043,1084,1112],[1124,1043,1112],[1174,1124,1112],[1084,1174,1112],[982,1043,1055],[1033,982,1055],[1124,1033,1055],[1043,1124,1055],[937,982,968],[935,937,968],[1033,935,968],[982,1033,968],[1272,1279,1321],[1369,1272,1321],[1376,1369,1321],[1279,1376,1321],[1250,1272,1309],[1347,1250,1309],[1369,1347,1309],[1272,1369,1309],[1234,1250,1285],[1315,1234,1285],[1347,1315,1285],[1250,1347,1285],[1206,1234,1252],[1278,1206,1252],[1315,1278,1252],[1234,1315,1252],[1369,1376,1388],[1402,1369,1388],[1415,1402,1388],[1376,1415,1388],[1347,1369,1375],[1378,1347,1375],[1402,1378,1375],[1369,1402,1375],[1402,1415,1419],[1423,1402,1419],[1434,1423,1419],[1415,1434,1419],[1378,1402,1396],[1390,1378,1396],[1423,1390,1396],[1402,1423,1396],[1315,1347,1339],[1335,1315,1339],[1378,1335,1339],[1347,1378,1339],[1278,1315,1305],[1295,1278,1305],[1335,1295,1305],[1315,1335,1305],[1335,1378,1365],[1353,1335,1365],[1390,1353,1365],[1378,1390,1365],[1295,1335,1325],[1301,1295,1325],[1353,1301,1325],[1335,1353,1325],[1174,1206,1222],[1226,1174,1222],[1278,1226,1222],[1206,1278,1222],[1124,1174,1176],[1169,1124,1176],[1226,1169,1176],[1174,1226,1176],[1033,1124,1108],[1078,1033,1108],[1169,1078,1108],[1124,1169,1108],[935,1033,988],[931,935,988],[1078,931,988],[1033,1078,988],[1226,1278,1256],[1240,1226,1256],[1295,1240,1256],[1278,1295,1256],[1169,1226,1202],[1180,1169,1202],[1240,1180,1202],[1226,1240,1202],[1240,1295,1274],[1244,1240,1274],[1301,1244,1274],[1295,1301,1274],[1180,1240,1218],[1186,1180,1218],[1244,1186,1218],[1240,1244,1218],[1078,1169,1138],[1086,1078,1138],[1180,1086,1138],[1169,1180,1138],[931,1078,996],[925,931,996],[1086,925,996],[1078,1086,996],[1086,1180,1145],[1090,1086,1145],[1186,1090,1145],[1180,1186,1145],[925,1086,1000],[921,925,1000],[1090,921,1000],[1086,1090,1000],[877,939,889],[812,877,889],[937,812,889],[939,937,889],[845,877,810],[729,845,810],[812,729,810],[877,812,810],[873,937,887],[822,873,887],[935,822,887],[937,935,887],[812,873,800],[731,812,800],[822,731,800],[873,822,800],[771,812,743],[681,771,743],[731,681,743],[812,731,743],[729,771,702],[649,729,702],[681,649,702],[771,681,702],[806,845,763],[694,806,763],[729,694,763],[845,729,763],[791,806,735],[684,791,735],[694,684,735],[806,694,735],[714,729,677],[621,714,677],[649,621,677],[729,649,677],[694,714,659],[605,694,659],[621,605,659],[714,621,659],[690,694,639],[583,690,639],[605,583,639],[694,605,639],[684,690,631],[575,684,631],[583,575,631],[690,583,631],[822,935,867],[777,822,867],[931,777,867],[935,931,867],[731,822,747],[686,731,747],[777,686,747],[822,777,747],[681,731,679],[629,681,679],[686,629,679],[731,686,679],[649,681,633],[577,649,633],[629,577,633],[681,629,633],[777,931,859],[769,777,859],[925,769,859],[931,925,859],[686,777,717],[675,686,717],[769,675,717],[777,769,717],[769,925,855],[765,769,855],[921,765,855],[925,921,855],[675,769,710],[669,675,710],[765,669,710],[769,765,710],[629,686,653],[615,629,653],[675,615,653],[686,675,653],[577,629,599],[560,577,599],[615,560,599],[629,615,599],[615,675,637],[611,615,637],[669,611,637],[675,669,637],[560,615,581],[554,560,581],[611,554,581],[615,611,581],[621,649,603],[540,621,603],[577,540,603],[649,577,603],[605,621,570],[508,605,570],[540,508,570],[621,540,570],[583,605,546],[486,583,546],[508,486,546],[605,508,546],[575,583,534],[478,575,534],[486,478,534],[583,486,534],[540,577,550],[520,540,550],[560,520,550],[577,560,550],[508,540,516],[477,508,516],[520,477,516],[540,520,516],[520,560,530],[502,520,530],[554,502,530],[560,554,530],[477,520,490],[465,477,490],[502,465,490],[520,502,490],[486,508,480],[453,486,480],[477,453,480],[508,477,480],[478,486,467],[439,478,467],[453,439,467],[486,453,467],[453,477,459],[432,453,459],[465,432,459],[477,465,459],[439,453,436],[420,439,436],[432,420,436],[453,432,436],[805,791,734],[693,805,734],[684,693,734],[791,684,734],[844,805,762],[728,844,762],[693,728,762],[805,693,762],[689,684,630],[582,689,630],[575,582,630],[684,575,630],[693,689,638],[604,693,638],[582,604,638],[689,582,638],[713,693,658],[620,713,658],[604,620,658],[693,604,658],[728,713,676],[648,728,676],[620,648,676],[713,620,676],[876,844,809],[811,876,809],[728,811,809],[844,728,809],[938,876,888],[936,938,888],[811,936,888],[876,811,888],[770,728,701],[680,770,701],[648,680,701],[728,648,701],[811,770,742],[730,811,742],[680,730,742],[770,680,742],[872,811,799],[821,872,799],[730,821,799],[811,730,799],[936,872,886],[934,936,886],[821,934,886],[872,821,886],[582,575,533],[485,582,533],[478,485,533],[575,478,533],[604,582,545],[507,604,545],[485,507,545],[582,485,545],[620,604,569],[539,620,569],[507,539,569],[604,507,569],[648,620,602],[576,648,602],[539,576,602],[620,539,602],[485,478,466],[452,485,466],[439,452,466],[478,439,466],[507,485,479],[476,507,479],[452,476,479],[485,452,479],[452,439,435],[431,452,435],[420,431,435],[439,420,435],[476,452,458],[464,476,458],[431,464,458],[452,431,458],[539,507,515],[519,539,515],[476,519,515],[507,476,515],[576,539,549],[559,576,549],[519,559,549],[539,519,549],[519,476,489],[501,519,489],[464,501,489],[476,464,489],[559,519,529],[553,559,529],[501,553,529],[519,501,529],[680,648,632],[628,680,632],[576,628,632],[648,576,632],[730,680,678],[685,730,678],[628,685,678],[680,628,678],[821,730,746],[776,821,746],[685,776,746],[730,685,746],[934,821,866],[930,934,866],[776,930,866],[821,776,866],[628,576,598],[614,628,598],[559,614,598],[576,559,598],[685,628,652],[674,685,652],[614,674,652],[628,614,652],[614,559,580],[610,614,580],[553,610,580],[559,553,580],[674,614,636],[668,674,636],[610,668,636],[614,610,636],[776,685,716],[768,776,716],[674,768,716],[685,674,716],[930,776,858],[924,930,858],[768,924,858],[776,768,858],[768,674,709],[764,768,709],[668,764,709],[674,668,709],[924,768,854],[920,924,854],[764,920,854],[768,764,854],[977,938,965],[1042,977,965],[936,1042,965],[938,936,965],[1009,977,1044],[1125,1009,1044],[1042,1125,1044],[977,1042,1044],[981,936,967],[1032,981,967],[934,1032,967],[936,934,967],[1042,981,1054],[1123,1042,1054],[1032,1123,1054],[981,1032,1054],[1083,1042,1111],[1173,1083,1111],[1123,1173,1111],[1042,1123,1111],[1125,1083,1152],[1205,1125,1152],[1173,1205,1152],[1083,1173,1152],[1048,1009,1091],[1160,1048,1091],[1125,1160,1091],[1009,1125,1091],[1063,1048,1119],[1170,1063,1119],[1160,1170,1119],[1048,1160,1119],[1140,1125,1177],[1233,1140,1177],[1205,1233,1177],[1125,1205,1177],[1160,1140,1195],[1249,1160,1195],[1233,1249,1195],[1140,1233,1195],[1164,1160,1215],[1271,1164,1215],[1249,1271,1215],[1160,1249,1215],[1170,1164,1223],[1279,1170,1223],[1271,1279,1223],[1164,1271,1223],[1032,934,987],[1077,1032,987],[930,1077,987],[934,930,987],[1123,1032,1107],[1168,1123,1107],[1077,1168,1107],[1032,1077,1107],[1173,1123,1175],[1225,1173,1175],[1168,1225,1175],[1123,1168,1175],[1205,1173,1221],[1277,1205,1221],[1225,1277,1221],[1173,1225,1221],[1077,930,995],[1085,1077,995],[924,1085,995],[930,924,995],[1168,1077,1137],[1179,1168,1137],[1085,1179,1137],[1077,1085,1137],[1085,924,999],[1089,1085,999],[920,1089,999],[924,920,999],[1179,1085,1144],[1185,1179,1144],[1089,1185,1144],[1085,1089,1144],[1225,1168,1201],[1239,1225,1201],[1179,1239,1201],[1168,1179,1201],[1277,1225,1255],[1294,1277,1255],[1239,1294,1255],[1225,1239,1255],[1239,1179,1217],[1243,1239,1217],[1185,1243,1217],[1179,1185,1217],[1294,1239,1273],[1300,1294,1273],[1243,1300,1273],[1239,1243,1273],[1233,1205,1251],[1314,1233,1251],[1277,1314,1251],[1205,1277,1251],[1249,1233,1284],[1346,1249,1284],[1314,1346,1284],[1233,1314,1284],[1271,1249,1308],[1368,1271,1308],[1346,1368,1308],[1249,1346,1308],[1279,1271,1320],[1376,1279,1320],[1368,1376,1320],[1271,1368,1320],[1314,1277,1304],[1334,1314,1304],[1294,1334,1304],[1277,1294,1304],[1346,1314,1338],[1377,1346,1338],[1334,1377,1338],[1314,1334,1338],[1334,1294,1324],[1352,1334,1324],[1300,1352,1324],[1294,1300,1324],[1377,1334,1364],[1389,1377,1364],[1352,1389,1364],[1334,1352,1364],[1368,1346,1374],[1401,1368,1374],[1377,1401,1374],[1346,1377,1374],[1376,1368,1387],[1415,1376,1387],[1401,1415,1387],[1368,1401,1387],[1401,1377,1395],[1422,1401,1395],[1389,1422,1395],[1377,1389,1395],[1415,1401,1418],[1434,1415,1418],[1422,1434,1418],[1401,1422,1418]];
var calculateNormals=function(positions,indices){var nvecs=new Array(positions.length);for(var i=0;i<indices.length;i++){var j0=indices[i][0];var j1=indices[i][1];var j2=indices[i][2];var v1=positions[j0];var v2=positions[j1];var v3=positions[j2];v2=SceneJS._math_subVec4(v2,v1,[0,0,0,0]);v3=SceneJS._math_subVec4(v3,v1,[0,0,0,0]);
var n=SceneJS._math_normalizeVec4(SceneJS._math_cross3Vec4(v2,v3,[0,0,0,0]),[0,0,0,0]);if(!nvecs[j0]){nvecs[j0]=[];}if(!nvecs[j1]){nvecs[j1]=[];}if(!nvecs[j2]){nvecs[j2]=[];}nvecs[j0].push(n);nvecs[j1].push(n);nvecs[j2].push(n);}var normals=new Array(positions.length);for(var i=0;i<nvecs.length;i++){var count=nvecs[i].length;
var x=0;var y=0;var z=0;for(var j=0;j<count;j++){x+=nvecs[i][j][0];y+=nvecs[i][j][1];z+=nvecs[i][j][2];}normals[i]=[x/count,y/count,z/count];}return normals;};var flatten=function(ar,numPerElement){var result=[];for(var i=0;i<ar.length;i++){if(numPerElement&&ar[i].length!=numPerElement){throw new SceneJS.errors.InvalidNodeConfigException("Bad geometry array element");
}for(var j=0;j<ar[i].length;j++){result.push(ar[i][j]);}}return result;};return{primitive:"triangles",positions:flatten(positions,3),indices:flatten(indices,3),normals:flatten(calculateNormals(positions,indices),3)};};};SceneJS._inherit(SceneJS.Teapot,SceneJS.Geometry);SceneJS.teapot=function(){return new SceneJS.Teapot();
};SceneJS._registerNode("teapot",SceneJS.Teapot,SceneJS.teapot);SceneJS._namespace("SceneJS.objects");SceneJS.Box=SceneJS.createNodeType("box","geometry");SceneJS.Box.prototype._init=function(params){this._attr.nodeType="box";var x=params.xSize||1;var y=params.ySize||1;var z=params.zSize||1;var solid=(params.solid!=undefined)?params.solid:true;
this._resource="box_"+x+"_"+y+"_"+z+(solid?"_solid":"wire");this._create=function(){var positions=[x,y,z,-x,y,z,-x,-y,z,x,-y,z,x,y,z,x,-y,z,x,-y,-z,x,y,-z,x,y,z,x,y,-z,-x,y,-z,-x,y,z,-x,y,z,-x,y,-z,-x,-y,-z,-x,-y,z,-x,-y,-z,x,-y,-z,x,-y,z,-x,-y,z,x,-y,-z,-x,-y,-z,-x,y,-z,x,y,-z];var normals=[0,0,-1,0,0,-1,0,0,-1,0,0,-1,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1];
var uv=[x,y,0,y,0,0,x,0,0,y,0,0,x,0,x,y,x,0,x,y,0,y,0,0,x,y,0,y,0,0,x,0,0,0,x,0,x,y,0,y,0,0,x,0,x,y,0,y];var indices=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23];return{primitive:solid?"triangles":"lines",positions:positions,normals:normals,uv:uv,indices:indices,colors:[]};
};};SceneJS.Box=SceneJS.createNodeType("cube","box");SceneJS.Sphere=SceneJS.createNodeType("sphere","geometry");SceneJS.Sphere.prototype._init=function(params){var slices=params.slices||30;var rings=params.rings||30;var radius=params.radius||1;this._resource="sphere_"+radius+"_"+rings+"_"+slices;this._create=function(){var positions=[];
var normals=[];var uv=[];for(var sliceNum=0;sliceNum<=slices;sliceNum++){var theta=sliceNum*Math.PI/slices;var sinTheta=Math.sin(theta);var cosTheta=Math.cos(theta);for(var ringNum=0;ringNum<=rings;ringNum++){var phi=ringNum*2*Math.PI/rings;var sinPhi=Math.sin(phi);var cosPhi=Math.cos(phi);var x=cosPhi*sinTheta;
var y=cosTheta;var z=sinPhi*sinTheta;var u=1-(ringNum/rings);var v=sliceNum/slices;normals.push(-x);normals.push(-y);normals.push(-z);uv.push(u);uv.push(v);positions.push(radius*x);positions.push(radius*y);positions.push(radius*z);}}var indices=[];for(var sliceNum=0;sliceNum<slices;sliceNum++){for(var ringNum=0;
ringNum<rings;ringNum++){var first=(sliceNum*(rings+1))+ringNum;var second=first+rings+1;indices.push(first);indices.push(second);indices.push(first+1);indices.push(second);indices.push(second+1);indices.push(first+1);}}return{primitive:"triangles",positions:positions,normals:normals,uv:uv,indices:indices};
};};SceneJS._namespace("SceneJS.objects");SceneJS.Quad=SceneJS.createNodeType("quad","geometry");SceneJS.Quad.prototype._init=function(params){this._attr.nodeType="quad";var x=params.xSize||1;var y=params.ySize||1;var solid=(params.solid!=undefined)?params.solid:true;this._resource="quad_"+x+"_"+y+(solid?"_solid":"_wire");
this._create=function(){var positions=[x,y,0,-x,y,0,-x,-y,0,x,-y,0];var normals=[0,0,-1,0,0,-1,0,0,-1,0,0,-1];var uv=[1,1,0,1,0,0,1,0];var indices=[0,1,2,0,2,3];return{primitive:solid?"triangles":"lines",positions:positions,normals:normals,uv:uv,indices:indices,colors:[]};};};SceneJS._vectorTextModule=new (function(){var letters={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},"$":{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},"0":{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},"1":{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},"2":{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},"3":{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"4":{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},"5":{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},"6":{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},"7":{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},"8":{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},"9":{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},",":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},"A":{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},"B":{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},"C":{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},"D":{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},"E":{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},"F":{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},"G":{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},"H":{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},"I":{width:8,points:[[4,21],[4,0]]},"J":{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},"K":{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},"L":{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},"M":{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},"N":{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},"O":{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},"P":{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},"Q":{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},"R":{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},"S":{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"T":{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},"U":{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},"V":{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},"W":{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},"X":{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},"Y":{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},"Z":{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},"_":{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},"a":{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"b":{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},"c":{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"d":{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"e":{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"f":{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},"g":{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"h":{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},"i":{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},"j":{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},"k":{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},"l":{width:8,points:[[4,21],[4,0]]},"m":{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},"n":{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},"o":{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},"p":{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},"q":{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},"r":{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},"s":{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},"t":{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},"u":{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},"v":{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},"w":{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},"x":{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},"y":{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},"z":{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};
function letter(ch){return letters[ch];}function ascent(font,size){return size;}function descent(font,size){return 7*size/25;}function measure(font,size,str){var total=0;var len=str.length;for(var i=0;i<len;i++){var c=letter(str.charAt(i));if(c){total+=c.width*size/25;}}return total;}this.getGeometry=function(size,xPos,yPos,text){var geo={positions:[],indices:[]};
var lines=text.split("\n");var countVerts=0;var y=yPos;for(var iLine=0;iLine<lines.length;iLine++){var x=xPos;var str=lines[iLine];var len=str.length;var mag=size/25;for(var i=0;i<len;i++){var c=letter(str.charAt(i));if(c=="\n"){alert("newline");}if(!c){continue;}var penUp=1;var p1=-1;var p2=-1;var needLine=false;
for(var j=0;j<c.points.length;j++){var a=c.points[j];if(a[0]==-1&&a[1]==-1){penUp=1;needLine=false;continue;}geo.positions.push(x+a[0]*mag);geo.positions.push(y+a[1]*mag);geo.positions.push(0);if(p1==-1){p1=countVerts;}else{if(p2==-1){p2=countVerts;}else{p1=p2;p2=countVerts;}}countVerts++;if(penUp){penUp=false;
}else{geo.indices.push(p1);geo.indices.push(p2);}needLine=true;}x+=c.width*mag;}y+=25*mag;}return geo;};})();SceneJS._bitmapTextModule=new (function(){SceneJS._eventModule.addListener(SceneJS._eventModule.INIT,function(){});function getHMTLColor(color){if(color.length!=4){return color;}for(var i=0;i<color.length;
i++){color[i]*=255;}return"rgba("+color.join(",")+")";}this.createText=function(font,size,text){var canvas=document.createElement("canvas");var cx=canvas.getContext("2d");cx.font=size+"px "+font;var width=cx.measureText(text).width;canvas.width=width;canvas.height=size;cx.font=size+"px "+font;cx.textBaseline="middle";
cx.fillStyle=getHMTLColor([0.5,10,30,0.5]);cx.fillStyle="#FFFF00";var x=0;var y=(size/2);cx.fillText(text,x,y);return{image:canvas,width:canvas.width,height:canvas.height};};})();SceneJS.Text=SceneJS.createNodeType("text");SceneJS.Text.prototype._init=function(params){var mode=params.mode||"bitmap";if(mode!="vector"&&mode!="bitmap"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Text unsupported mode - should be 'vector' or 'bitmap'"));
}this._mode=mode;if(this._mode=="bitmap"){var text=SceneJS._bitmapTextModule.createText("Helvetica",params.size||1,params.text||"");this._layer={creationParams:{image:text.image,minFilter:"linear",magFilter:"linear",isDepth:false,depthMode:"luminance",depthCompareMode:"compareRToTexture",depthCompareFunc:"lequal",flipY:false,width:1,height:1,internalFormat:"lequal",sourceFormat:"alpha",sourceType:"unsignedByte",applyTo:"baseColor",blendMode:"add"},texture:null,applyFrom:"uv",applyTo:"baseColor",blendMode:"add",scale:null,translate:null,rotate:null,rebuildMatrix:true};
var w=text.width/16;var h=text.height/16;var positions=[w,h,0.01,0,h,0.1,0,0,0.1,w,0,0.01];var normals=[0,0,-1,0,0,-1,0,0,-1,0,0,-1];var uv=[1,1,0,1,0,0,1,0];var indices=[0,1,2,0,2,3];if(params.doubleSided){var z=0.01;positions=positions.concat([w,0,-z,0,0,-z,0,h,-z,w,h,-z]);normals=normals.concat([0,0,1,0,0,1,0,0,1,0,0,1]);
uv=uv.concat([0,0,1,0,1,1,0,1]);indices=indices.concat([4,5,6,4,6,7]);}this.addNode({type:"material",emit:0,baseColor:{r:0,g:0,b:0},specularColor:{r:0.9,g:0.9,b:0.9},specular:0.9,shine:100,nodes:[{type:"geometry",primitive:"triangles",positions:positions,normals:normals,uv:uv,indices:indices}]});}else{this.addNode({type:"geometry",create:function(){var geo=SceneJS._vectorTextModule.getGeometry(3,0,0,params.text);
return{resource:this._attr.id,primitive:"lines",positions:geo.positions,normals:[],uv:[],indices:geo.indices,colors:[]};}});}};SceneJS.Text.prototype._render=function(traversalContext){if(this._mode=="bitmap"){if(!this._layer.texture&&!this._error){var self=this;(function(){SceneJS._textureModule.createTexture(self._layer.creationParams,function(texture){self._layer.texture=texture;
},function(){self._error=true;var message="SceneJS.text texture creation failed";SceneJS._loggingModule.warn(message);},function(){self._error=true;var message="SceneJS.text texture creation failed";SceneJS._loggingModule.warn(message);});})();}if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);
}else{if(this._layer){SceneJS._textureModule.pushTexture([this._layer]);this._renderNodes(traversalContext);SceneJS._textureModule.popTexture();}}}else{this._renderNodes(traversalContext);}};SceneJS._viewTransformModule=new (function(){var transform;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){transform={matrix:SceneJS._math_identityMat4(),fixed:true};
dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){if(!transform.matrixAsArray){transform.matrixAsArray=new Float32Array(transform.matrix);}if(!transform.normalMatrixAsArray){transform.normalMatrixAsArray=new Float32Array(SceneJS._math_transposeMat4(SceneJS._math_inverseMat4(transform.matrix,SceneJS._math_mat4())));
}SceneJS._shaderModule.addViewMatrices(transform.matrixAsArray,transform.normalMatrixAsArray);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.setTransform=function(t){transform=t;dirty=true;SceneJS._eventModule.fireEvent(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,transform);
};this.getTransform=function(){return transform;};})();SceneJS._modelTransformModule=new (function(){var transform;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){transform={matrix:SceneJS._math_identityMat4(),fixed:true,identity:true};dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){if(!transform.matrixAsArray){transform.matrixAsArray=new Float32Array(transform.matrix);}if(!transform.normalMatrixAsArray){transform.normalMatrixAsArray=new Float32Array(SceneJS._math_transposeMat4(SceneJS._math_inverseMat4(transform.matrix,SceneJS._math_mat4())));
}SceneJS._shaderModule.addModelMatrices(transform.matrixAsArray,transform.normalMatrixAsArray);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.setTransform=function(t){transform=t;dirty=true;SceneJS._eventModule.fireEvent(SceneJS._eventModule.MODEL_TRANSFORM_UPDATED,transform);
};this.getTransform=function(){return transform;};})();SceneJS._modelViewTransformModule=new (function(){var viewSpaceActive=true;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){viewSpaceActive=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.PROJECTION_TRANSFORM_UPDATED,function(t){viewSpaceActive=t.isDefault;
});this.isBuildingViewTransform=function(){return viewSpaceActive;};this.setTransform=function(t){if(viewSpaceActive){SceneJS._viewTransformModule.setTransform(t);}else{SceneJS._modelTransformModule.setTransform(t);}};this.getTransform=function(){if(viewSpaceActive){return SceneJS._viewTransformModule.getTransform();
}else{return SceneJS._modelTransformModule.getTransform();}};})();SceneJS.Rotate=SceneJS.createNodeType("rotate");SceneJS.Rotate.prototype._init=function(params){this._mat=null;this._xform=null;this.setAngle(params.angle);this.setXYZ({x:params.x,y:params.y,z:params.z});};SceneJS.Rotate.prototype.setAngle=function(angle){this._attr.angle=angle||0;
this._memoLevel=0;};SceneJS.Rotate.prototype.getAngle=function(){return this._attr.angle;};SceneJS.Rotate.prototype.setXYZ=function(xyz){xyz=xyz||{};var x=xyz.x||0;var y=xyz.y||0;var z=xyz.z||0;this._attr.x=x;this._attr.y=y;this._attr.z=z;this._memoLevel=0;};SceneJS.Rotate.prototype.getXYZ=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z};
};SceneJS.Rotate.prototype.setX=function(x){this._attr.x=x;this._memoLevel=0;};SceneJS.Rotate.prototype.getX=function(){return this._attr.x;};SceneJS.Rotate.prototype.setY=function(y){this._attr.y=y;this._memoLevel=0;};SceneJS.Rotate.prototype.getY=function(){return this._attr.y;};SceneJS.Rotate.prototype.setZ=function(z){this._attr.z=z;
this._memoLevel=0;};SceneJS.Rotate.prototype.getZ=function(){return this._attr.z;};SceneJS.Rotate.prototype.incX=function(x){this._attr.x+=x;this._memoLevel=0;};SceneJS.Rotate.prototype.incY=function(y){this._attr.y+=y;};SceneJS.Rotate.prototype.incZ=function(z){this._attr.z+=z;this._memoLevel=0;};SceneJS.Rotate.prototype.incAngle=function(angle){this._attr.angle+=angle;
this._memoLevel=0;};SceneJS.Rotate.prototype.getMatrix=function(){return(this._memoLevel>0)?this._mat.slice(0):SceneJS._math_rotationMat4v(this._attr.angle*Math.PI/180,[this._attr.x,this._attr.y,this._attr.z]);};SceneJS.Rotate.prototype.getAttributes=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z,angle:this._attr.angle};
};SceneJS.Rotate.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;if(this._memoLevel==0){this._memoLevel=1;if(this._attr.x+this._attr.y+this._attr.z>0){var angle=SceneJS._modelViewTransformModule.isBuildingViewTransform()?-this._attr.angle:this._attr.angle;this._mat=SceneJS._math_rotationMat4v(angle*Math.PI/180,[this._attr.x,this._attr.y,this._attr.z]);
}else{this._mat=SceneJS._math_identityMat4();}}var superXForm=SceneJS._modelViewTransformModule.getTransform();if(origMemoLevel<2||(!superXForm.fixed)){var instancing=SceneJS._instancingModule.instancing();var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXForm.matrix,this._mat,tempMat);this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};
if(this._memoLevel==1&&superXForm.fixed&&!instancing){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._modelViewTransformModule.setTransform(superXForm);};SceneJS.Translate=SceneJS.createNodeType("translate");SceneJS.Translate.prototype._init=function(params){this._mat=null;
this._xform=null;this.setXYZ({x:params.x,y:params.y,z:params.z});};SceneJS.Translate.prototype.setXYZ=function(xyz){xyz=xyz||{};var x=xyz.x||0;var y=xyz.y||0;var z=xyz.z||0;this._attr.x=x;this._attr.y=y;this._attr.z=z;this._memoLevel=0;};SceneJS.Translate.prototype.getXYZ=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z};
};SceneJS.Translate.prototype.setX=function(x){this._attr.x=x;this._memoLevel=0;};SceneJS.Translate.prototype.getX=function(){return this._attr.x;};SceneJS.Translate.prototype.setY=function(y){this._attr.y=y;this._memoLevel=0;};SceneJS.Translate.prototype.getY=function(){return this._attr.y;};SceneJS.Translate.prototype.setZ=function(z){this._attr.z=z;
this._memoLevel=0;};SceneJS.Translate.prototype.getZ=function(){return this._attr.z;};SceneJS.Translate.prototype.incX=function(x){this._attr.x+=x;this._memoLevel=0;};SceneJS.Translate.prototype.incY=function(y){this._attr.y+=y;};SceneJS.Translate.prototype.incZ=function(z){this._attr.z+=z;this._memoLevel=0;
};SceneJS.Translate.prototype.getMatrix=function(){return(this._memoLevel>0)?this._mat.slice(0):SceneJS._math_translationMat4v([this._attr.x,this._attr.y,this._attr.z]);};SceneJS.Translate.prototype.getAttributes=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z};};SceneJS.Translate.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;
if(this._memoLevel==0){if(SceneJS._modelViewTransformModule.isBuildingViewTransform()){this._mat=SceneJS._math_translationMat4v([-this._attr.x,-this._attr.y,-this._attr.z]);}else{this._mat=SceneJS._math_translationMat4v([this._attr.x,this._attr.y,this._attr.z]);}this._memoLevel=1;}var superXForm=SceneJS._modelViewTransformModule.getTransform();
if(origMemoLevel<2||(!superXForm.fixed)){var instancing=SceneJS._instancingModule.instancing();var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXForm.matrix,this._mat,tempMat);this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};if(this._memoLevel==1&&superXForm.fixed&&!instancing){this._memoLevel=2;
}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._modelViewTransformModule.setTransform(superXForm);};SceneJS.Scale=SceneJS.createNodeType("scale");SceneJS.Scale.prototype._init=function(params){this._mat=null;this._xform=null;this.setXYZ({x:params.x,y:params.y,z:params.z});
};SceneJS.Scale.prototype.setXYZ=function(xyz){xyz=xyz||{};this._attr.x=(xyz.x!=undefined)?xyz.x:1;this._attr.y=(xyz.y!=undefined)?xyz.y:1;this._attr.z=(xyz.z!=undefined)?xyz.z:1;this._setDirty();return this;};SceneJS.Scale.prototype.getXYZ=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z};
};SceneJS.Scale.prototype.setX=function(x){this._attr.x=(x!=undefined&&x!=null)?x:1;this._setDirty();return this;};SceneJS.Scale.prototype.getX=function(){return this._attr.x;};SceneJS.Scale.prototype.setY=function(y){this._attr.y=(y!=undefined&&y!=null)?y:1;this._setDirty();return this;};SceneJS.Scale.prototype.getY=function(){return this._attr.y;
};SceneJS.Scale.prototype.setZ=function(z){this._attr.z=(z!=undefined&&z!=null)?z:1;this._setDirty();return this;};SceneJS.Scale.prototype.getZ=function(){return this._attr.z;};SceneJS.Scale.prototype.incX=function(x){this._attr.x+=x;this._memoLevel=0;};SceneJS.Scale.prototype.incY=function(y){this._attr.y+=y;
};SceneJS.Scale.prototype.incZ=function(z){this._attr.z+=z;this._memoLevel=0;};SceneJS.Scale.prototype.getMatrix=function(){return(this._memoLevel>0)?this._mat.slice(0):SceneJS._math_scalingMat4v([this._attr.x,this._attr.y,this._attr.z]);};SceneJS.Scale.prototype.getAttributes=function(){return{x:this._attr.x,y:this._attr.y,z:this._attr.z};
};SceneJS.Scale.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;if(this._memoLevel==0){this._memoLevel=1;this._mat=SceneJS._math_scalingMat4v([this._attr.x,this._attr.y,this._attr.z]);}var superXform=SceneJS._modelViewTransformModule.getTransform();if(origMemoLevel<2||(!superXform.fixed)){var instancing=SceneJS._instancingModule.instancing();
var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXform.matrix,this._mat,tempMat);this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};if(this._memoLevel==1&&superXform.fixed&&!instancing){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);
SceneJS._modelViewTransformModule.setTransform(superXform);};SceneJS.Matrix=SceneJS.createNodeType("matrix");SceneJS.Matrix.prototype._init=function(params){this._xform=null;this._mat=SceneJS._math_identityMat4();this.setElements(params.elements);};SceneJS.Matrix.prototype.setElements=function(elements){elements=elements||SceneJS._math_identityMat4();
if(!elements){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Matrix elements undefined"));}if(elements.length!=16){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Matrix elements should number 16"));}for(var i=0;
i<16;i++){this._mat[i]=elements[i];}this._setDirty();return this;};SceneJS.Matrix.prototype.getElements=function(){var elements=new Array(16);for(var i=0;i<16;i++){elements[i]=this._mat[i];}return elements;};SceneJS.Matrix.prototype.getMatrix=function(){return this._mat.slice(0);};SceneJS.Matrix.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;
if(this._memoLevel==0){this._memoLevel=1;}var superXform=SceneJS._modelViewTransformModule.getTransform();if(origMemoLevel<2||(!superXform.fixed)){var instancing=SceneJS._instancingModule.instancing();var mat=SceneJS._math_mat4();mat=SceneJS._modelViewTransformModule.isBuildingViewTransform()?SceneJS._math_inverseMat4(this._mat,mat):this._mat;
var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXform.matrix,mat,tempMat);this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};if(this._memoLevel==1&&superXform.fixed&&!instancing){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);
SceneJS._modelViewTransformModule.setTransform(superXform);};SceneJS.Quaternion=SceneJS.createNodeType("quaternion");SceneJS.Quaternion.prototype._init=function(params){this._mat=null;this._xform=null;this._q=SceneJS._math_identityQuaternion();if(params.x||params.y||params.x||params.angle||params.w){this.setRotation(params);
}if(params.rotations){for(var i=0;i<params.rotations.length;i++){this.addRotation(params.rotations[i]);}}};SceneJS.Quaternion.prototype.setRotation=function(q){q=q||{};this._q=SceneJS._math_angleAxisQuaternion(q.x||0,q.y||0,q.z||0,q.angle||0);this._setDirty();return this;};SceneJS.Quaternion.prototype.getRotation=function(){return SceneJS._math_angleAxisFromQuaternion(this._q);
};SceneJS.Quaternion.prototype.addRotation=function(q){this._q=SceneJS._math_mulQuaternions(SceneJS._math_angleAxisQuaternion(q.x||0,q.y||0,q.z||0,q.angle||0),this._q);this._setDirty();return this;};SceneJS.Quaternion.prototype.getMatrix=function(){return(this._memoLevel>0)?this._mat.slice(0):SceneJS._math_newMat4FromQuaternion(this._q);
};SceneJS.Quaternion.prototype.normalize=function(){this._q=SceneJS._math_normalizeQuaternion(this._q);this._setDirty();return this;};SceneJS.Quaternion.prototype.getAttributes=function(){return{x:this._q[0],y:this._q[1],z:this._q[2],w:this._q[3]};};SceneJS.Quaternion.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;
if(this._memoLevel==0){this._mat=SceneJS._math_newMat4FromQuaternion(this._q);this._memoLevel=1;}var superXform=SceneJS._modelViewTransformModule.getTransform();if(origMemoLevel<2||(!superXform.fixed)){var instancing=SceneJS._instancingModule.instancing();var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXform.matrix,this._mat,tempMat);
this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};if(this._memoLevel==1&&superXform.fixed&&!instancing){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._modelViewTransformModule.setTransform(superXform);
};SceneJS.LookAt=SceneJS.createNodeType("lookAt");SceneJS.LookAt.prototype._init=function(params){this._mat=null;this._xform=null;this.setEye(params.eye);this.setLook(params.look);this.setUp(params.up);};SceneJS.LookAt.prototype.setEye=function(eye){eye=eye||{};this._eyeX=(eye.x!=undefined&&eye.x!=null)?eye.x:0;
this._eyeY=(eye.y!=undefined&&eye.y!=null)?eye.y:0;this._eyeZ=(eye.z!=undefined&&eye.z!=null)?eye.z:0;this._memoLevel=0;};SceneJS.LookAt.prototype.setEyeX=function(x){this._eyeX=x||0;this._memoLevel=0;};SceneJS.LookAt.prototype.setEyeY=function(y){this._eyeY=y||0;this._memoLevel=0;};SceneJS.LookAt.prototype.incEye=function(eye){eye=eye||{};
this._eyeX+=(eye.x!=undefined&&eye.x!=null)?eye.x:0;this._eyeY+=(eye.y!=undefined&&eye.y!=null)?eye.y:0;this._eyeZ+=(eye.z!=undefined&&eye.z!=null)?eye.z:0;this._memoLevel=0;};SceneJS.LookAt.prototype.incEyeX=function(x){this._eyeX+=x;this._memoLevel=0;};SceneJS.LookAt.prototype.incEyeY=function(y){this._eyeY+=y;
this._memoLevel=0;};SceneJS.LookAt.prototype.incEyeZ=function(z){this._eyeZ+=z;this._memoLevel=0;};SceneJS.LookAt.prototype.setEyeZ=function(z){this._eyeZ=z||0;this._memoLevel=0;};SceneJS.LookAt.prototype.getEye=function(){return{x:this._eyeX,y:this._eyeY,z:this._eyeZ};};SceneJS.LookAt.prototype.setLook=function(look){look=look||{};
this._lookX=(look.x!=undefined&&look.x!=null)?look.x:0;this._lookY=(look.y!=undefined&&look.y!=null)?look.y:0;this._lookZ=(look.z!=undefined&&look.z!=null)?look.z:0;this._memoLevel=0;};SceneJS.LookAt.prototype.setLookX=function(x){this._lookX=x||0;this._memoLevel=0;};SceneJS.LookAt.prototype.setLookY=function(y){this._lookY=y||0;
this._memoLevel=0;};SceneJS.LookAt.prototype.setLookZ=function(z){this._lookZ=z||0;this._memoLevel=0;};SceneJS.LookAt.prototype.incLook=function(look){look=look||{};this._lookX+=(look.x!=undefined&&look.x!=null)?look.x:0;this._lookY+=(look.y!=undefined&&look.y!=null)?look.y:0;this._lookZ+=(look.z!=undefined&&look.z!=null)?look.z:0;
this._memoLevel=0;};SceneJS.LookAt.prototype.getLook=function(){return{x:this._lookX,y:this._lookY,z:this._lookZ};};SceneJS.LookAt.prototype.setUp=function(up){up=up||{y:1};var x=(up.x!=undefined&&up.x!=null)?up.x:0;var y=(up.y!=undefined&&up.y!=null)?up.y:0;var z=(up.z!=undefined&&up.z!=null)?up.z:0;
if(x+y+z==0){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.lookAt up vector is zero length - at least one of its x,y and z components must be non-zero"));}this._upX=x;this._upY=y;this._upZ=z;this._memoLevel=0;};SceneJS.LookAt.prototype.setUpX=function(x){this._upX=x||0;
this._memoLevel=0;};SceneJS.LookAt.prototype.setUpY=function(x){this._upY=y||0;this._memoLevel=0;};SceneJS.LookAt.prototype.setUpZ=function(x){this._upZ=z||0;this._memoLevel=0;};SceneJS.LookAt.prototype.getUp=function(){return{x:this._upX,y:this._upY,z:this._upZ};};SceneJS.LookAt.prototype.incUp=function(up){up=up||{};
this._upX+=(up.x!=undefined&&up.x!=null)?up.x:0;this._upY+=(up.y!=undefined&&up.y!=null)?up.y:0;this._upZ+=(up.z!=undefined&&up.z!=null)?up.z:0;this._memoLevel=0;};SceneJS.LookAt.prototype.getMatrix=function(){return(this._memoLevel>0)?this._mat.slice(0):SceneJS._math_lookAtMat4c(this._eyeX,this._eyeY,this._eyeZ,this._lookX,this._lookY,this._lookZ,this._upX,this._upY,this._upZ);
};SceneJS.LookAt.prototype.getAttributes=function(){return{look:{x:this._lookX,y:this._lookY,z:this._lookZ},eye:{x:this._eyeX,y:this._eyeY,z:this._eyeZ},up:{x:this._upX,y:this._upY,z:this._upZ}};};SceneJS.LookAt.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;if(this._memoLevel==0){this._mat=SceneJS._math_lookAtMat4c(this._eyeX,this._eyeY,this._eyeZ,this._lookX,this._lookY,this._lookZ,this._upX,this._upY,this._upZ);
this._memoLevel=1;}var superXform=SceneJS._modelViewTransformModule.getTransform();if(this._memoLevel<2||(!superXform.fixed)){var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXform.matrix,this._mat,tempMat);this._xform={type:"lookat",matrix:tempMat,lookAt:{eye:{x:this._eyeX,y:this._eyeY,z:this._eyeZ},look:{x:this._lookX,y:this._lookY,z:this._lookZ},up:{x:this._upX,y:this._upY,z:this._upZ}},fixed:origMemoLevel==2};
if(this._memoLevel==1&&superXform.fixed&&!SceneJS._instancingModule.instancing()){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._modelViewTransformModule.setTransform(superXform);};SceneJS.Stationary=SceneJS.createNodeType("stationary");
SceneJS.Stationary.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;var superXform=SceneJS._viewTransformModule.getTransform();var lookAt=superXform.lookAt;if(lookAt){if(this._memoLevel==0||(!superXform.fixed)){var tempMat=SceneJS._math_mat4();SceneJS._math_mulMat4(superXform.matrix,SceneJS._math_translationMat4c(lookAt.eye.x,lookAt.eye.y,lookAt.eye.z),tempMat);
this._xform={matrix:tempMat,lookAt:lookAt,fixed:origMemoLevel==1};if(superXform.fixed&&!SceneJS._instancingModule.instancing()){this._memoLevel=1;}}SceneJS._viewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._viewTransformModule.setTransform(superXform);}else{this._renderNodes(traversalContext);
}};SceneJS.Billboard=SceneJS.createNodeType("billboard");SceneJS.Billboard.prototype._render=function(traversalContext){var superViewXForm=SceneJS._viewTransformModule.getTransform();var eye=superViewXForm.lookAt.eye;var look=superViewXForm.lookAt.look;var up=superViewXForm.lookAt.up;var superModelXForm=SceneJS._modelTransformModule.getTransform();
var matrix=superModelXForm.matrix.slice(0);var rotMatrix=[matrix[0],matrix[1],matrix[2],0,matrix[4],matrix[5],matrix[6],0,matrix[8],matrix[9],matrix[10],0,0,0,0,1];SceneJS._math_inverseMat4(rotMatrix);SceneJS._math_mulMat4(matrix,rotMatrix,matrix);var ZZ=[];SceneJS._math_subVec3([eye.x,eye.y,eye.z],[look.x,look.y,look.z],ZZ);
SceneJS._math_normalizeVec3(ZZ);var XX=[];SceneJS._math_cross3Vec3([up.x,up.y,up.z],ZZ,XX);SceneJS._math_normalizeVec3(XX);var YY=[];SceneJS._math_cross3Vec3(ZZ,XX,YY);SceneJS._math_normalizeVec3(YY);SceneJS._math_mulMat4(matrix,[XX[0],XX[1],XX[2],0,YY[0],YY[1],YY[2],0,ZZ[0],ZZ[1],ZZ[2],0,0,0,0,1],matrix);
SceneJS._modelTransformModule.setTransform({matrix:matrix});this._renderNodes(traversalContext);SceneJS._modelTransformModule.setTransform(superModelXForm);};SceneJS.Inverse=SceneJS.createNodeType("inverse");SceneJS.Inverse.prototype._render=function(traversalContext){var origMemoLevel=this._memoLevel;
if(this._memoLevel==0){this._memoLevel=1;}var superXform=SceneJS._modelViewTransformModule.getTransform();if(origMemoLevel<2||(!superXform.fixed)){var instancing=SceneJS._instancingModule.instancing();var tempMat=SceneJS._math_mat4();SceneJS._math_inverseMat4(superXform.matrix,this._mat,tempMat);this._xform={localMatrix:this._mat,matrix:tempMat,fixed:origMemoLevel==2};
if(this._memoLevel==1&&superXform.fixed&&!instancing){this._memoLevel=2;}}SceneJS._modelViewTransformModule.setTransform(this._xform);this._renderNodes(traversalContext);SceneJS._modelViewTransformModule.setTransform(superXform);};SceneJS._projectionModule=new (function(){var transform;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){transform={matrix:SceneJS._math_identityMat4(),isDefault:true,fixed:true};
dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){if(!transform.matrixAsArray){transform.matrixAsArray=new Float32Array(transform.matrix);}SceneJS._shaderModule.addProjectionMatrix(transform.matrixAsArray);
dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.setTransform=function(t){transform=t;dirty=true;SceneJS._eventModule.fireEvent(SceneJS._eventModule.PROJECTION_TRANSFORM_UPDATED,transform);};this.getTransform=function(){return transform;
};})();SceneJS.Camera=SceneJS.createNodeType("camera");SceneJS.Camera.prototype._init=function(params){this.setOptics(params.optics);};SceneJS.Camera.prototype.setOptics=function(optics){if(!optics){this._attr.optics={type:"perspective",fovy:60,aspect:1,near:0.1,far:5000};}else{if(optics.type=="ortho"){this._attr.optics={type:optics.type,left:optics.left||-1,bottom:optics.bottom||-1,near:optics.near||0.1,right:optics.right||1,top:optics.top||1,far:optics.far||5000};
}else{if(optics.type=="frustum"){this._attr.optics={type:optics.type,left:optics.left||-1,bottom:optics.bottom||-1,near:optics.near||0.1,right:optics.right||1,top:optics.top||1,far:optics.far||5000};}else{if(optics.type=="perspective"){this._attr.optics={type:optics.type,fovy:optics.fovy||60,aspect:optics.aspect||1,near:optics.near||0.1,far:optics.far||5000};
}else{if(!optics.type){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Camera configuration invalid: optics type not specified - "+"supported types are 'perspective', 'frustum' and 'ortho'"));}else{throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Camera configuration invalid: optics type not supported - "+"supported types are 'perspective', 'frustum' and 'ortho'"));
}}}}}this._setDirty();return this;};SceneJS.Camera.prototype.getOptics=function(){var optics={};for(var key in this._attr.optics){if(this._attr.optics.hasOwnProperty(key)){optics[key]=this._attr.optics[key];}}return optics;};SceneJS.Camera.prototype.getMatrix=function(){if(this._memoLevel==0){this._rebuild();
}return this._transform.matrix.slice(0);};SceneJS.Camera.prototype._render=function(traversalContext){if(this._memoLevel==0){this._rebuild();}var prevTransform=SceneJS._projectionModule.getTransform();SceneJS._projectionModule.setTransform(this._transform);this._renderNodes(traversalContext);SceneJS._projectionModule.setTransform(prevTransform);
};SceneJS.Camera.prototype._rebuild=function(){if(this._memoLevel==0){var optics=this._attr.optics;if(optics.type=="ortho"){this._transform={type:optics.type,optics:{left:optics.left,right:optics.right,bottom:optics.bottom,top:optics.top,near:optics.near,far:optics.far},matrix:SceneJS._math_orthoMat4c(optics.left,optics.right,optics.bottom,optics.top,optics.near,optics.far)};
}else{if(optics.type=="frustum"){this._transform={type:optics.type,optics:{left:optics.left,right:optics.right,bottom:optics.bottom,top:optics.top,near:optics.near,far:optics.far},matrix:SceneJS._math_frustumMatrix4(optics.left,optics.right,optics.bottom,optics.top,optics.near,optics.far)};}else{if(optics.type=="perspective"){this._transform={type:optics.type,optics:{fovy:optics.fovy,aspect:optics.aspect,near:optics.near,far:optics.far},matrix:SceneJS._math_perspectiveMatrix4(optics.fovy*Math.PI/180,optics.aspect,optics.near,optics.far)};
}}}this._memoLevel=1;}};SceneJS.Node.prototype.queryViewMatrix=function(){return SceneJS._viewTransformModule.getTransform().matrix.split(0);};SceneJS.Node.prototype.queryModelMatrix=function(){return SceneJS._modelTransformModule.getTransform().matrix.split(0);};SceneJS.Node.prototype.queryCameraMatrix=function(){return SceneJS._projectionModule.getTransform().matrix.split(0);
};SceneJS.Node.prototype.queryModelPos=function(){return SceneJS._math_transformPoint3(SceneJS._modelTransformModule.getTransform().matrix,[0,0,0]);};SceneJS.Node.prototype.queryViewPos=function(){return SceneJS._math_transformPoint3(SceneJS._viewTransformModule.getTransform().matrix,SceneJS._math_transformPoint3(SceneJS._modelTransformModule.getTransform().matrix,[0,0,0]));
};SceneJS.Node.prototype.queryCameraPos=function(){return SceneJS._math_transformPoint3(SceneJS._projectionModule.getTransform().matrix,SceneJS._math_transformPoint3(SceneJS._viewTransformModule.getTransform().matrix,SceneJS._math_transformPoint3(SceneJS._modelTransformModule.getTransform().matrix,[0,0,0])));
};SceneJS._lightingModule=new (function(){var viewMat;var modelMat;var lightStack=[];var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){modelMat=viewMat=SceneJS._math_identityMat4();lightStack=[];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(params){viewMat=params.matrix;});SceneJS._eventModule.addListener(SceneJS._eventModule.MODEL_TRANSFORM_UPDATED,function(params){modelMat=params.matrix;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._eventModule.fireEvent(SceneJS._eventModule.LIGHTS_EXPORTED,lightStack);
dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.pushLight=function(light){instanceLight(light);lightStack.push(light);dirty=true;};function instanceLight(light){if(light.mode=="point"){light.viewPos=SceneJS._math_transformPoint3(viewMat,SceneJS._math_transformPoint3(modelMat,light.pos));
}else{if(light.mode=="dir"){light.viewDir=SceneJS._math_transformVector3(viewMat,SceneJS._math_transformVector3(modelMat,light.dir));}}}})();SceneJS.Light=SceneJS.createNodeType("light");SceneJS.Light.prototype._init=function(params){params=params||{};this._light={};this.setMode(params.mode);this.setColor(params.color);
this.setDiffuse(params.diffuse);this.setSpecular(params.specular);this.setPos(params.pos);this.setDir(params.dir);this.setConstantAttenuation(params.constantAttenuation);this.setLinearAttenuation(params.linearAttenuation);this.setQuadraticAttenuation(params.quadraticAttenuation);};SceneJS.Light.prototype.setMode=function(mode){mode=mode||"dir";
if(mode!="dir"&&mode!="point"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Light unsupported mode - should be 'dir' or 'point' or 'ambient'"));}this._light.mode=mode;return this;};SceneJS.Light.prototype.getMode=function(){return this._light.mode;};SceneJS.Light.prototype.setColor=function(color){color=color||{};
this._light.color=[color.r!=undefined?color.r:1,color.g!=undefined?color.g:1,color.b!=undefined?color.b:1];return this;};SceneJS.Light.prototype.getColor=function(){return{r:this._light.color[0],g:this._light.color[1],b:this._light.color[2]};};SceneJS.Light.prototype.setDiffuse=function(diffuse){this._light.diffuse=(diffuse!=undefined)?diffuse:true;
return this;};SceneJS.Light.prototype.getDiffuse=function(){return this._light.diffuse;};SceneJS.Light.prototype.setSpecular=function(specular){this._light.specular=specular||false;return this;};SceneJS.Light.prototype.getSpecular=function(){return this._light.specular;};SceneJS.Light.prototype.setPos=function(pos){pos=pos||{};
this._light.pos=[pos.x||0,pos.y||0,pos.z||0];return this;};SceneJS.Light.prototype.getPos=function(){return{x:this._light.pos[0],y:this._light.pos[1],z:this._light.pos[2]};};SceneJS.Light.prototype.setDir=function(dir){dir=dir||{};this._light.dir=[dir.x||0,dir.y||0,(dir.z==undefined||dir.z==null)?-1:dir.z];
return this;};SceneJS.Light.prototype.getDir=function(){return{x:this._light.dir[0],y:this._light.dir[1],z:this._light.dir[2]};};SceneJS.Light.prototype.setConstantAttenuation=function(constantAttenuation){this._light.constantAttenuation=(constantAttenuation!=undefined)?constantAttenuation:1;return this;
};SceneJS.Light.prototype.getConstantAttenuation=function(){return this._light.constantAttenuation;};SceneJS.Light.prototype.setLinearAttenuation=function(linearAttenuation){this._light.linearAttenuation=linearAttenuation||0;return this;};SceneJS.Light.prototype.getLinearAttenuation=function(){return this._light.linearAttenuation;
};SceneJS.Light.prototype.setQuadraticAttenuation=function(quadraticAttenuation){this._light.quadraticAttenuation=quadraticAttenuation||0;return this;};SceneJS.Light.prototype.getQuadraticAttenuation=function(){return this._light.quadraticAttenuation;};SceneJS.Light.prototype._render=function(traversalContext){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);
}else{SceneJS._lightingModule.pushLight(this._light);this._renderNodes(traversalContext);}};SceneJS._materialModule=new (function(){var materialStack=[];var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){materialStack=[{override:false}];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.addMaterial(materialStack[materialStack.length-1]);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.pushMaterial=function(m){var top=materialStack[materialStack.length-1];
materialStack.push({highlightBaseColor:(m.highlightBaseColor!=undefined&&!(top.override&&top.highlightBaseColor!=undefined))?[m.highlightBaseColor.r,m.highlightBaseColor.g,m.highlightBaseColor.b]:top.baseColor,baseColor:(m.baseColor!=undefined&&!(top.override&&top.baseColor!=undefined))?[m.baseColor.r,m.baseColor.g,m.baseColor.b]:top.baseColor,specularColor:(m.specularColor!=undefined&&!(top.override&&top.specularColor!=undefined))?[m.specularColor.r,m.specularColor.g,m.specularColor.b]:top.specularColor,specular:(m.specular!=undefined&&!(top.override&&top.specular!=undefined))?m.specular:top.specular,shine:(m.shine!=undefined&&!(top.override&&top.shine!=undefined))?m.shine:top.shine,reflect:(m.reflect!=undefined&&!(top.override&&top.reflect!=undefined))?m.reflect:top.reflect,alpha:(m.alpha!=undefined&&!(top.override&&top.alpha!=undefined))?m.alpha:top.alpha,emit:(m.emit!=undefined&&!(top.override&&top.emit!=undefined))?m.emit:top.emit,opacity:(m.opacity!=undefined&&!(top.override&&top.opacity!=undefined))?m.opacity:top.opacity});
dirty=true;};this.popMaterial=function(){materialStack.pop();dirty=true;};})();SceneJS.Material=SceneJS.createNodeType("material");SceneJS.Material.prototype._init=function(params){this.setBaseColor(params.baseColor);this.setHighlightBaseColor(params.highlightBaseColor);this.setSpecularColor(params.specularColor);
this.setSpecular(params.specular);this.setShine(params.shine);this.setReflect(params.reflect);this.setEmit(params.emit);this.setAlpha(params.alpha);this.setOpacity(params.opacity);};SceneJS.Material.prototype.setBaseColor=function(color){this._attr.baseColor=color?{r:color.r!=undefined&&color.r!=null?color.r:0,g:color.g!=undefined&&color.g!=null?color.g:0,b:color.b!=undefined&&color.b!=null?color.b:0}:null;
};SceneJS.Material.prototype.getBaseColor=function(){return this._attr.baseColor?{r:this._attr.baseColor.r,g:this._attr.baseColor.g,b:this._attr.baseColor.b}:null;};SceneJS.Material.prototype.setHighlightBaseColor=function(color){this._attr.highlightBaseColor=color?{r:color.r!=undefined&&color.r!=null?color.r:0,g:color.g!=undefined&&color.g!=null?color.g:0,b:color.b!=undefined&&color.b!=null?color.b:0}:null;
};SceneJS.Material.prototype.getHighlightBaseColor=function(){return this._attr.highlightBaseColor?{r:this._attr.highlightBaseColor.r,g:this._attr.highlightBaseColor.g,b:this._attr.highlightBaseColor.b}:null;};SceneJS.Material.prototype.setSpecularColor=function(color){this._attr.specularColor=color?{r:color.r!=undefined&&color.r!=null?color.r:0.5,g:color.g!=undefined&&color.g!=null?color.g:0.5,b:color.b!=undefined&&color.b!=null?color.b:0.5}:null;
};SceneJS.Material.prototype.getBaseColor=function(){return this._attr.baseColor?{r:this._attr.baseColor.r,g:this._attr.baseColor.g,b:this._attr.baseColor.b}:null;};SceneJS.Material.prototype.getSpecularColor=function(){return this._attr.specularColor?{r:this._attr.specularColor.r,g:this._attr.specularColor.g,b:this._attr.specularColor.b}:null;
};SceneJS.Material.prototype.setSpecular=function(specular){this._attr.specular=specular;};SceneJS.Material.prototype.getSpecular=function(){return this._attr.specular;};SceneJS.Material.prototype.setShine=function(shine){this._attr.shine=shine;};SceneJS.Material.prototype.getShine=function(){return this._attr.shine;
};SceneJS.Material.prototype.setReflect=function(reflect){this._attr.reflect=reflect;};SceneJS.Material.prototype.getReflect=function(){return this._attr.reflect;};SceneJS.Material.prototype.setEmit=function(emit){this._attr.emit=emit;};SceneJS.Material.prototype.getEmit=function(){return this._attr.emit;
};SceneJS.Material.prototype.setAlpha=function(alpha){this._attr.alpha=alpha;};SceneJS.Material.prototype.getAlpha=function(){return this._attr.alpha;};SceneJS.Material.prototype.setOpacity=function(opacity){this._attr.opacity=opacity;};SceneJS.Material.prototype.getOpacity=function(){return this._attr.opacity;
};SceneJS.Material.prototype._render=function(traversalContext){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);}else{SceneJS._materialModule.pushMaterial(this._attr);this._renderNodes(traversalContext);SceneJS._materialModule.popMaterial();}};SceneJS.Colortrans=SceneJS.createNodeType("colortrans");
SceneJS.Colortrans.prototype._init=function(params){this.setScale(params.scale);this.setAdd(params.add);this.setSaturation(params.saturation);};SceneJS.Colortrans.prototype.setSaturation=function(saturation){this._attr.saturation=saturation;};SceneJS.Colortrans.prototype.getSaturation=function(){return this._attr.saturation;
};SceneJS.Colortrans.prototype.setScale=function(scale){scale=scale||{};this._attr.scale={r:scale.r!=undefined?scale.r:1,g:scale.g!=undefined?scale.g:1,b:scale.b!=undefined?scale.b:1,a:scale.a!=undefined?scale.a:1};};SceneJS.Colortrans.prototype.getScale=function(){return this._attr.scale;};SceneJS.Colortrans.prototype.setAdd=function(add){add=add||{};
this._attr.add={r:add.r!=undefined?add.r:0,g:add.g!=undefined?add.g:0,b:add.b!=undefined?add.b:0,a:add.a!=undefined?add.a:0};};SceneJS.Colortrans.prototype.getAdd=function(){return this._attr.add;};SceneJS.Colortrans.prototype._render=function(traversalContext){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);
}else{SceneJS._colortransModule.pushColortrans(this._attr);this._renderNodes(traversalContext);SceneJS._colortransModule.popColortrans();}};SceneJS._colortransModule=new (function(){var colortransStack=new Array(500);var stackLen=0;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){colortransStack=[];
dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.setColortrans(stackLen>0?colortransStack[stackLen-1]:null);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;
});this.pushColortrans=function(trans){colortransStack[stackLen++]=trans;dirty=true;};this.popColortrans=function(){stackLen--;dirty=true;};})();SceneJS.Interpolator=SceneJS.createNodeType("interpolator");SceneJS.Interpolator.prototype._init=function(params){this._attr.target=params.target;this._attr.targetProperty=params.targetProperty;
this._timeStarted=null;this._outputValue=null;this._attr.once=params.once;if(params.keys){if(!params.values){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Interpolator configuration incomplete: "+"keys supplied but no values - must supply a value for each key"));
}for(var i=1;i<params.keys.length;i++){if(params.keys[i-1]>=params.keys[i]){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Interpolator configuration invalid: "+"two invalid keys found ("+(i-1)+" and "+i+") - key list should contain distinct values in ascending order"));
}}}else{if(params.values){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Interpolator configuration incomplete: "+"values supplied but no keys - must supply a key for each value"));}}this._attr.keys=params.keys||[];this._attr.values=params.values||[];this._key1=0;
this._key2=1;params.mode=params.mode||"linear";switch(params.mode){case"linear":break;case"constant":break;case"cosine":break;case"cubic":if(params.keys.length<4){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Interpolator configuration invalid: minimum of four keyframes "+"required for cubic - only "+params.keys.length+" are specified"));
}break;case"slerp":break;default:throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Interpolator configuration invalid: mode not supported - "+"only 'linear', 'cosine', 'cubic', 'constant' and 'slerp' are supported"));}this._attr.mode=params.mode;this._attr.once=params.once;
};SceneJS.Interpolator.prototype.STATE_OUTSIDE="outside";SceneJS.Interpolator.prototype.STATE_BEFORE="pending";SceneJS.Interpolator.prototype.STATE_AFTER="complete";SceneJS.Interpolator.prototype.STATE_RUNNING="running";SceneJS.Interpolator.prototype._render=function(traversalContext){if(!this._attr.target){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NodeConfigExpectedException("SceneJS.Interpolator config expected: target"));
}if(!this._attr.targetProperty){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NodeConfigExpectedException("SceneJS.Interpolator config expected: targetProperty"));}if(!this._timeStarted){this._timeStarted=SceneJS._timeModule.getTime();}this._update((SceneJS._timeModule.getTime()-this._timeStarted)*0.001);
if(this._outputValue!=null&&SceneJS.nodeExists(this._attr.target)){SceneJS.withNode(this._attr.target).set(this._attr.targetProperty,this._outputValue);}this._renderNodes(traversalContext);};SceneJS.Interpolator.prototype._update=function(key){switch(this._findEnclosingFrame(key)){case this.STATE_OUTSIDE:break;
case this.STATE_BEFORE:this._setDirty();break;case this.STATE_AFTER:this._outputValue=null;if(this._attr.once){this.destroy();}break;case this.STATE_RUNNING:this._outputValue=this._interpolate((key));this._setDirty();break;default:break;}};SceneJS.Interpolator.prototype._findEnclosingFrame=function(key){if(this._attr.keys.length==0){return this.STATE_OUTSIDE;
}if(key<this._attr.keys[0]){return this.STATE_BEFORE;}if(key>this._attr.keys[this._attr.keys.length-1]){return this.STATE_AFTER;}while(this._attr.keys[this._key1]>key){this._key1--;this._key2--;}while(this._attr.keys[this._key2]<key){this._key1++;this._key2++;}return this.STATE_RUNNING;};SceneJS.Interpolator.prototype._interpolate=function(k){switch(this._attr.mode){case"linear":return this._linearInterpolate(k);
case"cosine":return this._cosineInterpolate(k);case"cubic":return this._cubicInterpolate(k);case"constant":return this._constantInterpolate(k);case"slerp":return this._slerp(k);default:throw SceneJS._errorModule.fatalError(new SceneJS.errors.InternalException("SceneJS.Interpolator internal error - interpolation mode not switched: '"+this._attr.mode+"'"));
}};SceneJS.Interpolator.prototype._linearInterpolate=function(k){var u=this._attr.keys[this._key2]-this._attr.keys[this._key1];var v=k-this._attr.keys[this._key1];var w=this._attr.values[this._key2]-this._attr.values[this._key1];return this._attr.values[this._key1]+((v/u)*w);};SceneJS.Interpolator.prototype._constantInterpolate=function(k){if(Math.abs((k-this._attr.keys[this._key1]))<Math.abs((k-this._attr.keys[this._key2]))){return this._attr.keys[this._key1];
}else{return this._attr.keys[this._key2];}};SceneJS.Interpolator.prototype._cosineInterpolate=function(k){var mu2=(1-Math.cos(k*Math.PI)/2);return(this._attr.keys[this._key1]*(1-mu2)+this._attr.keys[this._key2]*mu2);};SceneJS.Interpolator.prototype._cubicInterpolate=function(k){if(this._key1==0||this._key2==(this._attr.keys.length-1)){return this._cosineInterpolate(k);
}var y0=this._attr.keys[this._key1-1];var y1=this._attr.keys[this._key1];var y2=this._attr.keys[this._key2];var y3=this._attr.keys[this._key2+1];var mu2=k*k;var a0=y3-y2-y0+y1;var a1=y0-y1-a0;var a2=y2-y0;var a3=y1;return(a0*k*mu2+a1*mu2+a2*k+a3);};SceneJS.Interpolator.prototype._slerp=function(k){var u=this._attr.keys[this._key2]-this._attr.keys[this._key1];
var v=k-this._attr.keys[this._key1];return SceneJS._math_slerp((v/u),this._attr.values[this._key1],this._attr.values[this._key2]);};SceneJS.Interpolator.prototype._changeState=function(newState,params){params=params||{};params.oldState=this._state;params.newState=newState;this._state=newState;if(this._listeners["state-changed"]){this._fireEvent("state-changed",params);
}};SceneJS._frustumModule=new (function(){var viewport;var projMat;var viewMat;var frustum;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){projMat=viewMat=SceneJS._math_identityMat4();viewport=[0,0,1,1];frustum=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEWPORT_UPDATED,function(v){viewport=[v.x,v.y,v.width,v.height];
frustum=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.PROJECTION_TRANSFORM_UPDATED,function(params){projMat=params.matrix;frustum=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(params){viewMat=params.matrix;frustum=null;});this.testAxisBoxIntersection=function(box){return getFrustum().textAxisBoxIntersection(box);
};var getFrustum=function(){if(!frustum){frustum=new SceneJS._math_Frustum(viewMat,projMat,viewport);}return frustum;};this.getProjectedSize=function(box){return getFrustum().getProjectedSize(box);};this.getProjectedState=function(box){return getFrustum().getProjectedState(box);};})();SceneJS._localityModule=new (function(){var eye;
var radii;var radii2;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){eye={x:0,y:0,z:0};radii={inner:100000,outer:200000};radii2={inner:radii.inner*radii.inner,outer:radii.outer*radii.outer};});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(transform){if(transform.lookAt){var e=transform.lookAt.eye;
eye=[e.x,e.y,e.z];}else{eye=[0,0,0];}});function intersects(radius2,box){var dmin=0;var e;for(var i=0;i<3;i++){if(eye[i]<box.min[i]){e=eye[i]-box.min[i];dmin+=(e*e);}else{if(eye[i]>box.max[i]){e=eye[i]-box.max[i];dmin+=(e*e);}}}return(dmin<=radius2);}this.setRadii=function(r){radii={outer:r.inner,inner:r.outer};
radii2={inner:r.inner*r.inner,outer:r.outer*r.outer};};this.getRadii=function(){return radii;};this.testAxisBoxIntersectOuterRadius=function(box){return intersects(radii2.outer,box);};this.testAxisBoxIntersectInnerRadius=function(box){return intersects(radii2.inner,box);};})();SceneJS.BoundingBox=SceneJS.createNodeType("boundingBox");
SceneJS.BoundingBox.prototype._init=function(params){this._xmin=params.xmin||0;this._ymin=params.ymin||0;this._zmin=params.zmin||0;this._xmax=params.xmax||0;this._ymax=params.ymax||0;this._zmax=params.zmax||0;this._levels=null;this._level=-1;this._states=[];this._state=SceneJS.BoundingBox.STATE_INITIAL;
this._localCoords=null;this._modelBox=null;this._viewBox=null;this._canvasBox=null;if(params.levels){this._levels=params.levels;}this._validated=false;};SceneJS.BoundingBox.STATE_INITIAL="init";SceneJS.BoundingBox.STATE_OUTSIDE_OUTER_LOCALITY="outside";SceneJS.BoundingBox.STATE_INTERSECTING_OUTER_LOCALITY="far";
SceneJS.BoundingBox.STATE_INTERSECTING_INNER_LOCALITY="near";SceneJS.BoundingBox.STATE_INTERSECTING_FRUSTUM="visible";SceneJS.BoundingBox.prototype._changeState=function(newState,params){this._state=newState;if(this._listeners["state-changed"]){params=params||{};params.oldState=this._state;params.newState=newState;
this._fireEvent("state-changed",params);}};SceneJS.BoundingBox.prototype.setXMin=function(xmin){this._xmin=xmin;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getXMin=function(){return this._xmin;};SceneJS.BoundingBox.prototype.setYMin=function(ymin){this._ymin=ymin;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getYMin=function(){return this._ymin;
};SceneJS.BoundingBox.prototype.setZMin=function(zmin){this._zmin=zmin;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getZMin=function(){return this._zmin;};SceneJS.BoundingBox.prototype.setXMax=function(xmax){this._xmax=xmax;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getXMax=function(){return this._xmax;
};SceneJS.BoundingBox.prototype.setYMax=function(ymax){this._ymax=ymax;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getYMax=function(){return this._ymax;};SceneJS.BoundingBox.prototype.setZMax=function(zmax){this._zmax=zmax;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getZMax=function(){return this._zmax;
};SceneJS.BoundingBox.prototype.setBoundary=function(boundary){this._xmin=boundary.xmin||0;this._ymin=boundary.ymin||0;this._zmin=boundary.zmin||0;this._xmax=boundary.xmax||0;this._ymax=boundary.ymax||0;this._zmax=boundary.zmax||0;this._memoLevel=0;};SceneJS.BoundingBox.prototype.getBoundary=function(){return{xmin:this._xmin,ymin:this._ymin,zmin:this._zmin,xmax:this._xmax,ymax:this._ymax,zmax:this._zmax};
};SceneJS.BoundingBox.prototype._render=function(traversalContext){if(!this._validated){if(this._levels){if(this._levels.length!=this._children.length){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NodeConfigExpectedException("boundingBox levels property should have a value for each child node"));
}for(var i=1;i<this._levels.length;i++){if(this._levels[i-1]>=this._levels[i]){throw SceneJS._errorModule.fatalError(new SceneJS.errors.NodeConfigExpectedException("boundingBox levels property should be an ascending list of unique values"));}}}}var origLevel=this._level;var origState=this._state;var newState;
var modelTransform=SceneJS._modelTransformModule.getTransform();if(this._memoLevel==0){this._state=SceneJS.BoundingBox.STATE_INITIAL;this._memoLevel=1;if(!modelTransform.identity){this._localCoords=[[this._xmin,this._ymin,this._zmin],[this._xmax,this._ymin,this._zmin],[this._xmax,this._ymax,this._zmin],[this._xmin,this._ymax,this._zmin],[this._xmin,this._ymin,this._zmax],[this._xmax,this._ymin,this._zmax],[this._xmax,this._ymax,this._zmax],[this._xmin,this._ymax,this._zmax]];
}else{this._modelBox={min:[this._xmin,this._ymin,this._zmin],max:[this._xmax,this._ymax,this._zmax]};this._modelCoords=null;this._memoLevel=2;}}if(this._memoLevel<2){modelTransform=SceneJS._modelTransformModule.getTransform();this._modelBox=new SceneJS._math_Box3().fromPoints(SceneJS._math_transformPoints3(modelTransform.matrix,this._localCoords));
this._modelCoords=null;if(modelTransform.fixed&&this._memoLevel==1&&(!SceneJS._instancingModule.instancing())){this._localCoords=null;this._memoLevel=2;}}newState=SceneJS.BoundingBox.STATE_OUTSIDE_OUTER_LOCALITY;if(SceneJS._localityModule.testAxisBoxIntersectOuterRadius(this._modelBox)){newState=SceneJS.BoundingBox.STATE_INTERSECTING_OUTER_LOCALITY;
if(SceneJS._localityModule.testAxisBoxIntersectInnerRadius(this._modelBox)){newState=SceneJS.BoundingBox.STATE_INTERSECTING_INNER_LOCALITY;var result=SceneJS._frustumModule.testAxisBoxIntersection(this._modelBox);switch(result){case SceneJS._math_INTERSECT_FRUSTUM:case SceneJS._math_INSIDE_FRUSTUM:newState=SceneJS.BoundingBox.STATE_INTERSECTING_FRUSTUM;
if(!this._modelCoords){this._modelCoords=[[this._modelBox.min[0],this._modelBox.min[1],this._modelBox.min[2]],[this._modelBox.max[0],this._modelBox.min[1],this._modelBox.min[2]],[this._modelBox.max[0],this._modelBox.max[1],this._modelBox.min[2]],[this._modelBox.min[0],this._modelBox.max[1],this._modelBox.min[2]],[this._modelBox.min[0],this._modelBox.min[1],this._modelBox.max[2]],[this._modelBox.max[0],this._modelBox.min[1],this._modelBox.max[2]],[this._modelBox.max[0],this._modelBox.max[1],this._modelBox.max[2]],[this._modelBox.min[0],this._modelBox.max[1],this._modelBox.max[2]]];
}this._viewBox=new SceneJS._math_Box3().fromPoints(SceneJS._math_transformPoints3(SceneJS._viewTransformModule.getTransform().matrix,this._modelCoords));this._canvasSize=SceneJS._frustumModule.getProjectedSize(this._modelBox);if(newState!=origState){this._changeState(newState);}var isectListeners=this._listeners["intersect"];
SceneJS._boundaryModule.pushBoundary(this._modelBox,this._viewBox,this._attr.id,this._state=newState,(isectListeners!=undefined&&isectListeners!=null));if(this._levels){for(var i=this._levels.length-1;i>=0;i--){if(this._levels[i]<=this._canvasSize){this._level=i;if(origLevel!=this._level){if(this._listeners["lod-selected"]){this._fireEvent("lod-selected",{oldLevel:origLevel,newLevel:this._level});
}}var state=this._states[i];if(this._children.length>0){this._renderNodeAtIndex(i,traversalContext);}else{this._renderNodes(traversalContext);}return;}}}else{this._renderNodes(traversalContext);}SceneJS._boundaryModule.popBoundary();break;case SceneJS._math_OUTSIDE_FRUSTUM:if(newState!=origState){this._changeState(newState);
}break;}}else{if(newState!=origState){this._changeState(newState);}this._renderNodes(traversalContext);}}else{if(newState!=origState){this._changeState(newState);}}};SceneJS.BoundingBox.prototype.getJSON=function(){return{xmin:this._xmin,ymin:this._ymin,zmin:this._zmin,xmax:this._xmax,ymax:this._ymax,zmax:this._zmax};
};SceneJS.BoundingBox.prototype.queryState=function(){return this._state;};SceneJS.BoundingBox.prototype.queryCanvasSize=function(){return this._canvasSize;};SceneJS.BoundingBox.prototype.queryLevel=function(){return this._level;};SceneJS._boundaryModule=new (function(){var viewMat;var boundaryStack=new Array(1000);
var stackLen=0;var dirty;var boundaries=new Array(1000);var numBoundaries;var observedBoundaries=new Array(500);var numObservedBoundaries;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){viewMat=SceneJS._math_identityMat4();stackLen=0;dirty=true;numBoundaries=0;numObservedBoundaries=0;
});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(params){viewMat=params.matrix;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_NEEDS_BOUNDARIES,function(){if(dirty){var topBoundary=stackLen>0?boundaryStack[stackLen-1]:null;
SceneJS._eventModule.fireEvent(SceneJS._eventModule.BOUNDARY_EXPORTED,topBoundary);dirty=false;}});this.pushBoundary=function(modelBox,viewBox,nodeId,isectState,observed){var boundary={modelBox:modelBox,viewBox:viewBox,nodeId:nodeId,isectState:isectState};boundaryStack[stackLen++]=boundary;dirty=true;
if(observed){observedBoundaries[numObservedBoundaries++]=boundary;}else{boundaries[numBoundaries++]=boundary;}};this.popBoundary=function(){stackLen--;};SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_DEACTIVATED,function(){if(numObservedBoundaries>0){findViewBoundingBoxIntersects(observedBoundaries,numObservedBoundaries,boundaries,numBoundaries);
}});function findViewBoundingBoxIntersects(list1,len1,list2,len2){var b1,b2;var isects={};var numIntersects=0;for(var i=0;i<len1;i++){for(var j=0;j<len2;j++){if(list1[i].nodeId!=list2[j].nodeId){b1=list1[i].viewBox;b2=list2[j].viewBox;if(b1.max[0]<b2.min[0]||b1.max[1]<b2.min[1]||b1.max[2]<b2.min[2]||b2.max[0]<b1.min[0]||b2.max[1]<b1.min[1]||b2.max[2]<b1.min[2]){}else{isects[list2[j].nodeId]=true;
numIntersects++;}}}if(numIntersects>0){SceneJS._nodeIDMap[list1[i].nodeId]._fireEvent("intersect",{nodeIds:isects});isects={};}}}})();SceneJS.Locality=SceneJS.createNodeType("locality");SceneJS.Locality.prototype._init=function(params){this.setInner(params.inner);this.setOuter(params.outer);};SceneJS.Locality.prototype.setInner=function(inner){this._attr.inner=inner||100000;
this._setDirty();return this;};SceneJS.Locality.prototype.getInner=function(){return this._attr.inner;};SceneJS.Locality.prototype.setOuter=function(outer){this._attr.outer=outer||200000;this._setDirty();return this;};SceneJS.Locality.prototype.getOuter=function(){return this._attr.outer;};SceneJS.Locality.prototype._render=function(traversalContext,data){if(!this._fixedParams){this._init(this._getParams(data));
}var prevRadii=SceneJS._localityModule.getRadii();SceneJS._localityModule.setRadii(this._attr);this._renderNodes(traversalContext,data);SceneJS._localityModule.setRadii(prevRadii);};SceneJS._textureModule=new (function(){var time=(new Date()).getTime();var canvas;var textures={};var textureStack=[];var dirty;
SceneJS._eventModule.addListener(SceneJS._eventModule.TIME_UPDATED,function(t){time=t;});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){textureStack=[];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(c){canvas=c;dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_DEACTIVATED,function(){canvas=null;dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._eventModule.fireEvent(SceneJS._eventModule.TEXTURES_EXPORTED,(textureStack.length>0)?{layers:textureStack[textureStack.length-1]}:{layers:[]});
dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});function deleteTexture(texture){textures[texture.textureId]=undefined;if(document.getElementById(texture.canvas.canvasId)){texture.destroy();}}function deleteTextures(){for(var textureId in textures){var texture=textures[textureId];
deleteTexture(texture);}textures={};textureStack=[];dirty=true;}SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){deleteTextures();});SceneJS._memoryModule.registerEvictor(function(){var earliest=time;var evictee;for(var id in textures){if(id){var texture=textures[id];if(texture.lastUsed<earliest){evictee=texture;
earliest=texture.lastUsed;}}}if(evictee){SceneJS._loggingModule.info("Evicting texture: "+id);deleteTexture(evictee);return true;}return false;});function getGLOption(name,context,cfg,defaultVal){var value=cfg[name];if(value==undefined){return defaultVal;}var glName=SceneJS._webgl_enumMap[value];if(glName==undefined){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Unrecognised value for SceneJS.texture node property '"+name+"' value: '"+value+"'"));
}var glValue=context[glName];return glValue;}function getOption(value,defaultVal){return(value==undefined)?defaultVal:value;}this.textureExists=function(texture){return textures[texture.textureId];};this.createTexture=function(cfg,onSuccess,onError,onAbort){var image=new Image();var _canvas=canvas;var _context=canvas.context;
if(cfg.uri){var process=SceneJS._processModule.createProcess({description:"creating texture: uri = "+cfg.uri,type:"create-texture",info:{uri:cfg.uri},timeoutSecs:-1});image.onload=function(){var textureId=allocateTexture(_canvas,_context,image,cfg);SceneJS._processModule.killProcess(process);onSuccess(textures[textureId]);
};image.onerror=function(){SceneJS._processModule.killProcess(process);onError();};image.onabort=function(){SceneJS._processModule.killProcess(process);onAbort();};image.src=cfg.uri;}else{if(cfg.image){var textureId=allocateTexture(_canvas,_context,cfg.image,cfg);onSuccess(textures[textureId]);}else{throw SceneJS._errorModule.fatalError("Failed to create texture: neither cfg.image nor cfg.uri supplied");
}}};function allocateTexture(canvas,context,image,cfg){var textureId=SceneJS._createKeyForMap(textures,"t");SceneJS._memoryModule.allocate(context,"texture '"+textureId+"'",function(){try{textures[textureId]=new SceneJS._webgl_Texture2D(context,{textureId:textureId,canvas:canvas,image:ensureImageSizePowerOfTwo(image),texels:cfg.texels,minFilter:getGLOption("minFilter",context,cfg,context.LINEAR),magFilter:getGLOption("magFilter",context,cfg,context.LINEAR),wrapS:getGLOption("wrapS",context,cfg,context.CLAMP_TO_EDGE),wrapT:getGLOption("wrapT",context,cfg,context.CLAMP_TO_EDGE),isDepth:getOption(cfg.isDepth,false),depthMode:getGLOption("depthMode",context,cfg,context.LUMINANCE),depthCompareMode:getGLOption("depthCompareMode",context,cfg,context.COMPARE_R_TO_TEXTURE),depthCompareFunc:getGLOption("depthCompareFunc",context,cfg,context.LEQUAL),flipY:getOption(cfg.flipY,true),width:getOption(cfg.width,1),height:getOption(cfg.height,1),internalFormat:getGLOption("internalFormat",context,cfg,context.LEQUAL),sourceFormat:getGLOption("sourceType",context,cfg,context.ALPHA),sourceType:getGLOption("sourceType",context,cfg,context.UNSIGNED_BYTE),logging:SceneJS._loggingModule});
}catch(e){throw SceneJS._errorModule.fatalError("Failed to create texture: "+e);}});return textureId;}function ensureImageSizePowerOfTwo(image){if(!isPowerOfTwo(image.width)||!isPowerOfTwo(image.height)){var canvas=document.createElement("canvas");canvas.width=nextHighestPowerOfTwo(image.width);canvas.height=nextHighestPowerOfTwo(image.height);
var ctx=canvas.getContext("2d");ctx.drawImage(image,0,0,image.width,image.height,0,0,canvas.width,canvas.height);image=canvas;}return image;}function isPowerOfTwo(x){return(x&(x-1))==0;}function nextHighestPowerOfTwo(x){--x;for(var i=1;i<32;i<<=1){x=x|x>>i;}return x+1;}this.pushTexture=function(layers){textureStack.push(layers);
dirty=true;};this.popTexture=function(){textureStack.pop();dirty=true;};})();SceneJS.TextureLayer=function(cfg){this._imageBuffer=null;this._imageURL=null;this._minFilter="linear";this._magFilter="linear";this._wrapS="clampToEdge";this._wrapT="clampToEdge";this._isDepth=false;this._depthMode="luminance";
this._depthCompareMode="compareRToTexture";this._depthCompareFunc="lequal";this._flipY=true;this._width=1;this._height=1;this._internalFormat="alpha";this._sourceFormat="alpha";this._sourceType="unsignedByte";};SceneJS.TextureLayer.STATE_INITIAL=0;SceneJS.TextureLayer.STATE_LOADING=1;SceneJS.TextureLayer.STATE_LOADED=2;
SceneJS.TextureLayer.STATE_ERROR=-1;SceneJS.Texture=SceneJS.createNodeType("texture");SceneJS.Texture.prototype._init=function(params){this._layers=[];this._state=SceneJS.Texture.STATE_INITIAL;if(params.layers){for(var i=0;i<params.layers.length;i++){var layerParam=params.layers[i];if(!layerParam.uri&&!layerParam.imageBuf){throw new SceneJS.errors.NodeConfigExpectedException("SceneJS.Texture.layers["+i+"] has no uri or imageBuf specified");
}if(layerParam.applyFrom){if(layerParam.applyFrom!="uv"&&layerParam.applyFrom!="uv2"&&layerParam.applyFrom!="normal"&&layerParam.applyFrom!="geometry"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Texture.layers["+i+"].applyFrom value is unsupported - "+"should be either 'uv', 'uv2', 'normal' or 'geometry'"));
}}if(layerParam.applyTo){if(layerParam.applyTo!="baseColor"&&layerParam.applyTo!="specular"&&layerParam.applyTo!="emit"&&layerParam.applyTo!="normals"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.Texture.layers["+i+"].applyTo value is unsupported - "+"should be either 'baseColor', 'specular' or 'normals'"));
}}this._layers.push({state:SceneJS.TextureLayer.STATE_INITIAL,process:null,image:null,creationParams:layerParam,texture:null,applyFrom:layerParam.applyFrom||"uv",applyTo:layerParam.applyTo||"baseColor",blendMode:layerParam.blendMode||"add",scale:layerParam.scale,translate:layerParam.translate,rotate:layerParam.rotate,rebuildMatrix:true});
}}};SceneJS.Texture.STATE_INITIAL="init";SceneJS.Texture.STATE_LOADING="loading";SceneJS.Texture.STATE_LOADED="loaded";SceneJS.Texture.STATE_ERROR="error";SceneJS.Texture.prototype.getState=function(){return this._state;};SceneJS.Texture.prototype._render=function(traversalContext){var countLayersReady=0;
var layer;for(var i=0;i<this._layers.length;i++){layer=this._layers[i];if(layer.state==SceneJS.TextureLayer.STATE_LOADED){if(layer.creationParams.uri){if(!SceneJS._textureModule.textureExists(layer.texture)){layer.state=SceneJS.TextureLayer.STATE_INITIAL;}}else{if(layer.creationParams.imageBuf){if(!SceneJS._imageBufModule.getImageBuffer(layer.creationParams.imageBuf)){layer.state=SceneJS.TextureLayer.STATE_INITIAL;
}}}}switch(layer.state){case SceneJS.TextureLayer.STATE_LOADED:countLayersReady++;this._rebuildTextureMatrix(layer);break;case SceneJS.TextureLayer.STATE_INITIAL:layer.state=SceneJS.TextureLayer.STATE_LOADING;if(layer.creationParams.uri){var self=this;(function(l){SceneJS._textureModule.createTexture(l.creationParams,function(texture){l.texture=texture;
l.state=SceneJS.TextureLayer.STATE_LOADED;SceneJS._needFrame=true;},function(){l.state=SceneJS.TextureLayer.STATE_ERROR;var message="SceneJS.texture image load failed: "+l.creationParams.uri;SceneJS._loggingModule.warn(message);if(self._state!=SceneJS.Texture.STATE_ERROR){self._changeState(SceneJS.Texture.STATE_ERROR,{exception:new SceneJS.errors.Exception("SceneJS.Exception - "+message)});
}},function(){SceneJS._loggingModule.warn("SceneJS.texture image load aborted: "+l.creationParams.uri);l.state=SceneJS.TextureLayer.STATE_ERROR;if(self._state!=SceneJS.Texture.STATE_ERROR){self._changeState(SceneJS.Texture.STATE_ERROR,{exception:new SceneJS.errors.Exception("SceneJS.Exception - texture image load stopped - user aborted it?")});
}});}).call(this,layer);}break;case SceneJS.TextureLayer.STATE_LOADING:if(layer.creationParams.imageBuf){var imageBuf=SceneJS._imageBufModule.getImageBuffer(layer.creationParams.imageBuf);if(imageBuf&&imageBuf.isRendered()){var texture=SceneJS._imageBufModule.getTexture(layer.creationParams.imageBuf);
if(texture){layer.texture=texture;layer.state=SceneJS.TextureLayer.STATE_LOADED;}}}break;case SceneJS.TextureLayer.STATE_ERROR:break;}}if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);}else{if(countLayersReady==this._layers.length){SceneJS._textureModule.pushTexture(this._layers);
if(this._state!=SceneJS.Texture.STATE_ERROR&&this._state!=SceneJS.Texture.STATE_LOADED){this._changeState(SceneJS.Texture.STATE_LOADED);}SceneJS._loadStatusModule.status.numNodesLoaded++;this._renderNodes(traversalContext);SceneJS._textureModule.popTexture();}else{if(this._state!=SceneJS.Texture.STATE_ERROR&&this._state!=SceneJS.Texture.STATE_LOADING){this._changeState(SceneJS.Texture.STATE_LOADING);
}SceneJS._loadStatusModule.status.numNodesLoading++;this._renderNodes(traversalContext);}}};SceneJS.Texture.prototype._rebuildTextureMatrix=function(layer){if(layer.rebuildMatrix){if(layer.translate||layer.rotate||layer.scale){layer.matrix=SceneJS.Texture.prototype._getMatrix(layer.translate,layer.rotate,layer.scale);
layer.matrixAsArray=new Float32Array(layer.matrix);layer.rebuildMatrix=false;}}};SceneJS.Texture.prototype._getMatrix=function(translate,rotate,scale){var matrix=null;if(translate){matrix=SceneJS._math_translationMat4v([translate.x||0,translate.y||0,0]);}if(scale){var t=SceneJS._math_scalingMat4v([scale.x||1,scale.y||1,1]);
matrix=matrix?SceneJS._math_mulMat4(matrix,t):t;}if(rotate){var t=SceneJS._math_rotationMat4v(rotate*0.0174532925,[0,0,1]);matrix=matrix?SceneJS._math_mulMat4(matrix,t):t;}return matrix;};SceneJS.Texture.prototype.setLayer=function(cfg){if(cfg.index==undefined||cfg.index==null){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Invalid SceneJS.Texture#setLayerConfig argument: index null or undefined"));
}if(cfg.index<0||cfg.index>=this._layers.length){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Invalid SceneJS.Texture#setLayer argument: index out of range ("+this._layers.length+" layers defined)"));}var layer=this._layers[cfg.index];cfg=cfg.cfg||{};if(cfg.translate){this.setTranslate(layer,cfg.translate);
}if(cfg.scale){this.setScale(layer,cfg.scale);}if(cfg.rotate){this.setRotate(layer,cfg.rotate);}this._setDirty();};SceneJS.Texture.prototype.setTranslate=function(layer,xy){if(!layer.translate){layer.translate={x:0,y:0};}if(xy.x!=undefined){layer.translate.x=xy.x;}if(xy.y!=undefined){layer.translate.y=xy.y;
}layer.rebuildMatrix=true;};SceneJS.Texture.prototype.setScale=function(layer,xy){if(!layer.scale){layer.scale={x:1,y:1};}if(xy.x!=undefined){layer.scale.x=xy.x;}if(xy.y!=undefined){layer.scale.y=xy.y;}layer.rebuildMatrix=true;};SceneJS.Texture.prototype.setRotate=function(layer,angle){if(!layer.rotate){layer.rotate=angle;
}layer.rotate=angle;layer.rebuildMatrix=true;};SceneJS.Texture.prototype._changeState=function(newState,params){params=params||{};params.oldState=this._state;params.newState=newState;this._state=newState;if(this._listeners["state-changed"]){this._fireEvent("state-changed",params);}};SceneJS.Texture.prototype.queryState=function(){return this._state;
};SceneJS._fogModule=new (function(){var fogStack;var dirty;function colourToArray(v,fallback){return v?[v.r!=undefined?v.r:fallback[0],v.g!=undefined?v.g:fallback[1],v.b!=undefined?v.b:fallback[2]]:fallback;}function _createFog(f){f=f||{};if(f.mode&&(f.mode!="disabled"&&f.mode!="constant"&&f.mode!="exp"&&f.mode!="exp2"&&f.mode!="linear")){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.fog node has a mode of unsupported type - should be 'disabled', 'constant', 'exp', 'exp2' or 'linear'"));
}if(f.mode=="disabled"){return{mode:f.mode||"exp"};}else{return{mode:f.mode||"disabled",color:colourToArray(f.color,[0.5,0.5,0.5]),density:f.density||1,start:f.start||0,end:f.end||0};}}SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){fogStack=[];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.addFog(fogStack.length>0?fogStack[fogStack.length-1]:null);dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.pushFog=function(f){fogStack.push(_createFog(f));
dirty=true;};this.popFog=function(){fogStack.pop();dirty=true;};})();SceneJS.Fog=SceneJS.createNodeType("fog");SceneJS.Fog.prototype._init=function(params){this.setMode(params.mode);this.setColor(params.color);this.setDensity(params.density);this.setStart(params.start);this.setEnd(params.end);};SceneJS.Fog.prototype.setMode=function(mode){mode=mode||"disabled";
if(mode!="disabled"&&mode!="constant"&&mode!="exp"&&mode!="exp2"&&mode!="linear"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.fog has a mode of unsupported type: '"+mode+" - should be 'disabled', 'constant', 'exp', 'exp2' or 'linear'"));}this._attr.mode=mode;
};SceneJS.Fog.prototype.getMode=function(){return this._attr.mode;};SceneJS.Fog.prototype.setColor=function(color){color=color||{};this._attr.color={r:color.r!=undefined?color.r:0.5,g:color.g!=undefined?color.g:0.5,b:color.b!=undefined?color.b:0.5};};SceneJS.Fog.prototype.getColor=function(){return{r:this._attr.color.r,g:this._attr.color.g,b:this._attr.color.b};
};SceneJS.Fog.prototype.setDensity=function(density){this._attr.density=density||1;};SceneJS.Fog.prototype.getDensity=function(){return this._attr.density;};SceneJS.Fog.prototype.setStart=function(start){this._attr.start=start||0;};SceneJS.Fog.prototype.getStart=function(){return this._attr.start;};SceneJS.Fog.prototype.setEnd=function(end){this._attr.end=end||0;
};SceneJS.Fog.prototype.getEnd=function(){return this._attr.end;};SceneJS.Fog.prototype.getAttributes=function(){return{mode:this._attr.mode,color:{r:this._attr.color.r,g:this._attr.color.g,b:this._attr.color.b},density:this._attr.density,start:this._attr.start,end:this._attr.end};};SceneJS.Fog.prototype._render=function(traversalContext){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);
}else{SceneJS._fogModule.pushFog(this._attr);this._renderNodes(traversalContext);SceneJS._fogModule.popFog();}};SceneJS._clipModule=new (function(){var clipStack;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){clipStack=[];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){if(clipStack.length>0){SceneJS._shaderModule.addClips(clipStack.slice(0));}dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.pushClip=function(clip){clipStack.push(clip);
dirty=true;};this.popClip=function(){clipStack.pop();dirty=true;};})();SceneJS.Clip=SceneJS.createNodeType("clip");SceneJS.Clip.prototype._init=function(params){this.setMode(params.mode);this.setA(params.a);this.setB(params.b);this.setC(params.c);};SceneJS.Clip.prototype.setMode=function(mode){mode=mode||"disabled";
if(mode!="disabled"&&mode!="inside"&&mode!="outside"){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("SceneJS.clip has a mode of unsupported type: '"+mode+" - should be 'disabled', 'inside' or 'outside'"));}this._attr.mode=mode;this._memoLevel=0;};SceneJS.Clip.prototype.getMode=function(){return this._attr.mode;
};SceneJS.Clip.prototype.setABC=function(abc){abc=abc||{};this.setA(abc.a);this.setB(abc.b);this.setC(abc.c);};SceneJS.Clip.prototype.getABC=function(){return{a:this.getA(),b:this.getB(),c:this.getC()};};SceneJS.Clip.prototype.setA=function(a){a=a||{};this._attr.a=[a.x!=undefined?a.x:0,a.y!=undefined?a.y:0,a.z!=undefined?a.z:0,1];
this._memoLevel=0;};SceneJS.Clip.prototype.getA=function(){return{x:this._attr.a[0],y:this._attr.a[1],z:this._attr.a[2]};};SceneJS.Clip.prototype.setB=function(b){b=b||{};this._attr.b=[b.x!=undefined?b.x:0,b.y!=undefined?b.y:0,b.z!=undefined?b.z:0,1];this._memoLevel=0;};SceneJS.Clip.prototype.getB=function(){return{x:this._attr.b[0],y:this._attr.b[1],z:this._attr.b[2]};
};SceneJS.Clip.prototype.setC=function(c){c=c||{};this._attr.c=[c.x!=undefined?c.x:0,c.y!=undefined?c.y:0,c.z!=undefined?c.z:0,1];this._memoLevel=0;};SceneJS.Clip.prototype.getC=function(){return{x:this._attr.c[0],y:this._attr.c[1],z:this._attr.c[2]};};SceneJS.Clip.prototype.getAttributes=function(){return{mode:this._attr.mode,a:this.getA(),b:this.getB(),c:this.getC()};
};SceneJS.Clip.prototype._render=function(traversalContext){if(this._memoLevel==0){this._makePlane();}if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){this._renderNodes(traversalContext);}else{SceneJS._clipModule.pushClip(this._attr);this._renderNodes(traversalContext);SceneJS._clipModule.popClip();
}};SceneJS.Clip.prototype._makePlane=function(){var modelMat=SceneJS._modelTransformModule.getTransform().matrix;var viewMat=SceneJS._viewTransformModule.getTransform().matrix;var a=SceneJS._math_transformPoint3(viewMat,SceneJS._math_transformPoint3(modelMat,this._attr.a));var b=SceneJS._math_transformPoint3(viewMat,SceneJS._math_transformPoint3(modelMat,this._attr.b));
var c=SceneJS._math_transformPoint3(viewMat,SceneJS._math_transformPoint3(modelMat,this._attr.c));var q=[b[0]-a[0],b[1]-a[1],b[2]-a[2]];var v=[b[0]-c[0],b[1]-c[1],b[2]-c[2]];this._attr.normal=SceneJS._math_normalizeVec3(SceneJS._math_cross3Vec3(q,v));this._attr.dist=SceneJS._math_dotVector3(this._attr.normal,[a[0],a[1],a[2]]);
};SceneJS._deformModule=new (function(){var viewMat;var modelMat;var deformStack=new Array(255);var stackLen=0;var dirty;var self=this;SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){deformStack=[];stackLen=0;dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.VIEW_TRANSFORM_UPDATED,function(params){viewMat=params.matrix;
});SceneJS._eventModule.addListener(SceneJS._eventModule.MODEL_TRANSFORM_UPDATED,function(params){modelMat=params.matrix;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.addDeform(stackLen>0?deformStack[stackLen-1]:null);dirty=false;
}});this.pushDeform=function(deform){var d={verts:[]};var vert;for(var i=0,len=deform.verts.length;i<len;i++){vert=deform.verts[i];d.verts.push({pos:SceneJS._math_transformPoint3(viewMat,SceneJS._math_transformPoint3(modelMat,[vert.x,vert.y,vert.z])),mode:vert.mode,weight:vert.weight});}deformStack[stackLen++]=d;
dirty=true;};this.popDeform=function(){stackLen--;dirty=true;};})();SceneJS.Deform=SceneJS.createNodeType("deform");SceneJS.Deform.prototype._init=function(params){this.setVerts(params.verts);};SceneJS.Deform.prototype.setVerts=function(verts){verts=verts||[];var tmpVerts=[];var vert;for(var i=0,len=verts.length;
i<len;i++){vert=verts[i];if(vert.mode&&(vert.mode!="linear"&&vert.mode!="exp")){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't set deform vertex "+i+" - unsupported mode - should be 'linear' or 'exp'"));}tmpVerts.push({x:vert.x||0,y:vert.y||0,z:vert.z||0,mode:vert.mode||"linear",weight:vert.weight||0});
}this._attr.verts=tmpVerts;};SceneJS.Deform.prototype.setVert=function(vert){vert=vert||{};if(vert.index==undefined){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't set deform vertex - attribute missing: 'index'"));}if(vert.index<0||vert.index>=this._attr.verts.length){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't set deform vertex - index "+vert.indx+" out of range of existing vertices [0-"+this._attr.verts.length+"]"));
}if(vert.mode&&(vert.mode!="linear"&&vert.mode!="exp")){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't set deform vertex - unsupported mode - should be 'linear' or 'exp'"));}var temp=this._attr.verts[vert.index];this._attr.verts[vert.index]={x:vert.x!=undefined?vert.x:temp.x,y:vert.y!=undefined?vert.y:temp.y,z:vert.z!=undefined?vert.z:temp.z,mode:vert.mode!=undefined?vert.mode:temp.mode,weight:vert.weight!=undefined?vert.weight:temp.weight};
};SceneJS.Deform.prototype.getVert=function(index){if(index==undefined){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't get deform vertex - attribute missing: 'index'"));}if(index<0||index>this._attr.verts.length){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't get deform vertex - index out of range of existing vertices"));
}return SceneJS._shallowClone(this._attr.verts[index]);};SceneJS.Deform.prototype.addVert=function(vert){vert=vert||{};if(vert.mode&&(vert.mode!="linear"&&vert.mode!="exp")){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't add deform vertex - unsupported mode - should be 'linear' or 'exp'"));
}var temp={x:vert.x||0,y:vert.y||0,z:vert.z||0,mode:vert.mode||"linear",weight:vert.weight||0};if(vert.index){this._attr.verts.splice(vert.index,0,temp);}else{this._attr.verts.push(vert);}};SceneJS.Deform.prototype.removeVert=function(index){if(index==undefined){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't remove deform vertex - attribute undefined: 'index'"));
}if(index<0||index>this._attr.verts.length){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("Can't remove deform vertex - index out of range of existing vertices"));}this._attr.verts.splice(index,1);};SceneJS.Deform.prototype._render=function(traversalContext){SceneJS._deformModule.pushDeform(this._attr);
this._renderNodes(traversalContext);SceneJS._deformModule.popDeform();};SceneJS._morphGeometryModule=new (function(){var time=(new Date()).getTime();var canvas;var morphMaps={};var currentMorphMap=null;var morphStack=new Array(100);var stackLen=0;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.TIME_UPDATED,function(t){time=t;
});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(){canvas=null;currentMorphMap=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_ACTIVATED,function(c){if(!morphMaps[c.canvasId]){morphMaps[c.canvasId]={};}canvas=c;currentMorphMap=morphMaps[c.canvasId];
stackLen=0;stackLen=0;});SceneJS._eventModule.addListener(SceneJS._eventModule.CANVAS_DEACTIVATED,function(){canvas=null;currentMorphMap=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){if(stackLen==0){SceneJS._shaderModule.addMorph(null);
}else{var morph=morphStack[stackLen-1];var target1=morph.targets[0];var target2=morph.targets[1];SceneJS._shaderModule.addMorph({factor:morph.factor,target1:target1,target2:target2});}dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){for(var canvasId in morphMaps){if(morphMaps.hasOwnProperty(canvasId)){var morphMap=morphMaps[canvasId];
for(var resource in morphMap){if(morphMap.hasOwnProperty(resource)){var morph=morphMap[resource];destroyMorph(morph);}}}}canvas=null;morphMaps={};currentMorphMap=null;stackLen=0;});function destroyMorph(morph){if(document.getElementById(morph.canvas.canvasId)){var target;for(var i=0,len=morph.targets.length;
i<len;i++){target=morph.targets[i];if(target.vertexBuf){target.vertexBuf.destroy();}if(target.normalBuf){target.normalBuf.destroy();}if(target.uvBuf){target.uvBuf.destroy();}if(target.uvBuf2){target.uvBuf2.destroy();}}}var morphMap=morphMaps[morph.canvas.canvasId];if(morphMap){morphMap[morph.resource]=null;
}}SceneJS._memoryModule.registerEvictor(function(){var earliest=time;var evictee;for(var canvasId in morphMaps){if(morphMaps.hasOwnProperty(canvasId)){var morphMap=morphMaps[canvasId];if(morphMap){for(var resource in morphMap){if(morphMap.hasOwnProperty(resource)){var morph=morphMap[resource];if(morph){if(morph.lastUsed<earliest&&document.getElementById(morph.canvas.canvasId)){evictee=morph;
earliest=morph.lastUsed;}}}}}}}if(evictee){SceneJS._loggingModule.warn("Evicting morph from memory: "+evictee.resource);destroyMorph(evictee);return true;}return false;});function createArrayBuffer(description,context,bufType,values,numItems,itemSize,usage){var buf;SceneJS._memoryModule.allocate(context,description,function(){buf=new SceneJS._webgl_ArrayBuffer(context,bufType,values,numItems,itemSize,usage);
});return buf;}this.testMorphGeometryExists=function(resource){return currentMorphMap[resource]?true:false;};this.createMorphGeometry=function(resource,attr){if(!resource){resource=SceneJS._createKeyForMap(currentMorphMap,"m");}var context=canvas.context;var morph={resource:resource,lastUsed:time,keys:attr.keys,instant:attr.instant,targets:[]};
try{var usage=context.STATIC_DRAW;var target;var newTarget;for(var i=0,len=attr.targets.length;i<len;i++){target=attr.targets[i];newTarget={};morph.targets.push(newTarget);if(target.positions&&target.positions.length>0){newTarget.vertexBuf=createArrayBuffer("morphGeometry vertex buffer",context,context.ARRAY_BUFFER,new Float32Array(target.positions),target.positions.length,3,usage);
}if(target.normals&&target.normals.length>0){newTarget.normalBuf=createArrayBuffer("morphGeometry normal buffer",context,context.ARRAY_BUFFER,new Float32Array(target.normals),target.normals.length,3,usage);}if(target.uv&&target.uv.length>0){newTarget.uvBuf=createArrayBuffer("morphGeometry UV buffer",context,context.ARRAY_BUFFER,new Float32Array(target.uv),target.uv.length,2,usage);
}if(target.uv2&&target.uv2.length>0){newTarget.uvBuf2=createArrayBuffer("morphGeometry UV2 buffer",context,context.ARRAY_BUFFER,new Float32Array(target.uv2),target.uv2.length,2,usage);}}currentMorphMap[resource]=morph;return resource;}catch(e){for(var i=0,len=morph.targets.length;i<len;i++){target=morph.targets[i];
if(target.vertexBuf){target.vertexBuf.destroy();}if(target.normalBuf){target.normalBuf.destroy();}if(target.uvBuf){target.uvBuf.destroy();}if(target.uvBuf2){target.uvBuf2.destroy();}}throw e;}};this.pushMorphGeometry=function(resource,factor){var morph=currentMorphMap[resource];morph.lastUsed=time;morph.factor=factor;
morphStack[stackLen++]=morph;dirty=true;};this.popMorphGeometry=function(){stackLen--;dirty=true;};})();SceneJS.MorphGeometry=SceneJS.createNodeType("morphGeometry");SceneJS.MorphGeometry.prototype._init=function(params){var targets=params.targets||[];if(targets.length<2){throw SceneJS._errorModule.fatalError(new SceneJS.errors.InvalidNodeConfigException("morphGeometry node should have at least two targets"));
}var positions;var normals;var uv;var uv2;var target;for(var i=0,len=targets.length;i<len;i++){target=targets[i];if(!positions&&target.positions){positions=target.positions.slice(0);}if(!normals&&target.normals){normals=target.normals.slice(0);}if(!uv&&target.uv){uv=target.uv.slice(0);}if(!uv2&&target.uv2){uv2=target.uv2.slice(0);
}}for(var i=0,len=targets.length;i<len;i++){target=targets[i];if(!target.positions){target.positions=positions;}if(!target.normals){target.normals=normals;}if(!target.uv){target.uv=uv;}if(!target.uv2){target.uv2=uv2;}}this._attr.targets=targets;this._attr.factor=params.factor||0;};SceneJS.MorphGeometry.prototype.setFactor=function(factor){this._attr.factor=factor||0;
};SceneJS.MorphGeometry.prototype.getFactor=function(){return this._attr.factor;};SceneJS.MorphGeometry.prototype._render=function(traversalContext){if(this._handle){if(!SceneJS._morphGeometryModule.testMorphGeometryExists(this._handle)){this._handle=null;}}if(!this._handle){this._handle=SceneJS._morphGeometryModule.createMorphGeometry(this._resource,this._attr);
}SceneJS._morphGeometryModule.pushMorphGeometry(this._handle,this._attr.factor);this._renderNodes(traversalContext);SceneJS._morphGeometryModule.popMorphGeometry();};SceneJS._pickModule=new (function(){var scenePickBufs={};var boundPickBuf=null;var color={r:0,g:0,b:0};var pickX=null;var pickY=null;var debugCfg=null;
var nodeIndex=0;var pickedNodeIndex=0;var nodeLookup=[];var nodeStack=[];SceneJS._eventModule.addListener(SceneJS._eventModule.INIT,function(){SceneJS._traversalMode=SceneJS._TRAVERSAL_MODE_RENDER;debugCfg=SceneJS._debugModule.getConfigs("picking");scenePickBufs={};boundPickBuf=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.RESET,function(){SceneJS._traversalMode=SceneJS._TRAVERSAL_MODE_RENDER;
});this.pick=function(x,y){if(debugCfg.logTrace){SceneJS._loggingModule.info("Picking at ("+x+", "+y+")");}SceneJS._traversalMode=SceneJS._TRAVERSAL_MODE_PICKING;pickX=x;pickY=y;color={r:0,g:0,b:0};nodeIndex=0;nodeLookup=[];nodeStack=[];};SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(e){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){if(!scenePickBufs[e.sceneId]){scenePickBufs[e.sceneId]=createPickBuffer(e.canvas);
}bindPickBuffer(scenePickBufs[e.sceneId]);}});function createPickBuffer(canvas){var gl=canvas.context;var width=canvas.canvas.width;var height=canvas.canvas.height;var pickBuf={canvas:canvas,frameBuf:gl.createFramebuffer(),renderBuf:gl.createRenderbuffer(),texture:gl.createTexture()};gl.bindFramebuffer(gl.FRAMEBUFFER,pickBuf.frameBuf);
gl.bindTexture(gl.TEXTURE_2D,pickBuf.texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);
try{gl.texImage2D(gl.TEXTURE_2D,0,gl.RGB,width,height,0,gl.RGB,gl.UNSIGNED_BYTE,null);}catch(exception){var textureStorage=new WebGLUnsignedByteArray(width*height*3);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGB,width,height,0,gl.RGB,gl.UNSIGNED_BYTE,textureStorage);}gl.bindRenderbuffer(gl.RENDERBUFFER,pickBuf.renderBuf);
gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_COMPONENT16,width,height);gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,pickBuf.texture,0);gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.RENDERBUFFER,pickBuf.renderBuf);gl.bindTexture(gl.TEXTURE_2D,null);gl.bindRenderbuffer(gl.RENDERBUFFER,null);
gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.bindFramebuffer(gl.FRAMEBUFFER,pickBuf.frameBuf);if(!gl.isFramebuffer(pickBuf.frameBuf)){throw ("Invalid framebuffer");}var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);switch(status){case gl.FRAMEBUFFER_COMPLETE:break;case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");case gl.FRAMEBUFFER_UNSUPPORTED:throw ("Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED");
default:throw ("Incomplete framebuffer: "+status);}return pickBuf;}function bindPickBuffer(pickBuf){if(debugCfg.logTrace){SceneJS._loggingModule.info("Binding pick buffer");}var context=pickBuf.canvas.context;context.bindFramebuffer(context.FRAMEBUFFER,pickBuf.frameBuf);context.clear(context.COLOR_BUFFER_BIT|context.DEPTH_BUFFER_BIT);
context.disable(context.BLEND);boundPickBuf=pickBuf;}this.pushNode=function(node){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&SceneJS._flagsModule.flags.picking){if(node.hasListener("picked")){nodeStack.push(node);nodeLookup.push(node);nodeIndex++;var b=nodeIndex>>16&255;var g=nodeIndex>>8&255;
var r=nodeIndex&255;color.g=g/255;color.r=r/255;color.b=b/255;}}};this.popNode=function(node){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&SceneJS._flagsModule.flags.picking){if(nodeStack.length>0&&nodeStack[nodeStack.length-1].getID()==node.getID()){nodeStack.pop();if(nodeStack.length==0){color.g=1;
color.r=1;color.b=1;}}}};SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING&&SceneJS._flagsModule.flags.picking){SceneJS._eventModule.fireEvent(SceneJS._eventModule.PICK_COLOR_EXPORTED,{pickColor:[color.r,color.g,color.b]});
}});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERED,function(){if(SceneJS._traversalMode==SceneJS._TRAVERSAL_MODE_PICKING){try{readPickBuffer();unbindPickBuffer();}finally{SceneJS._traversalMode=SceneJS._TRAVERSAL_MODE_RENDER;}}});function readPickBuffer(){var context=boundPickBuf.canvas.context;
var canvas=boundPickBuf.canvas.canvas;var x=pickX;var y=canvas.height-pickY;var pix=new Uint8Array(4);context.readPixels(x,y,1,1,context.RGBA,context.UNSIGNED_BYTE,pix);if(debugCfg.logTrace){SceneJS._loggingModule.info("Reading pick buffer - picked pixel("+x+", "+y+") = {r:"+pix[0]+", g:"+pix[1]+", b:"+pix[2]+"}");
}pickedNodeIndex=pix[0]+pix[1]*256+pix[2]*65536;if(pickedNodeIndex>=1){var node=nodeLookup[pickedNodeIndex-1];if(node){node._fireEvent("picked",{canvasX:pickX,canvasY:pickY});}}}function unbindPickBuffer(){if(debugCfg.logTrace){SceneJS._loggingModule.info("Unbinding pick buffer");}boundPickBuf.canvas.context.bindFramebuffer(boundPickBuf.canvas.context.FRAMEBUFFER,null);
boundPickBuf=null;}SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_DESTROYED,function(){if(debugCfg.logTrace){SceneJS._loggingModule.info("Destroying pick buffer");}});})();SceneJS.ImageBuf=SceneJS.createNodeType("imageBuf");SceneJS.ImageBuf.prototype._init=function(params){};SceneJS.ImageBuf.prototype._render=function(traversalContext){if(!this._bufId){this._bufId=SceneJS._imageBufModule.createImageBuffer(this._attr.id);
}SceneJS._imageBufModule.pushImageBuffer(this._bufId);this._renderNodes(traversalContext);SceneJS._imageBufModule.popImageBuffer();};SceneJS.ImageBuf.prototype._destroy=function(){if(this._bufId){SceneJS._imageBufModule.destroyImageBuffer(this._bufId);this._bufId=null;}};SceneJS._imageBufModule=new (function(){var sceneBufs={};
var currentSceneBufs=null;var bufStack=[];var boundBuf=null;var canvas;var dirty;SceneJS._eventModule.addListener(SceneJS._eventModule.INIT,function(){sceneBufs={};boundBuf=null;});SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_RENDERING,function(e){canvas=e.canvas;currentSceneBufs=sceneBufs[e.sceneId];
if(!currentSceneBufs){currentSceneBufs=sceneBufs[e.sceneId]={};}bufStack=[];dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_ACTIVATED,function(){dirty=true;});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_RENDERING,function(){if(dirty){SceneJS._shaderModule.addImageBuf((bufStack.length>0)?bufStack[bufStack.length-1]:null);
dirty=false;}});SceneJS._eventModule.addListener(SceneJS._eventModule.SHADER_DEACTIVATED,function(){dirty=true;});this.createImageBuffer=function(id){var bufId=id;var gl=canvas.context;var width=canvas.canvas.width;var height=canvas.canvas.height;var frameBuf=gl.createFramebuffer();var renderBuf=gl.createRenderbuffer();
var texture=gl.createTexture();var rendered=false;gl.bindFramebuffer(gl.FRAMEBUFFER,frameBuf);gl.bindTexture(gl.TEXTURE_2D,texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);try{gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width,height,0,gl.RGBA,gl.UNSIGNED_BYTE,null);}catch(exception){var textureStorage=new WebGLUnsignedByteArray(width*height*4);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width,height,0,gl.RGBA,gl.UNSIGNED_BYTE,textureStorage);
}gl.bindRenderbuffer(gl.RENDERBUFFER,renderBuf);gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_COMPONENT16,width,height);gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,texture,0);gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.RENDERBUFFER,renderBuf);gl.bindTexture(gl.TEXTURE_2D,null);
gl.bindRenderbuffer(gl.RENDERBUFFER,null);gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.bindFramebuffer(gl.FRAMEBUFFER,frameBuf);if(!gl.isFramebuffer(frameBuf)){throw ("Invalid framebuffer");}var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);switch(status){case gl.FRAMEBUFFER_COMPLETE:break;case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw ("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");case gl.FRAMEBUFFER_UNSUPPORTED:throw ("Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED");
default:throw ("Incomplete framebuffer: "+status);}var buf={id:bufId,bind:function(){gl.bindFramebuffer(gl.FRAMEBUFFER,frameBuf);gl.clearColor(0,0,0,1);gl.clearDepth(1);gl.enable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.depthRange(0,1);gl.disable(gl.SCISSOR_TEST);gl.disable(gl.BLEND);},unbind:function(){gl.bindFramebuffer(gl.FRAMEBUFFER,null);
gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);gl.bindRenderbuffer(gl.RENDERBUFFER,renderBuf);rendered=true;},isRendered:function(){return rendered;},getTexture:function(){return{bind:function(unit){gl.activeTexture(gl["TEXTURE"+unit]);gl.bindTexture(gl.TEXTURE_2D,texture);},unbind:function(unit){gl.activeTexture(gl["TEXTURE"+unit]);
gl.bindTexture(this.target,null);}};}};currentSceneBufs[bufId]=buf;return bufId;};this.pushImageBuffer=function(bufId){var buf=currentSceneBufs[bufId];if(!buf){throw"Image buffer not found: "+bufId;}bufStack.push(buf);dirty=true;};this.popImageBuffer=function(){bufStack.pop();dirty=true;};this.destroyImageBuffer=function(bufId){};
this.getImageBuffer=function(bufId){return currentSceneBufs[bufId];};this.getTexture=function(bufId){var buf=currentSceneBufs[bufId];return buf?buf.getTexture():null;};SceneJS._eventModule.addListener(SceneJS._eventModule.SCENE_DESTROYED,function(){});})();