diff options
author | Armen Kesablyan | 2012-04-04 11:34:19 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-04-04 11:34:19 -0700 |
commit | 211f514882144de8df69ebb2106f3b446be1dda0 (patch) | |
tree | c8eaf3d9fc7ac1bc841320e73d41818fbfb5827d /js/lib/drawing/world.js | |
parent | 5a5d0f68dd82b829405a0b301dd11b4cf385c8d5 (diff) | |
parent | a11ef2eed7049835c8bdfa50a2b893632c46eaa0 (diff) | |
download | ninja-211f514882144de8df69ebb2106f3b446be1dda0.tar.gz |
Merge branch 'refs/heads/master' into BugFixes
Diffstat (limited to 'js/lib/drawing/world.js')
-rwxr-xr-x | js/lib/drawing/world.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index fec6a478..e348f5e8 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -527,7 +527,7 @@ World.prototype.clearTree = function() { | |||
527 | if (this._useWebGL) { | 527 | if (this._useWebGL) { |
528 | var root = this._rootNode; | 528 | var root = this._rootNode; |
529 | root.children = new Array(); | 529 | root.children = new Array(); |
530 | g_Engine.unregisterCanvas( this._canvas.rdgeid ) | 530 | g_Engine.unregisterCanvas( this._canvas.rdgeid ); |
531 | 531 | ||
532 | this.update( 0 ); | 532 | this.update( 0 ); |
533 | this.draw(); | 533 | this.draw(); |
@@ -540,8 +540,9 @@ World.prototype.updateMaterials = function( obj, time ) { | |||
540 | var matArray = obj.getMaterialArray(); | 540 | var matArray = obj.getMaterialArray(); |
541 | if (matArray) { | 541 | if (matArray) { |
542 | var n = matArray.length; | 542 | var n = matArray.length; |
543 | for (var i=0; i<n; i++) | 543 | for (var i=0; i<n; i++) { |
544 | matArray[i].update( time ); | 544 | matArray[i].update( time ); |
545 | } | ||
545 | } | 546 | } |
546 | 547 | ||
547 | this.updateMaterials( obj.getNext(), time ); | 548 | this.updateMaterials( obj.getNext(), time ); |
@@ -553,9 +554,8 @@ World.prototype.getNDCOrigin = function() { | |||
553 | var pt = MathUtils.transformPoint( [0,0,0], this.getCameraMatInverse() ); | 554 | var pt = MathUtils.transformPoint( [0,0,0], this.getCameraMatInverse() ); |
554 | var projMat = Matrix.makePerspective( this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); | 555 | var projMat = Matrix.makePerspective( this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); |
555 | var ndcPt = MathUtils.transformHomogeneousPoint( pt, projMat ); | 556 | var ndcPt = MathUtils.transformHomogeneousPoint( pt, projMat ); |
556 | var ndcOrigin = MathUtils.applyHomogeneousCoordinate( ndcPt ); | ||
557 | 557 | ||
558 | return ndcOrigin; | 558 | return MathUtils.applyHomogeneousCoordinate( ndcPt ); |
559 | }; | 559 | }; |
560 | 560 | ||
561 | World.prototype.worldToScreen = function(v) { | 561 | World.prototype.worldToScreen = function(v) { |
@@ -570,9 +570,8 @@ World.prototype.worldToScreen = function(v) { | |||
570 | var x = v2[0], y = v2[1], z = v2[2]; | 570 | var x = v2[0], y = v2[1], z = v2[2]; |
571 | 571 | ||
572 | var h = this.getGLContext().viewportHeight/2.0, w = this.getGLContext().viewportWidth/2.0; | 572 | var h = this.getGLContext().viewportHeight/2.0, w = this.getGLContext().viewportWidth/2.0; |
573 | var x2 = w*(1 + x), y2 = h*( 1 - y ), z2 = z; | 573 | var x2 = w * (1 + x), y2 = h * ( 1 - y ); |
574 | 574 | return [x2, y2, z, 1]; | |
575 | return [x2, y2, z2, 1]; | ||
576 | }; | 575 | }; |
577 | 576 | ||
578 | World.prototype.screenToView = function( x, y ) { | 577 | World.prototype.screenToView = function( x, y ) { |
@@ -942,6 +941,7 @@ World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) | |||
942 | World.prototype.importObjectJSON = function( jObj, parentGeomObj ) | 941 | World.prototype.importObjectJSON = function( jObj, parentGeomObj ) |
943 | { | 942 | { |
944 | var type = jObj.type; | 943 | var type = jObj.type; |
944 | var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; | ||
945 | 945 | ||
946 | var obj; | 946 | var obj; |
947 | switch (type) | 947 | switch (type) |
@@ -961,6 +961,11 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj ) | |||
961 | obj.importJSON( jObj ); | 961 | obj.importJSON( jObj ); |
962 | break; | 962 | break; |
963 | 963 | ||
964 | case 6: //brush stroke | ||
965 | obj = new BrushStroke(); | ||
966 | obj.importJSON(jObj); | ||
967 | break; | ||
968 | |||
964 | default: | 969 | default: |
965 | throw new Error( "Unrecognized object type: " + type ); | 970 | throw new Error( "Unrecognized object type: " + type ); |
966 | break; | 971 | break; |