Skip to content

Commit e4e9a9c

Browse files
author
Nikos M
committed
v.0.6.0
1 parent 0307db3 commit e4e9a9c

63 files changed

Lines changed: 2430 additions & 2831 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

beeld.config

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ tasks =[{}]
3333
./src/math/Matrix4.js
3434
./src/math/List.js
3535

36-
./src/core/VertexProxy.js
37-
./src/core/FaceProxy.js
38-
./src/core/MeshProxy.js
39-
./src/core/Modifier.js
40-
./src/core/Factory.js
36+
./src/core/Mesh.js
4137
./src/core/ModifierStack.js
4238

4339
# modifiers
@@ -54,34 +50,22 @@ tasks =[{}]
5450
./src/modifiers/Perlin.js
5551

5652
# Support for Three.js
57-
./src/plugins/Three/Vertex.js
58-
./src/plugins/Three/Mesh.js
59-
./src/plugins/Three/Library.js
53+
./src/plugins/Three/Three.js
6054

6155
# Support for OSG.js
62-
./src/plugins/OSG/Vertex.js
63-
./src/plugins/OSG/Mesh.js
64-
./src/plugins/OSG/Library.js
56+
./src/plugins/OSG/OSG.js
6557

6658
# Support for J3D
67-
./src/plugins/J3D/Vertex.js
68-
./src/plugins/J3D/Mesh.js
69-
./src/plugins/J3D/Library.js
59+
./src/plugins/J3D/J3D.js
7060

7161
# Support for CubicVR.js
72-
./src/plugins/CubicVR/Vertex.js
73-
./src/plugins/CubicVR/Mesh.js
74-
./src/plugins/CubicVR/Library.js
62+
./src/plugins/CubicVR/CubicVR.js
7563

7664
# Support for Copperlicht
77-
./src/plugins/Copperlicht/Vertex.js
78-
./src/plugins/Copperlicht/Mesh.js
79-
./src/plugins/Copperlicht/Library.js
65+
./src/plugins/Copperlicht/Copperlicht.js
8066

8167
# Support for Pre3D
82-
./src/plugins/Pre3D/Vertex.js
83-
./src/plugins/Pre3D/Mesh.js
84-
./src/plugins/Pre3D/Library.js
68+
./src/plugins/Pre3D/Pre3D.js
8569

8670
!tpl:umd-footer.tpl.js # include a umd-footer template
8771

@@ -97,7 +81,7 @@ tasks =[{}]
9781
"@@MODULE_NAME@@" = "MOD3"
9882
"@@MODULE_DEPENDENCIES@@" = "[ ['Classy'], ['./classy.js'] ]"
9983
"@@MODULE_ARGUMENTS@@" = "Classy"
100-
"@@VERSION@@" = "0.5.0"
84+
"@@VERSION@@" = "0.6.0"
10185
"@@DEPENDENCIES@@" = "@dependencies: Classy.js"
10286
"@@USE_STRICT@@" = '"use strict";'
10387

@@ -128,7 +112,7 @@ tasks =[{}]
128112
yui =[]
129113
--preserve-semi
130114
@
131-
115+
132116
@
133117

134118
out = ./build/mod3.min.js
@@ -155,11 +139,7 @@ tasks =[{}]
155139
./src/math/Matrix4.js
156140
./src/math/List.js
157141

158-
./src/core/VertexProxy.js
159-
./src/core/FaceProxy.js
160-
./src/core/MeshProxy.js
161-
./src/core/Modifier.js
162-
./src/core/Factory.js
142+
./src/core/Mesh.js
163143
./src/core/ModifierStack.js
164144

165145
# modifiers
@@ -176,9 +156,7 @@ tasks =[{}]
176156
./src/modifiers/Perlin.js
177157

178158
# Support for Three.js
179-
./src/plugins/Three/Vertex.js
180-
./src/plugins/Three/Mesh.js
181-
./src/plugins/Three/Library.js
159+
./src/plugins/Three/Three.js
182160

