diff options
author | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
commit | 53051672a62208fbc96957719d8285fac6431ed6 (patch) | |
tree | 79d542ee811044e8af2ef84aa0d6662c6eb895c4 /js/lib/drawing | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | 5146f224258929415adf4a8022e492454b4e2476 (diff) | |
download | ninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts:
js/panels/Timeline/DragDrop.js
js/panels/Timeline/Keyframe.reel/Keyframe.js
js/panels/Timeline/Layer.reel/Layer.js
js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
js/panels/Timeline/Span.reel/Span.js
js/panels/Timeline/Style.reel/Style.js
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
js/panels/Timeline/Track.reel/Track.html
js/panels/Timeline/Track.reel/Track.js
js/panels/Timeline/Track.reel/css/Track.css
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js
js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css
js/panels/Timeline/Tween.reel/Tween.js
Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-x | js/lib/drawing/world.js | 1289 |
1 files changed, 649 insertions, 640 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index fb70d18c..ca2f07cc 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -46,66 +47,66 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
46 | // Instance variables | 47 | // Instance variables |
47 | /////////////////////////////////////////////////////////////////////// | 48 | /////////////////////////////////////////////////////////////////////// |
48 | 49 | ||
49 | // flag to do the drawing with WebGL | 50 | // flag to do the drawing with WebGL |
50 | this._useWebGL = false; | 51 | this._useWebGL = false; |
51 | if(use3D) { | 52 | if(use3D) { |
52 | this._useWebGL = use3D; | 53 | this._useWebGL = use3D; |
53 | } | 54 | } |
54 | 55 | ||
55 | this._canvas = canvas; | 56 | this._canvas = canvas; |
56 | if (this._useWebGL) | 57 | if (this._useWebGL) |
57 | { | 58 | { |
58 | if(preserveDrawingBuffer) | 59 | if(preserveDrawingBuffer) |
59 | { | 60 | { |
60 | this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); | 61 | this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); |
61 | } | 62 | } |
62 | else | 63 | else |
63 | { | 64 | { |
64 | this._glContext = canvas.getContext("experimental-webgl"); | 65 | this._glContext = canvas.getContext("experimental-webgl"); |
65 | } | 66 | } |
66 | } | 67 | } |
67 | else | 68 | else |
68 | { | 69 | { |
69 | this._2DContext = canvas.getContext( "2d" ); | 70 | this._2DContext = canvas.getContext( "2d" ); |
70 | } | 71 | } |
71 | 72 | ||
72 | this._viewportWidth = canvas.width; | 73 | this._viewportWidth = canvas.width; |
73 | this._viewportHeight = canvas.height; | 74 | this._viewportHeight = canvas.height; |
74 | 75 | ||
75 | // view parameters | 76 | // view parameters |
76 | this._fov = 45.0; | 77 | this._fov = 45.0; |
77 | this._zNear = 0.1; | 78 | this._zNear = 0.1; |
78 | this._zFar = 100.0; | 79 | this._zFar = 100.0; |
79 | this._viewDist = 5.0; | 80 | this._viewDist = 5.0; |
80 | 81 | ||
81 | // default light parameters | 82 | // default light parameters |
82 | this._ambientLightColor = [0.1, 0.1, 0.1, 1.0]; | 83 | this._ambientLightColor = [0.1, 0.1, 0.1, 1.0]; |
83 | this._diffuseLightColor = [0.1, 0.1, 0.1, 1.0]; | 84 | this._diffuseLightColor = [0.1, 0.1, 0.1, 1.0]; |
84 | this._specularLightColor = [0.6, 0.6, 0.6, 1.0]; | 85 | this._specularLightColor = [0.6, 0.6, 0.6, 1.0]; |
85 | this._pointLightLoc = [0.0, 0.0, 0.05]; | 86 | this._pointLightLoc = [0.0, 0.0, 0.05]; |
86 | 87 | ||
87 | // default material properties. Material properties should be overridden | 88 | // default material properties. Material properties should be overridden |
88 | // by the materials used by the objects | 89 | // by the materials used by the objects |
89 | this._materialShininess = 20.0; | 90 | this._materialShininess = 20.0; |
90 | 91 | ||
91 | this._geomRoot = undefined; | 92 | this._geomRoot = undefined; |
92 | 93 | ||
93 | this._cameraMat = Matrix.I(4); | 94 | this._cameraMat = Matrix.I(4); |
94 | this._cameraMat[14] = 5.0; | 95 | this._cameraMat[14] = 5.0; |
95 | this._cameraMatInv = Matrix.I(4); | 96 | this._cameraMatInv = Matrix.I(4); |
96 | this._cameraMatInv[14] = -5.0; | 97 | this._cameraMatInv[14] = -5.0; |
97 | 98 | ||
98 | this._camera = null; | 99 | this._camera = null; |
99 | // keep a flag indicating whether a render has been completed. | 100 | // keep a flag indicating whether a render has been completed. |
100 | // this allows us to turn off automatic updating if there are | 101 | // this allows us to turn off automatic updating if there are |
101 | // no animated materials | 102 | // no animated materials |
102 | this._firstRender = true; | 103 | this._firstRender = true; |
103 | 104 | ||
104 | this._worldCount = worldCounter; | 105 | this._worldCount = worldCounter; |
105 | worldCounter++; | 106 | worldCounter++; |
106 | 107 | ||
107 | // keep a counter for generating node names | 108 | // keep a counter for generating node names |
108 | this._nodeCounter = 0; | 109 | this._nodeCounter = 0; |
109 | 110 | ||
110 | // for sending notifications to listeners | 111 | // for sending notifications to listeners |
111 | this._notifier = new Notifier(); | 112 | this._notifier = new Notifier(); |
@@ -113,46 +114,46 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
113 | /////////////////////////////////////////////////////////////////////// | 114 | /////////////////////////////////////////////////////////////////////// |
114 | // Property accessors | 115 | // Property accessors |
115 | /////////////////////////////////////////////////////////////////////// | 116 | /////////////////////////////////////////////////////////////////////// |
116 | this.getGLContext = function() { return this._glContext; }; | 117 | this.getGLContext = function() { return this._glContext; }; |
117 | this.setGLContext = function(gl) { this._glContext = gl; }; | 118 | this.setGLContext = function(gl) { this._glContext = gl; }; |
118 | 119 | ||
119 | this.get2DContext = function() { return this._2DContext; }; | 120 | this.get2DContext = function() { return this._2DContext; }; |
120 | this.set2DContext = function(c) { this._2DContext = c; }; | 121 | this.set2DContext = function(c) { this._2DContext = c; }; |
121 | 122 | ||
122 | this.getCanvas = function() { return this._canvas; }; | 123 | this.getCanvas = function() { return this._canvas; }; |
123 | this.setCanvas = function(c) { this._canvas = c; }; | 124 | this.setCanvas = function(c) { this._canvas = c; }; |
124 | 125 | ||
125 | this.getShaderProgram = function() { return this._shaderProgram; }; | 126 | this.getShaderProgram = function() { return this._shaderProgram; }; |
126 | 127 | ||
127 | this.getViewportWidth = function() { return this._viewportWidth; }; | 128 | this.getViewportWidth = function() { return this._viewportWidth; }; |
128 | this.getViewportHeight = function() { return this._viewportHeight; }; | 129 | this.getViewportHeight = function() { return this._viewportHeight; }; |
129 | 130 | ||
130 | this.getAspect = function() { return this._viewportWidth/this._viewportHeight; }; | 131 | this.getAspect = function() { return this._viewportWidth/this._viewportHeight; }; |
131 | 132 | ||
132 | this.getGeomRoot = function() { return this._geomRoot; }; | 133 | this.getGeomRoot = function() { return this._geomRoot; }; |
133 | this.getZNear = function() { return this._zNear; }; | 134 | this.getZNear = function() { return this._zNear; }; |
134 | this.getZFar = function() { return this._zFar; }; | 135 | this.getZFar = function() { return this._zFar; }; |
135 | this.getFOV = function() { return this._fov; }; | 136 | this.getFOV = function() { return this._fov; }; |
136 | 137 | ||
137 | this.getCamera = function() { return this._camera; }; | 138 | this.getCamera = function() { return this._camera; }; |
138 | 139 | ||
139 | this.getCameraMat = function() { return this._cameraMat.slice(0); }; | 140 | this.getCameraMat = function() { return this._cameraMat.slice(0); }; |
140 | this.setCameraMat = function(c) { this._cameraMat = c.slice(0); this._cameraMatInv = glmat4.inverse(c, []); }; | 141 | this.setCameraMat = function(c) { this._cameraMat = c.slice(0); this._cameraMatInv = glmat4.inverse(c, []); }; |
141 | 142 | ||
142 | this.getCameraMatInverse = function() { return this._cameraMatInv.slice(0); }; | 143 | this.getCameraMatInverse = function() { return this._cameraMatInv.slice(0); }; |
143 | 144 | ||
144 | this.getViewDistance = function() { return this._viewDist; }; | 145 | this.getViewDistance = function() { return this._viewDist; }; |
145 | 146 | ||
146 | this.getRootNode = function() { return this._rootNode; }; | 147 | this.getRootNode = function() { return this._rootNode; }; |
147 | this.setRootNode = function(r) { this._rootNode = r; }; | 148 | this.setRootNode = function(r) { this._rootNode = r; }; |
148 | 149 | ||
149 | this.isWebGL = function() { return this._useWebGL; }; | 150 | this.isWebGL = function() { return this._useWebGL; }; |
150 | 151 | ||
151 | this.getRenderer = function() { return this.renderer; }; | 152 | this.getRenderer = function() { return this.renderer; }; |
152 | 153 | ||
153 | // Flag to play/pause animation at authortime | 154 | // Flag to play/pause animation at authortime |
154 | this._previewAnimation = true; | 155 | this._previewAnimation = true; |
155 | 156 | ||
156 | //////////////////////////////////////////////////////////////////////////////////// | 157 | //////////////////////////////////////////////////////////////////////////////////// |
157 | // RDGE | 158 | // RDGE |
158 | // local variables | 159 | // local variables |
@@ -164,265 +165,265 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
164 | this.strokeShader = null; |