-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyOSGLib.js
125 lines (95 loc) · 2.91 KB
/
myOSGLib.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
/*function getDefaultShaderProgram() {
var vertexshader = [
'#ifdef GL_ES',
'precision highp float;',
'#endif',
'attribute vec3 Vertex;',
'attribute vec4 Color;',
'uniform mat4 uModelViewMatrix;',
'uniform mat4 uProjectionMatrix;',
'',
'varying vec4 vColor;',
'',
'void main(void) {',
' gl_Position = uProjectionMatrix * (uModelViewMatrix * vec4(Vertex, 1.0));',
' vColor = Color;',
'}'
].join( '\n' );
var fragmentshader = [
'#ifdef GL_ES',
'precision highp float;',
'#endif',
'varying vec4 vColor;',
'void main(void) {',
'gl_FragColor = vColor;',
'}'
].join( '\n' );
return program123 = new osg.Program( new osg.Shader( 'VERTEX_SHADER', vertexshader ), new osg.Shader( 'FRAGMENT_SHADER', fragmentshader ) );
}*/
/*function objectInherit(base) {
function F() {}
F.prototype = base;
var obj = new F();
return obj;
}
var Switch = function () {
osg.Node.call( this );
};
Switch.prototype = objectInherit(osg.Node.prototype);
Switch.getChildIndex = function(child) {
for ( var i = 0, l = this.children.length; i < l; i++ ) {
if ( this.children[ i ] === child ) {
return i;
}
}
return -1;
};*/
//window.addEventListener("load", main ,true);
function objectInherit(base) {
function F() {}
F.prototype = base;
var obj = new F();
return obj;
}
var ee497 = {};
ee497.globalify = function() {
var Switch = function () {
osg.Node.call( this );
};
Switch.prototype = objectInherit(osg.Node.prototype);
Switch.prototype._values = [];
Switch.prototype.newChildDefaultValue=true;
Switch.prototype.traverse = function (visitor) {
var children = this.children;
for ( var i = 0, l = children.length; i < l; i++ ) {
var child = children[ i ];
if(this._values[i])
child.accept(visitor);
}
};
Switch.prototype.setNewChildDefaultValue = function(value) {
this.newChildDefaultValue = value;
};
Switch.prototype.addChild = function(child, childValue) {
var childPosition = this.children.length;
osg.Node.prototype.addChild.call(this, child);
this._values[childPosition] = childValue;
};
/*Switch.prototype.addChild = function(child) {
this.addChild(child, this.newChildDefaultValue);
};*/
Switch.prototype.getChildIndex = function(child) {
for ( var i = 0, l = this.children.length; i < l; i++ ) {
if ( this.children[ i ] === child ) {
return i;
}
}
return -1;
};
Switch.prototype.setChildValue = function(child, value) {
var pos = this.getChildIndex(child);
this._values[pos] = value;
//this.dirtyBound();
};
this.Switch = Switch;
}