183161
!tpl:umd-footer.tpl.js # include a umd-footer template
184162

@@ -194,7 +172,7 @@ tasks =[{}]
194172
"@@MODULE_NAME@@" = "MOD3"
195173
"@@MODULE_DEPENDENCIES@@" = "[ ['Classy'], ['./classy.js'] ]"
196174
"@@MODULE_ARGUMENTS@@" = "Classy"
197-
"@@VERSION@@" = "0.5.0"
175+
"@@VERSION@@" = "0.6.0"
198176
"@@DEPENDENCIES@@" = "@dependencies: Classy.js"
199177
"@@USE_STRICT@@" = '"use strict";'
200178

build/MOD3.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/mod3.bundle.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Copperlicht/Bend.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252

5353
var mstack=new MOD3.ModifierStack(MOD3.LibraryCopperlicht,cubenode);
5454
var bend=new MOD3.Bend();
55-
bend.setAngle(0);
55+
bend.angle=0;
5656
bend.force=0;
5757
bend.offset=0.5;
5858
bend.switchAxes=true;
5959
bend.constraint=MOD3.ModConstant.LEFT;
6060
mstack.addModifier(bend);
6161
var tobj={angle:Math.PI/8,force:0.8};
6262
new TWEEN.Tween(tobj).to({force:-0.8},5000).onUpdate(function(){
63-
bend.setAngle(this.angle);
63+
bend.angle=this.angle;
6464
bend.force=this.force;
6565
mstack.apply();}).start();
6666

examples/Copperlicht/Bloat.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@
5252

5353
var mstack=new MOD3.ModifierStack(MOD3.LibraryCopperlicht,cubenode);
5454
var mod=new MOD3.Bloat();
55-
mod.setRadius(0);
55+
mod.radius=0;
5656
mstack.addModifier(mod);
5757
var tobj={radius:0};
5858
new TWEEN.Tween(tobj).to({radius:10},5000).onUpdate(function(){
59-
mod.setRadius(this.radius);
59+
mod.radius=this.radius;
6060
mstack.apply();}).start();
6161

6262
setInterval("TWEEN.update()",1000/30);

examples/CubicVR/Bend.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@
8383
var mstack=new MOD3.ModifierStack(MOD3.LibraryCubicVR, boxObject);
8484
// bend modifier
8585
var bend=new MOD3.Bend();
86-
bend.setAngle(0);
86+
bend.angle=0;
8787
bend.force=0;
8888
bend.offset=0.5;
8989
bend.switchAxes=true;
9090
bend.constraint=MOD3.ModConstant.LEFT;
9191
mstack.addModifier(bend);
9292
var tobj={angle:Math.PI/4,force:1.2};
9393
new TWEEN.Tween(tobj).to({force:-1.2},1000).onUpdate(function(){
94-
bend.setAngle(this.angle);
94+
bend.angle=this.angle;
9595
bend.force=this.force;
9696
mstack.apply();}).start();
9797

examples/CubicVR/Bloat.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282
// add a modifier stack
8383
var mstack=new MOD3.ModifierStack(MOD3.LibraryCubicVR, boxObject);
8484
var mod=new MOD3.Bloat();
85-
mod.setRadius(0);
85+
mod.radius=0;
8686
mstack.addModifier(mod);
8787
var tobj={radius:0};
8888
new TWEEN.Tween(tobj).to({radius:0.3},5000).onUpdate(function(){
89-
mod.setRadius(this.radius);
89+
mod.radius=this.radius;
9090
mstack.apply();}).start();
9191

9292
var time=0;

