Skip to content

Commit d119fe6

Browse files
committed
docs update, prep for release
1 parent 9462e9e commit d119fe6

File tree

7 files changed

+32
-18
lines changed

7 files changed

+32
-18
lines changed

dist/bas.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ THREE.BAS.Utils = {
114114
*
115115
* @param {THREE.Geometry} geometry Geometry instance the face is in.
116116
* @param {THREE.Face3} face Face object from the THREE.Geometry.faces array
117-
* @param {THREE.Vector3} v Optional vector to store result in.
117+
* @param {THREE.Vector3=} v Optional vector to store result in.
118118
* @returns {THREE.Vector3}
119119
*/
120120
computeCentroid: function(geometry, face, v) {
@@ -135,7 +135,7 @@ THREE.BAS.Utils = {
135135
* Get a random vector between box.min and box.max.
136136
*
137137
* @param {THREE.Box3} box THREE.Box3 instance.
138-
* @param {THREE.Vector3} v Optional vector to store result in.
138+
* @param {THREE.Vector3=} v Optional vector to store result in.
139139
* @returns {THREE.Vector3}
140140
*/
141141
randomInBox: function(box, v) {
@@ -151,7 +151,7 @@ THREE.BAS.Utils = {
151151
/**
152152
* Get a random axis for quaternion rotation.
153153
*
154-
* @param {THREE.Vector3} v Option vector to store result in.
154+
* @param {THREE.Vector3=} v Option vector to store result in.
155155
* @returns {THREE.Vector3}
156156
*/
157157
randomAxis: function(v) {
@@ -209,8 +209,8 @@ THREE.BAS.Utils = {
209209
*
210210
* @param {THREE.Geometry} model The THREE.Geometry to base this geometry on.
211211
* @param {Object=} options
212-
* @param {Boolean=false} options.computeCentroids If true, a centroids will be computed for each face and stored in THREE.BAS.ModelBufferGeometry.centroids.
213-
* @param {Boolean=false} options.localizeFaces If true, the positions for each face will be stored relative to the centroid. This is useful if you want to rotate or scale faces around their center.
212+
* @param {Boolean=} options.computeCentroids If true, a centroids will be computed for each face and stored in THREE.BAS.ModelBufferGeometry.centroids.
213+
* @param {Boolean=} options.localizeFaces If true, the positions for each face will be stored relative to the centroid. This is useful if you want to rotate or scale faces around their center.
214214
* @constructor
215215
*/
216216
THREE.BAS.ModelBufferGeometry = function(model, options) {
@@ -340,7 +340,7 @@ THREE.BAS.ModelBufferGeometry.prototype.bufferUVs = function() {
340340
*
341341
* @param {String} name Name of the attribute.
342342
* @param {int} itemSize Number of floats per vertex (typically 1, 2, 3 or 4).
343-
* @param {function} factory Function that will be called for each face upon creation. Accepts 3 arguments: data[], index and faceCount. Calls setFaceData.
343+
* @param {function=} factory Function that will be called for each face upon creation. Accepts 3 arguments: data[], index and faceCount. Calls setFaceData.
344344
*
345345
* @returns {THREE.BufferAttribute}
346346
*/
@@ -485,7 +485,7 @@ THREE.BAS.PrefabBufferGeometry.prototype.bufferUvs = function() {
485485
*
486486
* @param {String} name Name of the attribute.
487487
* @param {Number} itemSize Number of floats per vertex (typically 1, 2, 3 or 4).
488-
* @param {function} factory Function that will be called for each prefab upon creation. Accepts 3 arguments: data[], index and prefabCount. Calls setPrefabData.
488+
* @param {function=} factory Function that will be called for each prefab upon creation. Accepts 3 arguments: data[], index and prefabCount. Calls setPrefabData.
489489
*
490490
* @returns {THREE.BufferAttribute}
491491
*/

dist/bas.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/boxes/main.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
window.onload = init;
22

3+
/**
4+
* This is a proof-of-concept for 'embedding' an animation timeline inside the vertex shader.
5+
* Implementation is very rough. Only translation and scale are supported.
6+
* This may or may not end up being useful.
7+
*/
8+
39
function init() {
410
var root = new THREERoot();
511
root.renderer.setClearColor(0x000000);
@@ -72,6 +78,9 @@ function init() {
7278

7379
function Animation(gridSize) {
7480
// setup timeline
81+
82+
// the timeline generates shader chunks where an animation step is baked into.
83+
// each prefab will execute the same animation, with in offset position and time (delay).
7584
var timeline = new Timeline();
7685

7786
// scale down
@@ -125,11 +134,11 @@ function Animation(gridSize) {
125134
// setup prefab geometry
126135
var prefabCount = gridSize * gridSize;
127136
var geometry = new THREE.BAS.PrefabBufferGeometry(prefab, prefabCount);
137+
128138
var aPosition = geometry.createAttribute('aPosition', 3);
129139
var aDelayDuration = geometry.createAttribute('aDelayDuration', 2);
130140
var index = 0;
131141
var dataArray = [];
132-
133142
var maxDelay = 4.0;
134143

135144
this.totalDuration = timeline.totalDuration + maxDelay;
@@ -146,8 +155,6 @@ function Animation(gridSize) {
146155
geometry.setPrefabData(aPosition, index, dataArray);
147156

148157
// animation
149-
//dataArray[0] = maxDelay * index / prefabCount;
150-
//dataArray[0] = maxDelay * Math.random();
151158
dataArray[0] = maxDelay * Math.sqrt(x * x + y * y) / gridSize;
152159
dataArray[1] = timeline.totalDuration;
153160
geometry.setPrefabData(aDelayDuration, index, dataArray);
@@ -167,10 +174,12 @@ function Animation(gridSize) {
167174
roughness: 1.0
168175
},
169176
vertexFunctions: [
177+
// the eases used by the timeline defined above
170178
THREE.BAS.ShaderChunk['ease_cubic_in'],
171179
THREE.BAS.ShaderChunk['ease_cubic_out'],
172180
THREE.BAS.ShaderChunk['ease_cubic_in_out'],
173181
THREE.BAS.ShaderChunk['ease_back_out'],
182+
// getChunks outputs the shader chunks where the animation is baked into
174183
].concat(timeline.getChunks()),
175184
vertexParameters: [
176185
'uniform float uTime;',
@@ -179,11 +188,14 @@ function Animation(gridSize) {
179188
'attribute vec2 aDelayDuration;'
180189
],
181190
vertexPosition: [
191+
// calculate animation time for the prefab
182192
'float tTime = clamp(uTime - aDelayDuration.x, 0.0, aDelayDuration.y);',
183193

194+
// apply timeline transformations based on 'tTime'
184195
timeline.getScaleCalls(),
185196
timeline.getTranslateCalls(),
186197

198+
// translate the vertex by prefab position
187199
'transformed += aPosition;'
188200
]
189201
});
@@ -310,6 +322,7 @@ function Segment(key, delay, duration, ease, translate, scale) {
310322
var sf = 'vec3(' + vecToString(scale.from, 2) + ')';
311323
var st = 'vec3(' + vecToString(scale.to, 2) + ')';
312324

325+
// this is where the magic happens, but the magic still needs a lot of work
313326
this.chunk = [
314327
'float cDelay' + key + ' = ' + delay.toPrecision(2) + ';',
315328
'float cDuration' + key + ' = ' + duration.toPrecision(2) + ';',

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ <h2>Advanced / Showcase</h2>
4949
<a href="examples/audio_visual">Audio Visualiser</a>
5050
<a href="examples/image_transition">Image Transition</a>
5151
<a href="examples/motion_smear">Motion Smear</a>
52+
<a href="examples/boxes">Many Boxes</a>
5253
</div>
5354
<div class="footer">
5455
<a href="https://github.com/zadvorsky/three.bas">Source</a> | <a href="docs/gen">Documentation</a> | <a href="https://github.com/zadvorsky/three.bas/wiki">Wiki</a> | <a href="https://twitter.com/zadvorsky">@zadvorsky</a>

src/Utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ THREE.BAS.Utils = {
4141
*
4242
* @param {THREE.Geometry} geometry Geometry instance the face is in.
4343
* @param {THREE.Face3} face Face object from the THREE.Geometry.faces array
44-
* @param {THREE.Vector3} v Optional vector to store result in.
44+
* @param {THREE.Vector3=} v Optional vector to store result in.
4545
* @returns {THREE.Vector3}
4646
*/
4747
computeCentroid: function(geometry, face, v) {
@@ -62,7 +62,7 @@ THREE.BAS.Utils = {
6262
* Get a random vector between box.min and box.max.
6363
*
6464
* @param {THREE.Box3} box THREE.Box3 instance.
65-
* @param {THREE.Vector3} v Optional vector to store result in.
65+
* @param {THREE.Vector3=} v Optional vector to store result in.
6666
* @returns {THREE.Vector3}
6767
*/
6868
randomInBox: function(box, v) {
@@ -78,7 +78,7 @@ THREE.BAS.Utils = {
7878
/**
7979
* Get a random axis for quaternion rotation.
8080
*
81-
* @param {THREE.Vector3} v Option vector to store result in.
81+
* @param {THREE.Vector3=} v Option vector to store result in.
8282
* @returns {THREE.Vector3}
8383
*/
8484
randomAxis: function(v) {

src/geometry/ModelBufferGeometry.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* @param {THREE.Geometry} model The THREE.Geometry to base this geometry on.
55
* @param {Object=} options
6-
* @param {Boolean=false} options.computeCentroids If true, a centroids will be computed for each face and stored in THREE.BAS.ModelBufferGeometry.centroids.
7-
* @param {Boolean=false} options.localizeFaces If true, the positions for each face will be stored relative to the centroid. This is useful if you want to rotate or scale faces around their center.
6+
* @param {Boolean=} options.computeCentroids If true, a centroids will be computed for each face and stored in THREE.BAS.ModelBufferGeometry.centroids.
7+
* @param {Boolean=} options.localizeFaces If true, the positions for each face will be stored relative to the centroid. This is useful if you want to rotate or scale faces around their center.
88
* @constructor
99
*/
1010
THREE.BAS.ModelBufferGeometry = function(model, options) {
@@ -134,7 +134,7 @@ THREE.BAS.ModelBufferGeometry.prototype.bufferUVs = function() {
134134
*
135135
* @param {String} name Name of the attribute.
136136
* @param {int} itemSize Number of floats per vertex (typically 1, 2, 3 or 4).
137-
* @param {function} factory Function that will be called for each face upon creation. Accepts 3 arguments: data[], index and faceCount. Calls setFaceData.
137+
* @param {function=} factory Function that will be called for each face upon creation. Accepts 3 arguments: data[], index and faceCount. Calls setFaceData.
138138
*
139139
* @returns {THREE.BufferAttribute}
140140
*/

src/geometry/PrefabBufferGeometry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ THREE.BAS.PrefabBufferGeometry.prototype.bufferUvs = function() {
101101
*
102102
* @param {String} name Name of the attribute.
103103
* @param {Number} itemSize Number of floats per vertex (typically 1, 2, 3 or 4).
104-
* @param {function} factory Function that will be called for each prefab upon creation. Accepts 3 arguments: data[], index and prefabCount. Calls setPrefabData.
104+
* @param {function=} factory Function that will be called for each prefab upon creation. Accepts 3 arguments: data[], index and prefabCount. Calls setPrefabData.
105105
*
106106
* @returns {THREE.BufferAttribute}
107107
*/

0 commit comments

Comments
 (0)