Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: samples/o3d-webgl/function.js

Issue 3020030: Fixes errors when loading animated meshes in simpleviewer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/o3d-webgl/curve.js ('k') | samples/o3d-webgl/pack.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010, Google Inc. 2 * Copyright 2010, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 * @extends {o3d.ParamObject} 59 * @extends {o3d.ParamObject}
60 */ 60 */
61 o3d.FunctionEval = function() { 61 o3d.FunctionEval = function() {
62 o3d.ParamObject.call(this); 62 o3d.ParamObject.call(this);
63 63
64 /** 64 /**
65 * Read/write input value to the function. 65 * Read/write input value to the function.
66 * @private 66 * @private
67 * @type {o3d.ParamFloat} 67 * @type {o3d.ParamFloat}
68 */ 68 */
69 this.input_param_ = this.createParam("input", "ParamFloat"); 69 this.input_param_ = this.getParam("input");
70 70
71 /** 71 /**
72 * ParamFunction whose value is a o3d.Function or subclass. 72 * ParamFunction whose value is a o3d.Function or subclass.
73 * @private 73 * @private
74 * @type {o3d.ParamFunction} 74 * @type {o3d.ParamFunction}
75 */ 75 */
76 this.func_param_ = this.createParam("functionObject", "ParamFunction"); 76 this.func_param_ = this.getParam("functionObject");
77 77
78 /** 78 /**
79 * Read-only output value. Value is cached if input does not change. 79 * Read-only output value. Value is cached if input does not change.
80 * @private 80 * @private
81 * @type {o3d.ParamFloatOutput} 81 * @type {o3d.ParamFloatOutput}
82 */ 82 */
83 this.output_param_ = this.createParam("output", "ParamFloatOutput"); 83 this.output_param_ = this.getParam("output");
84 84
85 /** 85 /**
86 * Context value to allow faster evaluation for adjacent input values. 86 * Context value to allow faster evaluation for adjacent input values.
87 * Used by the o3d.Function itself, but stored here to allow multiple 87 * Used by the o3d.Function itself, but stored here to allow multiple
88 * FunctionEval objects to share the same Function object. 88 * FunctionEval objects to share the same Function object.
89 * @private 89 * @private
90 * @type {object} 90 * @type {object}
91 */ 91 */
92 this.func_context_ = {}; 92 this.func_context_ = {};
93 93
94 /** 94 /**
95 * Last input value to check if cache needs to be invalidated. 95 * Last input value to check if cache needs to be invalidated.
96 * @private 96 * @private
97 * @type {number} 97 * @type {number}
98 */ 98 */
99 this.last_input_value_ = null; 99 this.last_input_value_ = null;
100 100
101 /** 101 /**
102 * Cache of the last output value. 102 * Cache of the last output value.
103 * @private 103 * @private
104 * @type {number} 104 * @type {number}
105 */ 105 */
106 this.last_output_value_ = null; 106 this.last_output_value_ = null;
107 }; 107 };
108 o3d.inherit('FunctionEval', 'ParamObject'); 108 o3d.inherit('FunctionEval', 'ParamObject');
109 109
110 /** 110 /**
111 * Read-only output value. Value is cached if input does not change. 111 * Read-only output value. Value is cached if input does not change.
112 * @private 112 * @type {number}
113 * @type {o3d.ParamFloatOutput}
114 */ 113 */
115 o3d.FunctionEval.prototype.__defineGetter__("output", 114 o3d.ParamObject.setUpO3DParam_(o3d.FunctionEval, "output", "ParamFloatOutput");
116 function() {
117 return this.output_param_.value;
118 });
119 115
120 /** 116 /**
121 * Read/write input value to the function. 117 * Read/write input value to the function.
122 * @type {o3d.ParamFloat} 118 * @type {number}
123 */ 119 */
124 o3d.FunctionEval.prototype.__defineGetter__("input", 120 o3d.ParamObject.setUpO3DParam_(o3d.FunctionEval, "input", "ParamFloat");
125 function() {
126 return this.input_param_.value;
127 });
128 o3d.FunctionEval.prototype.__defineSetter__("input",
129 function(newInput) {
130 this.input_param_.value = newInput;
131 });
132 121
133 /** 122 /**
134 * o3d.Function object (or subclass) with evaluate function. 123 * o3d.Function object (or subclass) with evaluate function.
135 * @private
136 * @type {o3d.Function} 124 * @type {o3d.Function}
137 */ 125 */
138 o3d.FunctionEval.prototype.__defineGetter__("functionObject", 126 o3d.ParamObject.setUpO3DParam_(o3d.FunctionEval, "functionObject",
139 function() { 127 "ParamFunction");
140 return this.func_param_.value;
141 });
142 o3d.FunctionEval.prototype.__defineSetter__("functionObject",
143 function(newFunc) {
144 this.func_param_.value = newFunc;
145 });
146 128
147 /** 129 /**
148 * Called by o3d.Param*Output whenever its value gets read. 130 * Called by o3d.Param*Output whenever its value gets read.
149 * This function should be responsible for caching the last value if necessary. 131 * This function should be responsible for caching the last value if necessary.
150 * @return {number} The result of evaluating the function. 132 * @return {number} The result of evaluating the function.
151 */ 133 */
152 o3d.FunctionEval.prototype.updateOutputs = function() { 134 o3d.FunctionEval.prototype.updateOutputs = function() {
153 var new_input_value = this.input_param_.value; 135 var new_input_value = this.input_param_.value;
154 if (this.last_input_value_ != new_input_value) { 136 if (this.last_input_value_ != new_input_value) {
155 this.last_output_value_ = 137 this.last_output_value_ =
156 this.func_param_.value.evaluate(this.last_input_value_, 138 this.func_param_.value.evaluate(this.last_input_value_,
157 this.func_context_); 139 this.func_context_);
158 this.last_input_value_ = new_input_value; 140 this.last_input_value_ = new_input_value;
159 } 141 }
160 return this.last_output_value_; 142 return this.last_output_value_;
161 }; 143 };
OLDNEW
« no previous file with comments | « samples/o3d-webgl/curve.js ('k') | samples/o3d-webgl/pack.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698