examples/J3D/bend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ registerDemo(function(engine) {
3232

3333
mstack = new MOD3.ModifierStack(MOD3.LibraryJ3D, cube);
3434
mod = new MOD3.Bend();
35-
mod.setAngle(0);
35+
mod.angle = 0;
3636
mod.force = 0;
3737
mod.offset = 0.1;
3838
mod.switchAxes = true;
@@ -43,7 +43,7 @@ registerDemo(function(engine) {
4343
new TWEEN.Tween(tobj)
4444
.to( { force: -1.2 }, 5000)
4545
.onUpdate(function(){
46-
mod.setAngle( this.angle );
46+
mod.angle = this.angle;
4747
mod.force = this.force;
4848
mstack.apply();
4949
})

examples/OSG/Bend.html

Lines changed: 84 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<!--<script type="text/javascript" src="./leap.js"></script>-->
1313
<script type="text/javascript" src="./OSG.js"></script>
1414
<script type="text/javascript" src="../../build/mod3.bundle.js"></script>
15+
<script type="text/javascript" src="../js/Tween.js"></script>
1516
</head>
1617

1718

@@ -31,53 +32,100 @@
3132
var osg = OSG.osg;
3233
var osgAnimation = OSG.osgAnimation;
3334
var osgViewer = OSG.osgViewer;
34-
var cube, mstack, mod;
35+
var cube, mstack, mod, rotate;
3536

3637
function SimpleUpdateCallback() {}
3738
SimpleUpdateCallback.prototype = {
38-
mod_angle: Math.PI/4,
39-
mod_force: 1.2,
4039
angle: 0,
41-
40+
4241
update: function ( node, nv ) {
4342
var t = nv.getFrameStamp().getSimulationTime();
4443
var dt = t - node._lastUpdate;
4544
if ( dt < 0 ) { return true; }
4645
node._lastUpdate = t;
4746

48-
// rotation
49-
/*var m = node.getMatrix();
50-
osg.Matrix.makeRotate( -this.angle, 0.0, 0.0, 1.0, m );
51-
osg.Matrix.setTrans( m, 0, 0, 0 );*/
52-
mod.setAngle(this.mod_angle);
53-
mod.force = this.mod_force;
54-
mstack.apply();
55-
this.angle += 0.1;
56-
this.mod_force -= 0.1;
47+
var m = rotate.getMatrix();
48+
osg.Matrix.makeRotate( -this.angle, 0.0, 1.0, 0.0, m );
49+
osg.Matrix.setTrans( m, 0, 0, 10 );
50+
this.angle += 0.02;
51+
mod.force = 1.2;
52+
mstack.apply( );
5753
return true;
5854
}
5955
};
6056

57+
function createBox( cx, cy, cz, wx, wy, wz, hx, hy, hz, res1, res2 )
58+
{
59+
cx = cx !== undefined ? cx : -0.5;
60+
cy = cy !== undefined ? cy : -0.5;
61+
cz = cz !== undefined ? cz : 0.0;
62+
63+
wx = wx !== undefined ? wx : 1.0;
64+
wy = wy !== undefined ? wy : 0.0;
65+
wz = wz !== undefined ? wz : 0.0;
66+
67+
hx = hx !== undefined ? hx : 0.0;
68+
hy = hy !== undefined ? hy : 1.0;
69+
hz = hz !== undefined ? hz : 0.0;
70+
71+
res1 = res1 !== undefined ? res1 : 5;
72+
res2 = res2 !== undefined ? res2 : res1;
73+
res1 += 2;
74+
res2 += 2;
75+
76+
var g = new osg.Geometry();
77+
var vertices = new Float32Array( ( res1 /*+ res2*/ ) * 2 * 3 );
78+
//var uv = new Float32Array( ( res1 + res2 ) * 2 * 2 );
79+
//var normal = new Float32Array( vertices.length );
80+
var i = 0;
81+
var j = 0, k;
82+
var sx = wx / ( res1 - 1 );
83+
var sy = wy / ( res1 - 1 );
84+
var sz = wz / ( res1 - 1 );
85+
var ux = cx + wx + hx;
86+
var uy = cy + wy + hy;
87+
var uz = cz + wz + hz;
88+
for ( i = 0; i < res1; ++i ) {
89+
j = i * 6; k = i * 4;
90+
vertices[ j ] = cx + sx * i;
91+
vertices[ j + 1 ] = cy + sy * i;
92+
vertices[ j + 2 ] = cz + sz * i;
93+
vertices[ j + 3 ] = ux - sx * ( res1 - i - 1 );
94+
vertices[ j + 4 ] = uy - sy * ( res1 - i - 1 );
95+
vertices[ j + 5 ] = uz - sz * ( res1 - i - 1 );
96+
}
97+
/*sx = hx / ( res2 - 1 );
98+
sy = hy / ( res2 - 1 );
99+
sz = hz / ( res2 - 1 );
100+
for ( i = 0; i < res2; ++i ) {
101+
j = ( res1 + i ) * 6;
102+
vertices[ j ] = cx + sx * i;
103+
vertices[ j + 1 ] = cy + sy * i;
104+
vertices[ j + 2 ] = cz + sz * i;
105+
vertices[ j + 3 ] = ux - sx * ( res2 - i - 1 );
106+
vertices[ j + 4 ] = uy - sy * ( res2 - i - 1 );
107+
vertices[ j + 5 ] = uz - sz * ( res2 - i - 1 );
108+
}*/
109+
g.getAttributes().Vertex = new osg.BufferArray( osg.BufferArray.ARRAY_BUFFER, vertices, 3 );
110+
var primitive = new osg.DrawArrays( osg.PrimitiveSet.LINES, 0, ( res1 /*+ res2*/ ) * 2 );
111+
g.getPrimitives().push( primitive );
112+
return g;
113+
}
114+
61115
function createScene()
62116
{
63117
var root = new osg.Node();
64-
65-
cube = osg.createTexturedBoxGeometry( 0, 0, 0, 20, 20, 2 );
66-
// attache updatecallback function to cube
67-
var cb = new SimpleUpdateCallback();
68-
cube.addUpdateCallback( cb );
118+
cube = createBox( -5, -5, 0.0, 10.0, 0.0, 0.0, 0.0, 10.0, 0, 100, 5 );
119+
cube.addUpdateCallback( new SimpleUpdateCallback() );
69120
root.addChild( cube );
70-
71121
mstack = new MOD3.ModifierStack( MOD3.LibraryOSG, cube );
72-
73122
mod = new MOD3.Bend( );
74-
mod.setAngle( 0 );
123+
mod.angle = Math.PI/8;
75124
mod.force = 0;
76125
mod.offset = 0.5;
77-
mod.switchAxes = true;
126+
//mod.switchAxes = true;
78127
mod.constraint = MOD3.ModConstant.LEFT;
79128
mstack.addModifier( mod );
80-
81129
return root;
82130
}
83131

@@ -92,15 +140,23 @@
92140
alpha: true
93141
} );
94142
viewer.init();
95-
var rotate = new osg.MatrixTransform();
96-
rotate.addChild( createScene() );
97-
viewer.getCamera().setClearColor( [ 0.0, 0.0, 0.0, 0.0 ] );
143+
var scene = createScene();
144+
rotate = new osg.MatrixTransform();
145+
rotate.addChild( scene );
146+
viewer.getCamera().setClearColor( [ 0.7, 0.7, 0.7, 0.0 ] );
98147
viewer.setSceneData( rotate );
99-
viewer.setupManipulator();
100-
viewer.getManipulator().computeHomePosition();
148+
//viewer._requestContinousUpdate = true;
149+
//viewer.setupManipulator();
150+
//viewer.getManipulator().computeHomePosition();
101151

102152
viewer.run();
103153

154+
/*var tobj = { force:0 };
155+
new TWEEN.Tween(tobj).to({force:200}, 2000).onUpdate(function(){
156+
mod.force = this.force;
157+
//mstack.apply( );
158+
}).start();*/
159+
104160
} catch ( er ) {
105161
osg.log( 'exception in osgViewer ' + er );
106162
}

0 commit comments

Comments
 (0)