aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/line.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/line.js')
-rwxr-xr-xjs/lib/geom/line.js57
1 files changed, 51 insertions, 6 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index 2b46b0f5..26631a31 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -87,8 +87,17 @@ exports.Line = Object.create(GeomObj, {
87 this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; 87 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
88 88
89 if(strokeMaterial) { 89 if(strokeMaterial) {
90 this._strokeMaterial = strokeMaterial; 90 this._strokeMaterial = strokeMaterial.dup();
91 if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); 91 } else {
92 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
93 }
94
95 if(strokeColor) {
96 if(this._strokeMaterial.hasProperty("color")) {
97 this._strokeMaterial.setProperty( "color", this._strokeColor );
98 } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) {
99 this._strokeMaterial.setGradientData(this._strokeColor.color);
100 }
92 } 101 }
93 } 102 }
94 }, 103 },
@@ -437,12 +446,48 @@ exports.Line = Object.create(GeomObj, {
437 indices.push( index ); index++; 446 indices.push( index ); index++;
438 } 447 }
439 448
440 var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, indices.length);
441
442 var strokeMaterial = this.makeStrokeMaterial(); 449 var strokeMaterial = this.makeStrokeMaterial();
443 450// var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, indices.length);
444 this._primArray.push( prim ); 451// this._primArray.push( prim );
452// this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
453
454 // refine the mesh for vertex deformations
455 if (strokeMaterial)
456 {
457 var primArray;
458 if (strokeMaterial.hasVertexDeformation())
459 {
460 var paramRange = strokeMaterial.getVertexDeformationRange();
461 var tolerance = strokeMaterial.getVertexDeformationTolerance();
462 var nVertices = indices.length;
463 nVertices = ShapePrimitive.refineMesh( strokeVertices, strokeNormals, strokeTextures, indices, nVertices, paramRange, tolerance );
464 var subdividedParts = ShapePrimitive.subdivideOversizedMesh( strokeVertices, strokeNormals, strokeTextures, indices );
465
466 primArray = [];
467 if (subdividedParts)
468 {
469 for (var i=0; i<subdividedParts.length; i++)
470 {
471 var obj = subdividedParts[i];
472 primArray.push( ShapePrimitive.create(obj.vertices, obj.normals, obj.uvs, obj.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, obj.vertices.length/3) );
473 }
474 }
475 else
476 primArray = [ ShapePrimitive.create(vrts, nrms, uvs, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices) ];
477 }
478 else
479 {
480 // create the RDGE primitive
481 primArray = [ ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, indices.length) ];
482 }
483
484 var nPrims = primArray.length;
485 for (var i=0; i<nPrims; i++)
486 {
487 this._primArray.push( primArray[i] );
445 this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); 488 this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
489 }
490 }
446 491
447 world.updateObject(this); 492 world.updateObject(this);
448 } 493 }