language
stringclasses 1
value | owner
stringlengths 2
15
| repo
stringlengths 2
21
| sha
stringlengths 45
45
| message
stringlengths 7
36.3k
| path
stringlengths 1
199
| patch
stringlengths 15
102k
| is_multipart
bool 2
classes |
---|---|---|---|---|---|---|---|
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/GeometryEditor.js | @@ -1,75 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.GeometryEditor = function ( geometry ) {
-
- this.geometry = geometry;
-
-};
-
-Object.defineProperties( THREE.GeometryEditor.prototype, {
- vertices: {
- enumerable: true,
- get: function() { return this.createVertexProxies(); }
- },
- normals: {
- enumerable: true,
- get: function() { return this.createNormalProxies(); }
- },
- uvs: {
- enumerable: true,
- get: function() { return this.createUVProxies(); }
- }
-} );
-
-THREE.GeometryEditor.prototype.createVertexProxies = function () {
-
- Object.defineProperty( this, 'vertices', { value: [], writable: true } );
-
- var attributes = this.geometry.attributes;
- var length = attributes.position.array.length / 3;
-
- for ( var i = 0; i < length; i ++ ) {
-
- this.vertices.push( new THREE.ProxyVector3( attributes.position.array, i * 3 ) );
-
- }
-
- return this.vertices;
-
-};
-
-THREE.GeometryEditor.prototype.createNormalProxies = function () {
-
- Object.defineProperty( this, 'normals', { value: [], writable: true } );
-
- var attributes = this.geometry.attributes;
- var length = attributes.position.array.length / 3;
-
- for ( var i = 0; i < length; i ++ ) {
-
- this.normals.push( new THREE.ProxyVector3( attributes.normal.array, i * 3 ) );
-
- }
-
- return this.normals;
-
-};
-
-THREE.GeometryEditor.prototype.createUVProxies = function () {
-
- Object.defineProperty( this, 'uvs', { value: [], writable: true } );
-
- var attributes = this.geometry.attributes;
- var length = attributes.position.array.length / 3;
-
- for ( var i = 0; i < length; i ++ ) {
-
- this.uvs.push( new THREE.ProxyVector2( attributes.uv.array, i * 2 ) );
-
- }
-
- return this.uvs;
-
-};
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/IndexedTypedGeometry.js | @@ -1,28 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.IndexedTypedGeometry = function () {
-
- THREE.BufferGeometry.call( this );
-
-};
-
-THREE.IndexedTypedGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.IndexedTypedGeometry.prototype.constructor = THREE.IndexedTypedGeometry;
-
-THREE.IndexedTypedGeometry.prototype.setArrays = function ( indices, vertices, normals, uvs ) {
-
- this.indices = indices;
- this.vertices = vertices;
- this.normals = normals;
- this.uvs = uvs;
-
- this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
- this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
- this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
- this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
-
- return this;
-
-}; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/PlaneTypedGeometry.js | @@ -1,92 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneTypedGeometry = function ( width, height, widthSegments, heightSegments ) {
-
- this.parameters = {
- width: width,
- height: height,
- widthSegments: widthSegments,
- heightSegments: heightSegments
- };
-
- var width_half = width / 2;
- var height_half = height / 2;
-
- var gridX = widthSegments || 1;
- var gridY = heightSegments || 1;
-
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
-
- var segment_width = width / gridX;
- var segment_height = height / gridY;
-
- var vertices = new Float32Array( gridX1 * gridY1 * 3 );
- var normals = new Float32Array( gridX1 * gridY1 * 3 );
- var uvs = new Float32Array( gridX1 * gridY1 * 2 );
-
- var offset = 0;
- var offset2 = 0;
-
- for ( var iy = 0; iy < gridY1; iy ++ ) {
-
- var y = iy * segment_height - height_half;
-
- for ( var ix = 0; ix < gridX1; ix ++ ) {
-
- var x = ix * segment_width - width_half;
-
- vertices[ offset ] = x;
- vertices[ offset + 1 ] = - y;
-
- normals[ offset + 2 ] = 1;
-
- uvs[ offset2 ] = ix / gridX;
- uvs[ offset2 + 1 ] = 1 - ( iy / gridY );
-
- offset += 3;
- offset2 += 2;
-
- }
-
- }
-
- offset = 0;
-
- var indices = new ( ( vertices.length / 3 ) > 65535 ? Uint32Array : Uint16Array )( gridX * gridY * 6 );
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var a = ix + gridX1 * iy;
- var b = ix + gridX1 * ( iy + 1 );
- var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
- var d = ( ix + 1 ) + gridX1 * iy;
-
- indices[ offset ] = a;
- indices[ offset + 1 ] = b;
- indices[ offset + 2 ] = d;
-
- indices[ offset + 3 ] = b;
- indices[ offset + 4 ] = c;
- indices[ offset + 5 ] = d;
-
- offset += 6;
-
- }
-
- }
-
- THREE.IndexedTypedGeometry.call( this );
-
- this.setArrays( indices, vertices, normals, uvs );
- this.computeBoundingSphere();
-
-};
-
-THREE.PlaneTypedGeometry.prototype = Object.create( THREE.IndexedTypedGeometry.prototype );
-THREE.PlaneTypedGeometry.prototype.constructor = THREE.PlaneTypedGeometry; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/ProxyGeometry.js | @@ -1,755 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * @author kile / http://kile.stravaganza.org/
- * @author alteredq / http://alteredqualia.com/
- * @author mikael emtinger / http://gomo.se/
- * @author zz85 / http://www.lab4games.net/zz85/blog
- * @author bhouston / http://exocortex.com
- * @author jbaicoianu / http://baicoianu.com
- */
-
-THREE.ProxyGeometry = function ( ) {
-
- THREE.BufferGeometry.call( this );
-
- this.addEventListener( 'allocate', this.onGeometryAllocate);
-
- // TODO - implement as BufferGeometry attributes
- this.morphTargets = [];
- this.morphColors = [];
-
-};
-
-THREE.ProxyGeometry.prototype = Object.create( THREE.IndexedGeometry2.prototype );
-THREE.ProxyGeometry.prototype.constructor = THREE.ProxyGeometry;
-
-Object.defineProperties(THREE.ProxyGeometry.prototype, {
- vertices: {
- enumerable: true,
- configurable: true,
- get: function() { return this.createVertexProxies(); }
- },
- faces: {
- enumerable: true,
- get: function() { return this.createFaceProxies() }
- },
- faceVertexUvs: {
- enumerable: true,
- get: function() { return this.createUvProxies() }
- },
- colors: {
- enumerable: true,
- get: function() { return this.createColorProxies() }
- },
- skinIndices: {
- enumerable: true,
- get: function() { return this.createSkinIndexProxies() }
- },
- skinWeights: {
- enumerable: true,
- get: function() { return this.createSkinWeightProxies() }
- },
- // TODO - fill in additional proxies:
- // - morphColors
- // - morphNormals
- // - morphTargets
-
- verticesNeedUpdate: {
- enumerable: true,
- get: function() { if (this.attributes[ 'position' ]) return this.attributes[ 'position' ].needsUpdate; },
- set: function(v) { if (this.attributes[ 'position' ]) this.attributes[ 'position' ].needsUpdate = v; }
- },
- colorsNeedUpdate: {
- enumerable: true,
- get: function() { if (this.attributes[ 'color' ]) return this.attributes[ 'color' ].needsUpdate; },
- set: function(v) { if (this.attributes[ 'color' ]) this.attributes[ 'color' ].needsUpdate = v; }
- },
- normalsNeedUpdate: {
- enumerable: true,
- get: function() { if (this.attributes[ 'normal' ]) return this.attributes[ 'normal' ].needsUpdate; },
- set: function(v) { if (this.attributes[ 'normal' ]) this.attributes[ 'normal' ].needsUpdate = v; }
- },
-});
-
-THREE.ProxyGeometry.prototype.createVertexProxies = function(values) {
-
- if (!this.hasOwnProperty('vertices')) {
-
- // Replace the prototype getter with a local array property
-
- Object.defineProperty( this, "vertices", { value: [], writable: true } );
-
- } else {
-
- // Start with a new, empty array
-
- this.vertices = [];
-
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- this.populateProxyFromBuffer(this.vertices, "position", THREE.ProxyVector3, 3);
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0; i < values.length; i ++) {
-
- this.vertices[i].copy(values[i]);
-
- }
- }
-
- // Return a reference to the newly-created array
-
- return this.vertices;
-
-};
-
-THREE.ProxyGeometry.prototype.createFaceProxies = function(values) {
-
- if (!this.hasOwnProperty("faces")) {
-
- // Replace the prototype getter with a local array property
-
- Object.defineProperty( this, "faces", { value: [], writable: true } );
-
- } else {
-
- // Start with a new, empty array
-
- this.faces = [];
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- var faces = this.faces,
- indexarray = false,
- positionarray = false,
- normalarray = false,
- colorarray = false,
- tangentarray = false;
-
- if ( this.attributes[ 'index' ] ) {
- indexarray = this.attributes[ 'index' ].array;
- }
- if ( this.attributes[ 'position' ] ) {
- positionarray = this.attributes[ 'position' ].array;
- }
- if (this.attributes[ 'normal' ]) {
- normalarray = this.attributes[ 'normal' ].array;
- }
- if (this.attributes[ 'color' ]) {
- colorarray = this.attributes[ 'color' ].array;
- }
- if (this.attributes[ 'tangent' ]) {
- tangentarray = this.attributes[ 'tangent' ].array;
- }
-
- // TODO - this should be accomplished using "virtual" functions on various classes (IndexedGeometry, SmoothGeometry, etc)
-
- if (indexarray) {
-
- for ( var i = 0, l = indexarray.length / 3; i < l; i ++ ) {
-
- var o = i * 3;
-
- var face = new THREE.ProxyFace3( indexarray, i * 3 );
- faces.push(face);
-
- }
-
- } else if (positionarray) {
-
- for ( var i = 0, l = positionarray.length / 3; i < l; i += 3 ) {
-
- var o = i * 3;
- var v1 = i, v2 = i + 1, v3 = i + 2;
-
- var face = new THREE.ProxyFace3( v1, v2, v3 );
- faces.push(face);
-
- }
-
- }
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0, l = values.length; i < l; i ++) {
-
- var f = faces[i],
- v = values[i];
-
- f.a = v.a;
- f.b = v.b;
- f.c = v.c;
-
- }
-
- }
-
- if (normalarray) {
-
- this.createFaceVertexNormalProxies(values);
-
- }
-
- if (colorarray) {
-
- this.createFaceVertexColorProxies(values);
-
- }
-
- if (tangentarray) {
-
- this.createFaceVertexTangentProxies(values);
-
- }
-
- // Return a reference to the newly-created array
-
- return this.faces;
-
-};
-
-THREE.ProxyGeometry.prototype.createFaceVertexNormalProxies = function(values) {
-
- if ( this.attributes[ 'normal' ] && this.attributes[ 'normal' ].array ) {
-
- var normalarray = this.attributes[ 'normal' ].array;
-
- for (var i = 0, l = this.faces.length; i < l; i ++) {
-
- var f = this.faces[i];
-
- f.vertexNormals = [
- new THREE.ProxyVector3(normalarray, f.a * 3),
- new THREE.ProxyVector3(normalarray, f.b * 3),
- new THREE.ProxyVector3(normalarray, f.c * 3),
- ];
- f.normal = new THREE.MultiVector3(f.vertexNormals);
-
- }
- }
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0, l = values.length; i < l; i ++) {
-
- var f = this.faces[i],
- v = values[i];
-
- if (v.vertexNormals.length > 0) {
-
- for (var j = 0, l2 = f.vertexNormals.length; j < l2; j ++) {
-
- f.vertexNormals[j].copy(v.vertexNormals[j]);
-
- }
-
- } else if (v.normal) {
-
- f.normal.copy(v.normal);
-
- }
-
- }
-
- }
-
-};
-
-THREE.ProxyGeometry.prototype.createFaceVertexColorProxies = function(values) {
-
- if ( this.attributes[ 'color' ] && this.attributes[ 'color' ].array ) {
-
- var colorarray = this.attributes[ 'color' ].array;
-
- for (var i = 0, l = this.faces.length; i < l; i ++) {
- var f = this.faces[i];
-
- if ( this.attributes[ 'index' ] ) {
- f.vertexColors = [
- new THREE.ProxyColor(colorarray, f.a * 3),
- new THREE.ProxyColor(colorarray, f.b * 3),
- new THREE.ProxyColor(colorarray, f.c * 3),
- ];
- } else {
- var o = i * 9;
-
- f.vertexColors = [
- new THREE.ProxyColor(colorarray, o),
- new THREE.ProxyColor(colorarray, o + 3),
- new THREE.ProxyColor(colorarray, o + 6),
- ];
- }
- f.color = new THREE.MultiColor(f.vertexColors);
-
- }
- }
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0, l = values.length; i < l; i ++) {
-
- var f = this.faces[i],
- v = values[i];
-
- for (var j = 0, l2 = f.vertexColors.length; j < l2; j ++) {
-
- if (v.vertexColors.length > 0) {
-
- f.vertexColors[j].copy(v.vertexColors[j]);
-
- } else if (v.color) {
-
- f.color.copy(v.color);
-
- }
-
- }
-
- }
-
- }
-
-};
-
-THREE.ProxyGeometry.prototype.createFaceVertexTangentProxies = function(values) {
-
- if ( this.attributes[ 'tangent' ] && this.attributes[ 'tangent' ].array ) {
-
- var tangentarray = this.attributes[ 'tangent' ].array;
-
- for (var i = 0, l = this.faces.length; i < l; i ++) {
-
- var f = this.faces[i];
-
- f.vertexTangents = [
- new THREE.ProxyVector3(tangentarray, f.a * 3),
- new THREE.ProxyVector3(tangentarray, f.b * 3),
- new THREE.ProxyVector3(tangentarray, f.c * 3),
- ];
-
- }
- }
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0, l = values.length; i < l; i ++) {
-
- var f = this.faces[i],
- v = values[i];
-
- if (v.vertexTangents.length > 0) {
-
- for (var j = 0, l2 = f.vertexTangents.length; j < l2; j ++) {
-
- f.vertexTangents[j].copy(v.vertexTangents[j]);
-
- }
-
- }
-
- }
-
- }
-
-};
-
-THREE.ProxyGeometry.prototype.createUvProxies = function(values) {
-
- // Replace the prototype getter with a local array property
-
- if (!this.hasOwnProperty("faceVertexUvs")) {
- Object.defineProperty( this, "faceVertexUvs", { value: [[]], writable: true } );
- } else {
- this.faceVertexUvs = [[]];
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- if ( this.attributes[ 'uv' ] && this.attributes[ 'uv' ].array ) {
-
- var faces = this.faces;
- var uvarray = this.attributes[ 'uv' ].array;
-
- for (var i = 0, l = faces.length; i < l; i ++) {
- var f = faces[i];
-
- this.faceVertexUvs[0][i] = [];
-
- if ( this.attributes[ 'index' ] ) {
- this.faceVertexUvs[0][i][0] = new THREE.ProxyVector2(uvarray, f.a * 2);
- this.faceVertexUvs[0][i][1] = new THREE.ProxyVector2(uvarray, f.b * 2);
- this.faceVertexUvs[0][i][2] = new THREE.ProxyVector2(uvarray, f.c * 2);
- } else {
- var o = i * 6;
- this.faceVertexUvs[0][i][0] = new THREE.ProxyVector2(uvarray, o);
- this.faceVertexUvs[0][i][1] = new THREE.ProxyVector2(uvarray, o + 2);
- this.faceVertexUvs[0][i][2] = new THREE.ProxyVector2(uvarray, o + 4);
- }
-
- }
-
- }
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0, l = values.length; i < l; i ++) {
-
- for (var j = 0, l2 = values[i].length; j < l2; j ++) {
-
- var uv = values[i][j];
- this.faceVertexUvs[0][i][j].copy(uv);
-
- }
-
- }
-
- }
-
- // Return a reference to the newly-created array
-
- return this.faceVertexUvs;
-
-};
-
-THREE.ProxyGeometry.prototype.createSkinIndexProxies = function(values) {
-
- // Replace the prototype getter with a local array property
-
- if (!this.hasOwnProperty('skinIndices')) {
- Object.defineProperty( this, "skinIndices", { value: [], writable: true } );
- } else {
- this.skinIndices = [];
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- this.populateProxyFromBuffer(this.skinIndices, "skinIndex", THREE.ProxyVector4, 4);
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0; i < values.length; i ++) {
-
- this.skinIndices[i].copy(values[i]);
-
- }
-
- }
-
- // Return a reference to the newly-created array
-
- return this.skinIndices;
-
-};
-
-THREE.ProxyGeometry.prototype.createSkinWeightProxies = function(values) {
-
- // Replace the prototype getter with a local array property
-
- if (!this.hasOwnProperty('skinWeights')) {
- Object.defineProperty( this, "skinWeights", { value: [], writable: true } );
- } else {
- this.skinWeights = [];
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- this.populateProxyFromBuffer(this.skinWeights, "skinWeight", THREE.ProxyVector4, 4);
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0; i < values.length; i ++) {
-
- this.skinWeights[i].copy(values[i]);
-
- }
-
- }
-
- // Return a reference to the newly-created array
-
- return this.skinWeights;
-
-};
-
-THREE.ProxyGeometry.prototype.createColorProxies = function(values) {
-
- // Replace the prototype getter with a local array property
-
- if (!this.hasOwnProperty('colors')) {
- Object.defineProperty( this, "colors", { value: [], writable: true } );
- } else {
- this.colors = [];
- }
-
- // If the attribute buffer has already been populated, set up proxy objects
-
- this.populateProxyFromBuffer(this.colors, "color", THREE.ProxyColor, 3);
-
- // If values were passed in, store them in the buffer via the proxy objects
-
- if (values) {
-
- for (var i = 0; i < values.length; i ++) {
-
- this.colors[i].copy(values[i]);
-
- }
-
- }
-
- // Return a reference to the newly-created array
-
- return this.colors;
-
-};
-
-THREE.ProxyGeometry.prototype.populateProxyFromBuffer = function(attr, buffername, proxytype, itemsize, offset, count) {
-
- if ( this.attributes[ buffername ] && this.attributes[ buffername ].array ) {
-
- var array = this.attributes[ buffername ].array;
- var size = itemsize || this.attributes[ buffername ].itemSize;
- var start = offset || 0;
-
- count = count || (array.length / size - start);
-
- for ( var i = start, l = start + count; i < l; i ++ ) {
-
- attr.push( new proxytype( array, i * size ) );
-
- }
-
- }
-
-};
-
-/*
- * Checks for duplicate vertices with hashmap.
- * Duplicated vertices are removed
- * and faces' vertices are updated.
- */
-
-THREE.ProxyGeometry.prototype.mergeVertices = function () {
-
- var verticesMap = {}; // Hashmap for looking up vertice by position coordinates (and making sure they are unique)
- var unique = [], changes = [];
-
- var v, key;
- var precisionPoints = 4; // number of decimal points, eg. 4 for epsilon of 0.0001
- var precision = Math.pow( 10, precisionPoints );
- var i,il, face;
- var indices, k, j, jl, u;
-
- for ( i = 0, il = this.vertices.length; i < il; i ++ ) {
-
- v = this.vertices[ i ];
- key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );
-
- if ( verticesMap[ key ] === undefined ) {
-
- verticesMap[ key ] = i;
- unique.push( this.vertices[ i ] );
- changes[ i ] = unique.length - 1;
-
- } else {
-
- //console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);
- changes[ i ] = changes[ verticesMap[ key ] ];
-
- }
-
- }
-
-
- // if faces are completely degenerate after merging vertices, we
- // have to remove them from the geometry.
- var faceIndicesToRemove = [];
-
- for ( i = 0, il = this.faces.length; i < il; i ++ ) {
-
- face = this.faces[ i ];
-
- face.a = changes[ face.a ];
- face.b = changes[ face.b ];
- face.c = changes[ face.c ];
-
- indices = [ face.a, face.b, face.c ];
-
- var dupIndex = -1;
-
- // if any duplicate vertices are found in a Face3
- // we have to remove the face as nothing can be saved
- for ( var n = 0; n < 3; n ++ ) {
- if ( indices[ n ] == indices[ ( n + 1 ) % 3 ] ) {
-
- dupIndex = n;
- faceIndicesToRemove.push( i );
- break;
-
- }
- }
-
- }
-
- for ( i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {
- var idx = faceIndicesToRemove[ i ];
-
- this.faces.splice( idx, 1 );
-
- for ( j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {
-
- this.faceVertexUvs[ j ].splice( idx, 1 );
-
- }
-
- }
-
- // Use unique set of vertices
-
- var diff = this.vertices.length - unique.length;
- this.vertices = unique;
- return diff;
-
-};
-
-THREE.ProxyGeometry.prototype.onGeometryAllocate = function (ev) {
-
- // Prevent allocate event listener from firing multiple times
- this.removeEventListener( 'allocate', this.onGeometryAllocate);
-
- if (this.hasOwnProperty('vertices')) {
- var attr = new THREE.Float32Attribute(this.vertices.length, 3);
- this.addAttribute('position', attr);
- this.createVertexProxies(this.vertices);
- }
- if (this.hasOwnProperty('faces')) {
- var idxattr = new THREE.Uint16Attribute(this.faces.length, 3);
- this.addAttribute('index', idxattr);
-
- if (this.faces.length > 0) {
- var hasnormals = (this.hasOwnProperty('normals') || this.faces[0].normal || this.faces[0].vertexNormals.length > 0);
- var hascolors = (this.hasOwnProperty('colors') || this.faces[0].color || this.faces[0].vertexColors.length > 0);
- var hastangents = (this.faces[0].vertexTangents.length > 0);
-
- if (hasnormals) {
- var normalattr = new THREE.Float32Attribute(this.vertices.length, 3);
- this.addAttribute('normal', normalattr);
- }
-
- if (hascolors) {
- var colorattr = new THREE.Float32Attribute(this.faces.length * 3, 3);
- this.addAttribute('color', colorattr);
- }
-
- if (hastangents) {
- var tangentattr = new THREE.Float32Attribute(this.faces.length * 3, 3);
- this.addAttribute('tangent', tangentattr);
- }
- }
-
- this.createFaceProxies(this.faces);
- }
-
- if (this.hasOwnProperty('faceVertexUvs')) {
-
- var uvattr = new THREE.Float32Attribute(this.faces.length * 3, 2);
- this.addAttribute('uv', uvattr);
- this.createUvProxies(this.faceVertexUvs[0]);
-
- }
-
- if (this.hasOwnProperty('skinIndices')) {
-
- var skinidxattr = new THREE.Float32Attribute(this.skinIndices.length, 4);
- this.addAttribute('skinIndex', skinidxattr);
- this.createSkinIndexProxies(this.skinIndices);
-
- }
-
- if (this.hasOwnProperty('skinWeights')) {
-
- var skinweightattr = new THREE.Float32Attribute(this.skinWeights.length, 4);
- this.addAttribute('skinWeight', skinweightattr);
- this.createSkinWeightProxies(this.skinWeights);
-
- }
-};
-
-THREE.ProxyGeometry.prototype.computeFaceNormals = function() {
-
- this.dispatchEvent( { type: 'allocate' } );
-
- return THREE.BufferGeometry.prototype.computeFaceNormals.call(this);
-
-};
-
-THREE.ProxyGeometry.prototype.computeVertexNormals = function() {
-
- this.dispatchEvent( { type: 'allocate' } );
-
- return THREE.BufferGeometry.prototype.computeVertexNormals.call(this);
-
-};
-
-THREE.ProxyGeometry.prototype.computeTangents = function() {
-
- this.dispatchEvent( { type: 'allocate' } );
-
- var ret = THREE.BufferGeometry.prototype.computeTangents.call(this);
-
- // FIXME - this doesn't work yet
- //this.createFaceVertexTangentProxies();
-
- return ret;
-
-};
-
-THREE.ProxyGeometry.prototype.computeBoundingSphere = function() {
-
- this.dispatchEvent( { type: 'allocate' } );
-
- return THREE.BufferGeometry.prototype.computeBoundingSphere.call(this);
-
-};
-
-THREE.ProxyGeometry.prototype.computeBoundingBox = function () {
-
- this.dispatchEvent( { type: 'allocate' } );
-
- return THREE.BufferGeometry.prototype.computeBoundingBox.call(this);
-
-};
-THREE.ProxyGeometry.prototype.clone = function () {
-
- var buff = THREE.BufferGeometry.prototype.clone.call(this);
- var geo = new THREE.ProxyGeometry();
- geo.attributes = buff.attributes;
- geo.offsets = buff.drawcalls;
-
- return geo;
-
-};
-
-THREE.EventDispatcher.prototype.apply( THREE.ProxyGeometry.prototype );
-
-THREE.ProxyGeometryIdCount = 0; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/TypedGeometry.js | @@ -1,120 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.TypedGeometry = function ( size ) {
-
- THREE.BufferGeometry.call( this );
-
- if ( size !== undefined ) {
-
- this.setArrays(
- new Float32Array( size * 3 * 3 ),
- new Float32Array( size * 3 * 3 ),
- new Float32Array( size * 3 * 2 )
- );
-
- }
-
-};
-
-THREE.TypedGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.TypedGeometry.prototype.constructor = THREE.TypedGeometry;
-
-THREE.TypedGeometry.prototype.setArrays = function ( vertices, normals, uvs ) {
-
- this.vertices = vertices;
- this.normals = normals;
- this.uvs = uvs;
-
- this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
- this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
- this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
-
- return this;
-
-};
-
-THREE.TypedGeometry.prototype.merge = ( function () {
-
- var offset = 0;
- var normalMatrix = new THREE.Matrix3();
-
- return function ( geometry, matrix, startOffset ) {
-
- if ( startOffset !== undefined ) offset = startOffset;
-
- var offset2 = offset * 2;
- var offset3 = offset * 3;
-
- var vertices = this.attributes.position.array;
- var normals = this.attributes.normal.array;
- var uvs = this.attributes.uv.array;
-
- if ( geometry instanceof THREE.TypedGeometry ) {
-
- var vertices2 = geometry.attributes.position.array;
- var normals2 = geometry.attributes.normal.array;
- var uvs2 = geometry.attributes.uv.array;
-
- for ( var i = 0, l = vertices2.length; i < l; i += 3 ) {
-
- vertices[ i + offset3 ] = vertices2[ i ];
- vertices[ i + offset3 + 1 ] = vertices2[ i + 1 ];
- vertices[ i + offset3 + 2 ] = vertices2[ i + 2 ];
-
- normals[ i + offset3 ] = normals2[ i ];
- normals[ i + offset3 + 1 ] = normals2[ i + 1 ];
- normals[ i + offset3 + 2 ] = normals2[ i + 2 ];
-
- uvs[ i + offset2 ] = uvs2[ i ];
- uvs[ i + offset2 + 1 ] = uvs2[ i + 1 ];
-
- }
-
- } else if ( geometry instanceof THREE.IndexedTypedGeometry ) {
-
- var indices2 = geometry.attributes.index.array;
- var vertices2 = geometry.attributes.position.array;
- var normals2 = geometry.attributes.normal.array;
- var uvs2 = geometry.attributes.uv.array;
-
- for ( var i = 0, l = indices2.length; i < l; i ++ ) {
-
- var index = indices2[ i ];
-
- var index3 = index * 3;
- var i3 = i * 3;
-
- vertices[ i3 + offset3 ] = vertices2[ index3 ];
- vertices[ i3 + offset3 + 1 ] = vertices2[ index3 + 1 ];
- vertices[ i3 + offset3 + 2 ] = vertices2[ index3 + 2 ];
-
- normals[ i3 + offset3 ] = normals2[ index3 ];
- normals[ i3 + offset3 + 1 ] = normals2[ index3 + 1 ];
- normals[ i3 + offset3 + 2 ] = normals2[ index3 + 2 ];
-
- var index2 = index * 2;
- var i2 = i * 2;
-
- uvs[ i2 + offset2 ] = uvs2[ index2 ];
- uvs[ i2 + offset2 + 1 ] = uvs2[ index2 + 1 ];
-
- }
-
- if ( matrix !== undefined ) {
-
- matrix.applyToVector3Array( vertices, offset3, indices2.length * 3 );
-
- normalMatrix.getNormalMatrix( matrix );
- normalMatrix.applyToVector3Array( normals, offset3, indices2.length * 3 );
-
- }
-
- offset += indices2.length;
-
- }
-
- };
-
-} )();
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/BoxGeometry2.js | @@ -1,114 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
- */
-
-THREE.BoxGeometry2 = function ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
-
- var scope = this;
-
- this.width = width;
- this.height = height;
- this.depth = depth;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
- this.depthSegments = depthSegments || 1;
-
- var width_half = this.width / 2;
- var height_half = this.height / 2;
- var depth_half = this.depth / 2;
-
- var vector = new THREE.Vector3();
-
- var vectors = [];
- var vertices = [];
-
- var addVertex = function ( a, b, c ) {
-
- vertices.push( vectors[ a ], vectors[ a + 1 ], vectors[ a + 2 ] );
- vertices.push( vectors[ b ], vectors[ b + 1 ], vectors[ b + 2 ] );
- vertices.push( vectors[ c ], vectors[ c + 1 ], vectors[ c + 2 ] );
-
- };
-
- buildPlane( 'z', 'y', - 1, - 1, this.depth, this.height, width_half, 0 ); // px
- buildPlane( 'z', 'y', 1, - 1, this.depth, this.height, - width_half, 1 ); // nx
- buildPlane( 'x', 'z', 1, 1, this.width, this.depth, height_half, 2 ); // py
- buildPlane( 'x', 'z', 1, - 1, this.width, this.depth, - height_half, 3 ); // ny
- buildPlane( 'x', 'y', 1, - 1, this.width, this.height, depth_half, 4 ); // pz
- buildPlane( 'x', 'y', - 1, - 1, this.width, this.height, - depth_half, 5 ); // nz
-
- function buildPlane( u, v, udir, vdir, width, height, depth, materialIndex ) {
-
- var w, ix, iy,
- gridX = scope.widthSegments,
- gridY = scope.heightSegments,
- width_half = width / 2,
- height_half = height / 2,
- offset = vectors.length;
-
- if ( ( u === 'x' && v === 'y' ) || ( u === 'y' && v === 'x' ) ) {
-
- w = 'z';
-
- } else if ( ( u === 'x' && v === 'z' ) || ( u === 'z' && v === 'x' ) ) {
-
- w = 'y';
- gridY = scope.depthSegments;
-
- } else if ( ( u === 'z' && v === 'y' ) || ( u === 'y' && v === 'z' ) ) {
-
- w = 'x';
- gridX = scope.depthSegments;
-
- }
-
- var gridX1 = gridX + 1,
- gridY1 = gridY + 1,
- segment_width = width / gridX,
- segment_height = height / gridY,
- normal = new THREE.Vector3();
-
- normal[ w ] = depth > 0 ? 1 : - 1;
-
- for ( iy = 0; iy < gridY1; iy ++ ) {
-
- for ( ix = 0; ix < gridX1; ix ++ ) {
-
- vector[ u ] = ( ix * segment_width - width_half ) * udir;
- vector[ v ] = ( iy * segment_height - height_half ) * vdir;
- vector[ w ] = depth;
-
- vectors.push( vector.x, vector.y, vector.z );
-
- }
-
- }
-
- for ( iy = 0; iy < gridY; iy ++ ) {
-
- for ( ix = 0; ix < gridX; ix ++ ) {
-
- var a = ix + gridX1 * iy;
- var b = ix + gridX1 * ( iy + 1 );
- var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
- var d = ( ix + 1 ) + gridX1 * iy;
-
- addVertex( a * 3 + offset, b * 3 + offset, d * 3 + offset );
- addVertex( b * 3 + offset, c * 3 + offset, d * 3 + offset );
-
- }
-
- }
-
- }
-
- THREE.Geometry2.call( this, vertices.length / 3 );
-
- this.vertices.set( vertices );
-
-};
-
-THREE.BoxGeometry2.prototype = Object.create( THREE.Geometry2.prototype );
-THREE.BoxGeometry2.prototype.constructor = THREE.BoxGeometry2; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry2.js | @@ -1,20 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry2 = function ( size ) {
-
- THREE.BufferGeometry.call( this );
-
- this.vertices = new THREE.Float32Attribute( size, 3 );
- this.normals = new THREE.Float32Attribute( size, 3 );
- this.uvs = new THREE.Float32Attribute( size, 2 );
-
- this.addAttribute( 'position', this.vertices );
- this.addAttribute( 'normal', this.normals );
- this.addAttribute( 'uv', this.uvs );
-
-};
-
-THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry2.prototype.constructor = THREE.Geometry2;
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry2Loader.js | @@ -1,67 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry2Loader = function ( manager ) {
-
- this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
-
-};
-
-THREE.Geometry2Loader.prototype = {
-
- constructor: THREE.Geometry2Loader,
-
- load: function ( url, onLoad, onProgress, onError ) {
-
- var scope = this;
-
- var loader = new THREE.XHRLoader();
- loader.setCrossOrigin( this.crossOrigin );
- loader.load( url, function ( text ) {
-
- onLoad( scope.parse( JSON.parse( text ) ) );
-
- } );
-
- },
-
- setCrossOrigin: function ( value ) {
-
- this.crossOrigin = value;
-
- },
-
- parse: function ( json ) {
-
- var geometry = new THREE.Geometry2( json.vertices.length / 3 );
-
- var attributes = [ 'vertices', 'normals', 'uvs' ];
- var boundingSphere = json.boundingSphere;
-
- for ( var key in attributes ) {
-
- var attribute = attributes[ key ];
- geometry[ attribute ].set( json[ attribute ] );
-
- }
-
- if ( boundingSphere !== undefined ) {
-
- var center = new THREE.Vector3();
-
- if ( boundingSphere.center !== undefined ) {
-
- center.fromArray( boundingSphere.center );
-
- }
-
- geometry.boundingSphere = new THREE.Sphere( center, boundingSphere.radius );
-
- }
-
- return geometry;
-
- }
-
-};
| true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry3.js | @@ -1,32 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry3 = function ( size ) {
-
- THREE.BufferGeometry.call( this );
-
- var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
- var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
- var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
-
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0; i < size; i ++ ) {
-
- this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
- this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
- this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
-
- }
-
- this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
-
-};
-
-THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry3.prototype.constructor = THREE.Geometry3;
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry4.js | @@ -1,85 +0,0 @@
-THREE.Geometry4 = function ( size ) {
-
- THREE.BufferGeometry.call( this );
-
- var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
- var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
- var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
-
- this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
-
- this.vertices = new THREE.VectorArrayProxy( this.attributes[ 'position' ] );
- this.normals = new THREE.VectorArrayProxy( this.attributes[ 'normal' ] );
- this.uvs = new THREE.VectorArrayProxy( this.attributes[ 'uv' ] );
-
-};
-THREE.Geometry4.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry4.prototype.constructor = THREE.Geometry4;
-
-THREE.VectorArrayProxy = function(attribute) {
-
- // Acts as a proxy for an array of vectors, by setting up accessors which return THREE.Vector*Proxy objects
-
- this.attribute = attribute;
-
- for (var i = 0, l = this.attribute.array.length / this.attribute.itemSize; i < l; i ++) {
-
- Object.defineProperty(this, i, {
- get: (function(i) { return function() { return this.getValue(i); }})(i),
- set: (function(i) { return function(v) { return this.setValue(i, v); }})(i),
- });
-
- }
-
-};
-
-THREE.VectorArrayProxy.prototype.getValue = function(i) {
-
- // Allocates a new THREE.Vector2Proxy or THREE.Vector3Proxy depending on the itemSize of our attribute
-
- var subarray = this.attribute.array.subarray(i * this.attribute.itemSize, (i + 1) * this.attribute.itemSize);
-
- switch (this.attribute.itemSize) {
-
- case 2:
- return new THREE.Vector2Proxy(subarray);
-
- case 3:
- return new THREE.Vector3Proxy(subarray);
-
- }
-
-};
-THREE.VectorArrayProxy.prototype.setValue = function(i, v) {
-
- var vec = this[i];
- vec.copy(v);
-
-};
-
-// Vector Proxy Objects
-
-THREE.Vector2Proxy = function(subarray) {
-
- this.subarray = subarray;
-
-};
-THREE.Vector2Proxy.prototype = Object.create( THREE.Vector2.prototype );
-THREE.Vector2Proxy.prototype.constructor = THREE.Vector2Proxy;
-Object.defineProperty(THREE.Vector2Proxy.prototype, 'x', { get: function() { return this.subarray[0]; }, set: function(v) { this.subarray[0] = v; } });
-Object.defineProperty(THREE.Vector2Proxy.prototype, 'y', { get: function() { return this.subarray[1]; }, set: function(v) { this.subarray[1] = v; } });
-
-
-THREE.Vector3Proxy = function(subarray) {
-
- this.subarray = subarray;
-
-};
-THREE.Vector3Proxy.prototype = Object.create( THREE.Vector3.prototype );
-THREE.Vector3Proxy.prototype.constructor = THREE.Vector3Proxy;
-
-Object.defineProperty(THREE.Vector3Proxy.prototype, 'x', { get: function() { return this.subarray[0]; }, set: function(v) { this.subarray[0] = v; } });
-Object.defineProperty(THREE.Vector3Proxy.prototype, 'y', { get: function() { return this.subarray[1]; }, set: function(v) { this.subarray[1] = v; } });
-Object.defineProperty(THREE.Vector3Proxy.prototype, 'z', { get: function() { return this.subarray[2]; }, set: function(v) { this.subarray[2] = v; } });
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry5.js | @@ -1,78 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry5 = function ( size ) {
-
- THREE.BufferGeometry.call( this );
-
- var verticesBuffer = new Float32Array( size * 3 );
- var normalsBuffer = new Float32Array( size * 3 );
- var uvsBuffer = new Float32Array( size * 2 );
-
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0; i < size; i ++ ) {
-
- this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
- this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
- this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
-
- }
-
- this.attributes[ 'position' ] = { array: verticesBuffer, itemSize: 3 };
- this.attributes[ 'normal' ] = { array: normalsBuffer, itemSize: 3 };
- this.attributes[ 'uv' ] = { array: uvsBuffer, itemSize: 2 };
-
-};
-
-THREE.Geometry5.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry5.prototype.constructor = THREE.Geometry5;
-
-THREE.TypedVector2 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
-THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
-
-Object.defineProperties( THREE.TypedVector2.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- }
-} );
-
-THREE.TypedVector3 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
-THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
-
-Object.defineProperties( THREE.TypedVector3.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'z': {
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- }
-} );
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/Geometry5b.js | @@ -1,76 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry5b = function ( bufferGeometry ) {
-
- THREE.BufferGeometry.call( this );
-
- this.attributes = bufferGeometry.attributes;
-
- var verticesBuffer = this.attributes.position.array;
- var normalsBuffer = this.attributes.normal.array;
- var uvsBuffer = this.attributes.uv.array;
-
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0, l = verticesBuffer.length / 3; i < l; i ++ ) {
-
- this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
- this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
- this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
-
- }
-
-};
-
-THREE.Geometry5b.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry5b.prototype.constructor = THREE.Geometry5b;
-
-THREE.TypedVector2 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
-THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
-
-Object.defineProperties( THREE.TypedVector2.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- }
-} );
-
-THREE.TypedVector3 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
-THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
-
-Object.defineProperties( THREE.TypedVector3.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'z': {
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- }
-} );
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/IndexedGeometry3.js | @@ -1,34 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.IndexedGeometry3 = function ( indices, size ) {
-
- THREE.BufferGeometry.call( this );
-
- var verticesBuffer = new ArrayBuffer( size * 3 * 4 );
- var normalsBuffer = new ArrayBuffer( size * 3 * 4 );
- var uvsBuffer = new ArrayBuffer( size * 2 * 4 );
-
- this.indices = new Uint16Array( indices );
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0; i < size; i ++ ) {
-
- this.vertices.push( new Float32Array( verticesBuffer, i * 3 * 4, 3 ) );
- this.normals.push( new Float32Array( normalsBuffer, i * 3 * 4, 3 ) );
- this.uvs.push( new Float32Array( uvsBuffer, i * 2 * 4, 2 ) );
-
- }
-
- this.attributes[ 'index' ] = { array: this.indices, itemSize: 1 };
- this.attributes[ 'position' ] = { array: new Float32Array( verticesBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'normal' ] = { array: new Float32Array( normalsBuffer, 0, size * 3 ), itemSize: 3 };
- this.attributes[ 'uv' ] = { array: new Float32Array( uvsBuffer, 0, size * 2 ), itemSize: 2 };
-
-};
-
-THREE.Geometry3.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.Geometry3.prototype.constructor = THREE.Geometry3;
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/IndexedGeometry5.js | @@ -1,80 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.IndexedGeometry5 = function ( indices, size ) {
-
- THREE.BufferGeometry.call( this );
-
- var verticesBuffer = new Float32Array( size * 3 );
- var normalsBuffer = new Float32Array( size * 3 );
- var uvsBuffer = new Float32Array( size * 2 );
-
- this.indices = new Uint16Array( indices );
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0; i < size; i ++ ) {
-
- this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
- this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
- this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
-
- }
-
- this.attributes[ 'index' ] = { array: this.indices, itemSize: 1 };
- this.attributes[ 'position' ] = { array: verticesBuffer, itemSize: 3 };
- this.attributes[ 'normal' ] = { array: normalsBuffer, itemSize: 3 };
- this.attributes[ 'uv' ] = { array: uvsBuffer, itemSize: 2 };
-
-};
-
-THREE.IndexedGeometry5.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.IndexedGeometry5.prototype.constructor = THREE.IndexedGeometry5;
-
-THREE.TypedVector2 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
-THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
-
-Object.defineProperties( THREE.TypedVector2.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- }
-} );
-
-THREE.TypedVector3 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
-THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
-
-Object.defineProperties( THREE.TypedVector3.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'z': {
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- }
-} );
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/IndexedPlaneGeometry5.js | @@ -1,83 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.IndexedPlaneGeometry5 = function ( width, height, widthSegments, heightSegments ) {
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var width_half = width / 2;
- var height_half = height / 2;
-
- var gridX = this.widthSegments;
- var gridY = this.heightSegments;
-
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
-
- var segment_width = this.width / gridX;
- var segment_height = this.height / gridY;
-
- var indices = gridX * gridY * 6;
- var vertices = gridX1 * gridY1;
-
- THREE.IndexedGeometry5.call( this, indices, vertices );
-
- var offset = 0;
-
- for ( var iy = 0; iy < gridY1; iy ++ ) {
-
- var y = iy * segment_height - height_half;
-
- for ( var ix = 0; ix < gridX1; ix ++ ) {
-
- var x = ix * segment_width - width_half;
-
- this.vertices[ offset ].x = x;
- this.vertices[ offset ].y = - y;
-
- this.normals[ offset ].z = 1;
-
- this.uvs[ offset ].x = ix / gridX;
- this.uvs[ offset ].y = iy / gridY;
-
- offset ++;
-
- }
-
- }
-
- var offset = 0;
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var a = ix + gridX1 * iy;
- var b = ix + gridX1 * ( iy + 1 );
- var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
- var d = ( ix + 1 ) + gridX1 * iy;
-
- this.indices[ offset ] = a;
- this.indices[ offset + 1 ] = b;
- this.indices[ offset + 2 ] = d;
-
- this.indices[ offset + 3 ] = b;
- this.indices[ offset + 4 ] = c;
- this.indices[ offset + 5 ] = d;
-
- offset += 6;
-
- }
-
- }
-
-};
-
-THREE.IndexedPlaneGeometry5.prototype = Object.create( THREE.IndexedGeometry5.prototype );
-THREE.IndexedPlaneGeometry5.prototype.constructor = THREE.IndexedPlaneGeometry5; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry.js | @@ -1,79 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry.call( this );
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var ix, iz;
- var width_half = width / 2;
- var height_half = height / 2;
-
- var gridX = this.widthSegments;
- var gridZ = this.heightSegments;
-
- var gridX1 = gridX + 1;
- var gridZ1 = gridZ + 1;
-
- var segment_width = this.width / gridX;
- var segment_height = this.height / gridZ;
-
- var normal = new THREE.Vector3( 0, 0, 1 );
-
- for ( iz = 0; iz < gridZ1; iz ++ ) {
-
- for ( ix = 0; ix < gridX1; ix ++ ) {
-
- var x = ix * segment_width - width_half;
- var y = iz * segment_height - height_half;
-
- this.vertices.push( new THREE.Vector3( x, - y, 0 ) );
-
- }
-
- }
-
- for ( iz = 0; iz < gridZ; iz ++ ) {
-
- for ( ix = 0; ix < gridX; ix ++ ) {
-
- var a = ix + gridX1 * iz;
- var b = ix + gridX1 * ( iz + 1 );
- var c = ( ix + 1 ) + gridX1 * ( iz + 1 );
- var d = ( ix + 1 ) + gridX1 * iz;
-
- var uva = new THREE.Vector2( ix / gridX, 1 - iz / gridZ );
- var uvb = new THREE.Vector2( ix / gridX, 1 - ( iz + 1 ) / gridZ );
- var uvc = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - ( iz + 1 ) / gridZ );
- var uvd = new THREE.Vector2( ( ix + 1 ) / gridX, 1 - iz / gridZ );
-
- var face = new THREE.Face3( a, b, d );
- face.normal.copy( normal );
- face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
-
- this.faces.push( face );
- this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
-
- face = new THREE.Face3( b, c, d );
- face.normal.copy( normal );
- face.vertexNormals.push( normal.clone(), normal.clone(), normal.clone() );
-
- this.faces.push( face );
- this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] );
-
- }
-
- }
-
-};
-
-THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.PlaneGeometry.prototype.constructor = THREE.PlaneGeometry; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry2.js | @@ -1,76 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneGeometry2 = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry2.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
-
- var vertices = this.vertices.array;
- var normals = this.normals.array;
- var uvs = this.uvs.array;
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var widthHalf = width / 2;
- var heightHalf = height / 2;
-
- var gridX = this.widthSegments;
- var gridY = this.heightSegments;
-
- var segmentWidth = this.width / gridX;
- var segmentHeight = this.height / gridY;
-
- var offset = 0;
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- var y1 = iy * segmentHeight - heightHalf;
- var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var x1 = ix * segmentWidth - widthHalf;
- var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
-
- vertices[ offset + 0 ] = x1;
- vertices[ offset + 1 ] = y1;
-
- vertices[ offset + 3 ] = x2;
- vertices[ offset + 4 ] = y1;
-
- vertices[ offset + 6 ] = x1;
- vertices[ offset + 7 ] = y2;
-
- normals[ offset + 2 ] = 1;
- normals[ offset + 5 ] = 1;
- normals[ offset + 8 ] = 1;
-
- vertices[ offset + 9 ] = x2;
- vertices[ offset + 10 ] = y1;
-
- vertices[ offset + 12 ] = x2;
- vertices[ offset + 13 ] = y2;
-
- vertices[ offset + 15 ] = x1;
- vertices[ offset + 16 ] = y2;
-
- normals[ offset + 11 ] = 1;
- normals[ offset + 13 ] = 1;
- normals[ offset + 17 ] = 1;
-
- offset += 18;
-
- }
-
- }
-
-};
-
-THREE.PlaneGeometry2.prototype = Object.create( THREE.Geometry2.prototype );
-THREE.PlaneGeometry2.prototype.constructor = THREE.PlaneGeometry2; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry2b.js | @@ -1,66 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneGeometry2b = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry2.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
-
- var vertices = this.vertices;
- var normals = this.normals;
- var uvs = this.uvs;
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var widthHalf = width / 2;
- var heightHalf = height / 2;
-
- var gridX = this.widthSegments;
- var gridY = this.heightSegments;
-
- var segmentWidth = this.width / gridX;
- var segmentHeight = this.height / gridY;
-
- var index = 0;
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- var y1 = iy * segmentHeight - heightHalf;
- var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var x1 = ix * segmentWidth - widthHalf;
- var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
-
- this.vertices.setXY( index + 0, x1, y1 );
- this.vertices.setXY( index + 1, x2, y1 );
- this.vertices.setXY( index + 2, x1, y2 );
-
- this.vertices.setXY( index + 3, x2, y1 );
- this.vertices.setXY( index + 4, x2, y2 );
- this.vertices.setXY( index + 5, x1, y2 );
-
- this.normals.setZ( index + 0, 1 );
- this.normals.setZ( index + 1, 1 );
- this.normals.setZ( index + 2, 1 );
-
- this.normals.setZ( index + 3, 1 );
- this.normals.setZ( index + 4, 1 );
- this.normals.setZ( index + 5, 1 );
-
- index += 6;
-
- }
-
- }
-
-};
-
-THREE.PlaneGeometry2b.prototype = Object.create( THREE.Geometry2.prototype );
-THREE.PlaneGeometry2b.prototype.constructor = THREE.PlaneGeometry2b; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry3.js | @@ -1,76 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneGeometry3 = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry3.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
-
- var vertices = this.vertices;
- var normals = this.normals;
- var uvs = this.uvs;
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var widthHalf = width / 2;
- var heightHalf = height / 2;
-
- var gridX = this.widthSegments;
- var gridY = this.heightSegments;
-
- var segmentWidth = this.width / gridX;
- var segmentHeight = this.height / gridY;
-
- var offset = 0;
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- var y1 = iy * segmentHeight - heightHalf;
- var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var x1 = ix * segmentWidth - widthHalf;
- var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
-
- vertices[ offset + 0 ][ 0 ] = x1;
- vertices[ offset + 0 ][ 1 ] = y1;
-
- vertices[ offset + 1 ][ 0 ] = x2;
- vertices[ offset + 1 ][ 1 ] = y1;
-
- vertices[ offset + 2 ][ 0 ] = x1;
- vertices[ offset + 2 ][ 1 ] = y2;
-
- normals[ offset + 0 ][ 2 ] = 1;
- normals[ offset + 1 ][ 2 ] = 1;
- normals[ offset + 2 ][ 2 ] = 1;
-
- vertices[ offset + 3 ][ 0 ] = x2;
- vertices[ offset + 3 ][ 1 ] = y1;
-
- vertices[ offset + 4 ][ 0 ] = x2;
- vertices[ offset + 4 ][ 1 ] = y2;
-
- vertices[ offset + 5 ][ 0 ] = x1;
- vertices[ offset + 5 ][ 1 ] = y2;
-
- normals[ offset + 3 ][ 2 ] = 1;
- normals[ offset + 4 ][ 2 ] = 1;
- normals[ offset + 5 ][ 2 ] = 1;
-
- offset += 6;
-
- }
-
- }
-
-};
-
-THREE.PlaneGeometry3.prototype = Object.create( THREE.Geometry3.prototype );
-THREE.PlaneGeometry3.prototype.constructor = THREE.PlaneGeometry3; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry5.js | @@ -1,66 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
- */
-
-THREE.PlaneGeometry5 = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry5.call( this, ( widthSegments * heightSegments ) * 2 * 3 );
-
- var vertices = this.vertices;
- var normals = this.normals;
- var uvs = this.uvs;
-
- this.width = width;
- this.height = height;
-
- this.widthSegments = widthSegments || 1;
- this.heightSegments = heightSegments || 1;
-
- var widthHalf = width / 2;
- var heightHalf = height / 2;
-
- var gridX = this.widthSegments;
- var gridY = this.heightSegments;
-
- var segmentWidth = this.width / gridX;
- var segmentHeight = this.height / gridY;
-
- var offset = 0;
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- var y1 = iy * segmentHeight - heightHalf;
- var y2 = ( iy + 1 ) * segmentHeight - heightHalf;
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var x1 = ix * segmentWidth - widthHalf;
- var x2 = ( ix + 1 ) * segmentWidth - widthHalf;
-
- vertices[ offset + 0 ].set( x1, y1, 0 );
- vertices[ offset + 1 ].set( x2, y1, 0 );
- vertices[ offset + 2 ].set( x1, y2, 0 );
-
- normals[ offset + 0 ].z = 1;
- normals[ offset + 1 ].z = 1;
- normals[ offset + 2 ].z = 1;
-
- vertices[ offset + 3 ].set( x2, y1, 0 );
- vertices[ offset + 4 ].set( x2, y2, 0 );
- vertices[ offset + 5 ].set( x1, y2, 0 );
-
- normals[ offset + 3 ].z = 1;
- normals[ offset + 4 ].z = 1;
- normals[ offset + 5 ].z = 1;
-
- offset += 6;
-
- }
-
- }
-
-};
-
-THREE.PlaneGeometry5.prototype = Object.create( THREE.Geometry5.prototype );
-THREE.PlaneGeometry5.prototype.constructor = THREE.PlaneGeometry5; | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry6.js | @@ -1,30 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.PlaneGeometry6 = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.PlaneBufferGeometry.call( this, width, height, widthSegments, heightSegments );
-
- var indices = this.attributes.index.array;
- var vertices = this.attributes.position.array;
- var normals = this.attributes.normal.array;
- var uvs = this.attributes.uv.array;
-
- this.indices = indices;
- this.vertices = [];
- this.normals = [];
- this.uvs = [];
-
- for ( var i = 0, l = vertices.length / 3; i < l; i ++ ) {
-
- this.vertices.push( new THREE.TypedVector3( vertices, i * 3 ) );
- this.normals.push( new THREE.TypedVector3( normals, i * 3 ) );
- this.uvs.push( new THREE.TypedVector2( uvs, i * 2 ) );
-
- }
-
-};
-
-THREE.PlaneGeometry6.prototype = Object.create( THREE.PlaneBufferGeometry.prototype );
-THREE.PlaneGeometry6.prototype.constructor = THREE.PlaneGeometry6;
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/PlaneGeometry99.js | @@ -1,93 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.PlaneGeometry99 = function ( width, height, widthSegments, heightSegments ) {
-
- THREE.Geometry99.call( this );
-
- this.parameters = {
- width: width,
- height: height,
- widthSegments: widthSegments,
- heightSegments: heightSegments
- };
-
- var width_half = width / 2;
- var height_half = height / 2;
-
- var gridX = widthSegments || 1;
- var gridY = heightSegments || 1;
-
- var gridX1 = gridX + 1;
- var gridY1 = gridY + 1;
-
- var segment_width = width / gridX;
- var segment_height = height / gridY;
-
- var vertices = new Float32Array( gridX1 * gridY1 * 3 );
- var normals = new Float32Array( gridX1 * gridY1 * 3 );
- var uvs = new Float32Array( gridX1 * gridY1 * 2 );
-
- var offset = 0;
- var offset2 = 0;
-
- for ( var iy = 0; iy < gridY1; iy ++ ) {
-
- var y = iy * segment_height - height_half;
-
- for ( var ix = 0; ix < gridX1; ix ++ ) {
-
- var x = ix * segment_width - width_half;
-
- vertices[ offset ] = x;
- vertices[ offset + 1 ] = - y;
-
- normals[ offset + 2 ] = 1;
-
- uvs[ offset2 ] = ix / gridX;
- uvs[ offset2 + 1 ] = 1 - ( iy / gridY );
-
- offset += 3;
- offset2 += 2;
-
- }
-
- }
-
- offset = 0;
-
- var indices = new Uint16Array( gridX * gridY * 6 );
-
- for ( var iy = 0; iy < gridY; iy ++ ) {
-
- for ( var ix = 0; ix < gridX; ix ++ ) {
-
- var a = ix + gridX1 * iy;
- var b = ix + gridX1 * ( iy + 1 );
- var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
- var d = ( ix + 1 ) + gridX1 * iy;
-
- indices[ offset ] = a;
- indices[ offset + 1 ] = b;
- indices[ offset + 2 ] = d;
-
- indices[ offset + 3 ] = b;
- indices[ offset + 4 ] = c;
- indices[ offset + 5 ] = d;
-
- offset += 6;
-
- }
-
- }
-
- this.attributes[ 'index' ] = { array: indices, itemSize: 1 };
- this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
- this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
- this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
-
-};
-
-THREE.PlaneGeometry99.prototype = Object.create( THREE.Geometry99.prototype );
-THREE.PlaneGeometry99.prototype.constructor = THREE.PlaneGeometry99;
\ No newline at end of file | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/benchmark/TypedGeometry.js | @@ -1,178 +0,0 @@
-THREE.TypedVector2 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset * 2;
-
-};
-
-THREE.TypedVector2.prototype = {
-
- constructor: THREE.TypedVector2,
-
- get x () {
-
- return this.array[ this.offset ];
-
- },
-
- set x ( value ) {
-
- this.array[ this.offset ] = value;
-
- },
-
- get y () {
-
- return this.array[ this.offset + 1 ];
-
- },
-
- set y ( value ) {
-
- this.array[ this.offset + 1 ] = value;
-
- },
-
- set: function ( x, y ) {
-
- this.array[ this.offset ] = x;
- this.array[ this.offset + 1 ] = y;
- return this;
-
- }
-
-};
-
-THREE.TypedVector3 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset * 3;
-
-};
-
-THREE.TypedVector3.prototype = {
-
- constructor: THREE.TypedVector3,
-
- get x () {
-
- return this.array[ this.offset ];
-
- },
-
- set x ( value ) {
-
- this.array[ this.offset ] = value;
-
- },
-
- get y () {
-
- return this.array[ this.offset + 1 ];
-
- },
-
- set y ( value ) {
-
- this.array[ this.offset + 1 ] = value;
-
- },
-
- get z () {
-
- return this.array[ this.offset + 2 ];
-
- },
-
- set z ( value ) {
-
- this.array[ this.offset + 2 ] = value;
-
- },
-
- set: function ( x, y, z ) {
-
- this.array[ this.offset ] = x;
- this.array[ this.offset + 1 ] = y;
- this.array[ this.offset + 2 ] = z;
- return this;
-
- },
-
- toString: function () {
-
- return '[' + this.array[ this.offset ] + ',' + this.array[ this.offset + 1 ] + ',' + this.array[ this.offset + 2 ] + ']';
-
- }
-
-};
-
-THREE.TypedFace = function ( positions, normals, uvs, offset ) {
-
- this.positions = positions;
- this.normals = normals;
- this.uvs = uvs;
- this.offset = offset * 3;
-
-};
-
-THREE.TypedFace.prototype = {
-
- constructor: THREE.TypedFace,
-
- vertex: function ( index ) {
-
- return new THREE.TypedVector3( this.positions, this.offset + index );
-
- },
-
- normal: function ( index ) {
-
- return new THREE.TypedVector3( this.normals, this.offset + index );
-
- },
-
- uv: function ( index ) {
-
- return new THREE.TypedVector2( this.uvs, this.offset + index );
-
- }
-
-};
-
-
-THREE.TypedGeometry = function ( size ) {
-
- this.id = THREE.GeometryIdCount ++;
- this.uuid = THREE.Math.generateUUID();
-
- this.name = '';
-
- this.positions = new Float32Array( size * 3 * 3 );
- this.normals = new Float32Array( size * 3 * 3 );
- this.uvs = new Float32Array( size * 3 * 2 );
-
- this.boundingBox = null;
- this.boundingSphere = null;
-
-};
-
-THREE.TypedGeometry.prototype = {
-
- constructor: THREE.TypedGeometry,
-
- face: function ( index ) {
-
- return new THREE.TypedFace( this.positions, this.normals, this.uvs, index );
-
- },
-
- dispose: function () {
-
- this.dispatchEvent( { type: 'dispose' } );
-
- }
-
-};
-
-THREE.EventDispatcher.prototype.apply( THREE.TypedGeometry.prototype ); | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/MultiColor.js | @@ -1,39 +0,0 @@
-// Allows updating of multiple THREE.Color objects with the same value
-// Used for face.color -> face.vertexColor[] compatibility layer for non-indexed geometry
-
-THREE.MultiColor = function(links) {
-
- this.links = links;
-
-};
-
-THREE.MultiColor.prototype = Object.create( THREE.Color.prototype );
-THREE.MultiColor.prototype.constructor = THREE.MultiColor;
-
-THREE.MultiColor.prototype.setAll = function(axis, value) {
-
- for (var i = 0, l = this.links.length; i < l; i ++) {
-
- this.links[i][axis] = value;
-
- }
-
-};
-
-// Getters return value from the first linked color
-// Setters set the same value for all linked colors
-Object.defineProperties( THREE.MultiColor.prototype, {
- 'r': {
- get: function () { return (this.links[0] ? this.links[0].r : 0); },
- set: function ( v ) { this.setAll('r', v); }
- },
- 'g': {
- get: function () { return (this.links[0] ? this.links[0].g : 0); },
- set: function ( v ) { this.setAll('g', v); }
- },
- 'b': {
- get: function () { return (this.links[0] ? this.links[0].b : 0); },
- set: function ( v ) { this.setAll('b', v); }
- }
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/MultiVector3.js | @@ -1,40 +0,0 @@
-// Allows updating of multiple THREE.Vector3 objects with the same value
-// Used for face.normal -> face.vertexNormal[] compatibility layer for FlatShading
-
-THREE.MultiVector3 = function(links) {
-
- this.links = links;
-
-};
-
-THREE.MultiVector3.prototype = Object.create( THREE.Vector3.prototype );
-THREE.MultiVector3.prototype.constructor = THREE.MultiVector3;
-
-THREE.MultiVector3.prototype.setAll = function(axis, value) {
-
- for (var i = 0, l = this.links.length; i < l; i ++) {
-
- this.links[i][axis] = value;
-
- }
-
-};
-
-// Getters return value from the first linked vector
-// Setters set the same value for all linked vectors
-Object.defineProperties( THREE.MultiVector3.prototype, {
- 'x': {
- get: function () { return (this.links[0] ? this.links[0].x : 0); },
- set: function ( v ) { this.setAll('x', v); }
- },
- 'y': {
- get: function () { return (this.links[0] ? this.links[0].y : 0); },
- set: function ( v ) { this.setAll('y', v); }
- },
- 'z': {
- get: function () { return (this.links[0] ? this.links[0].z : 0); },
- set: function ( v ) { this.setAll('z', v); }
- }
-} );
-
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/ProxyColor.js | @@ -1,33 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * @author jbaicoianu / http://baicoianu.com/
- */
-
-THREE.ProxyColor = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.ProxyColor.prototype = Object.create( THREE.Color.prototype );
-THREE.ProxyColor.prototype.constructor = THREE.ProxyColor;
-
-Object.defineProperties( THREE.ProxyColor.prototype, {
- 'r': {
- enumerable: true,
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'g': {
- enumerable: true,
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'b': {
- enumerable: true,
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- }
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/ProxyFace3.js | @@ -1,40 +0,0 @@
-/**
- * @author jbaicoianu / http://baicoianu.com/
- */
-
-THREE.ProxyFace3 = function ( array, offset, vertexNormals, vertexColors, vertexTangents ) {
-
- this.array = array;
- this.offset = offset;
- this.vertexNormals = vertexNormals || [];
- this.vertexColors = vertexColors || [];
- this.vertexTangents = vertexTangents || [];
-
- this.normal = new THREE.MultiVector3( this.vertexNormals );
- this.color = new THREE.MultiColor( this.vertexColors );
-
- //THREE.Face3.call( this, array[offset], array[offset+1], array[offset+2] /*, normal, color, materialIndex */);
-
-};
-
-THREE.ProxyFace3.prototype = Object.create( THREE.Face3.prototype );
-THREE.ProxyFace3.prototype.constructor = THREE.ProxyFace3;
-
-Object.defineProperties( THREE.ProxyFace3.prototype, {
- 'a': {
- enumerable: true,
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'b': {
- enumerable: true,
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'c': {
- enumerable: true,
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- },
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/ProxyVector2.js | @@ -1,26 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * @author jbaicoianu / http://baicoianu.com/
- */
-
-THREE.ProxyVector2 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype );
-THREE.ProxyVector2.prototype.constructor = THREE.ProxyVector2;
-
-Object.defineProperties( THREE.ProxyVector2.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- }
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/ProxyVector3.js | @@ -1,30 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * @author jbaicoianu / http://baicoianu.com/
- */
-
-THREE.ProxyVector3 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype );
-THREE.ProxyVector3.prototype.constructor = THREE.ProxyVector3;
-
-Object.defineProperties( THREE.ProxyVector3.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'z': {
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- }
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/proxies/ProxyVector4.js | @@ -1,34 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- * @author jbaicoianu / http://baicoianu.com/
- */
-
-THREE.ProxyVector4 = function ( array, offset ) {
-
- this.array = array;
- this.offset = offset;
-
-};
-
-THREE.ProxyVector4.prototype = Object.create( THREE.Vector4.prototype );
-THREE.ProxyVector4.prototype.constructor = THREE.ProxyVector4;
-
-Object.defineProperties( THREE.ProxyVector4.prototype, {
- 'x': {
- get: function () { return this.array[ this.offset ]; },
- set: function ( v ) { this.array[ this.offset ] = v; }
- },
- 'y': {
- get: function () { return this.array[ this.offset + 1 ]; },
- set: function ( v ) { this.array[ this.offset + 1 ] = v; }
- },
- 'z': {
- get: function () { return this.array[ this.offset + 2 ]; },
- set: function ( v ) { this.array[ this.offset + 2 ] = v; }
- },
- 'w': {
- get: function () { return this.array[ this.offset + 3 ]; },
- set: function ( v ) { this.array[ this.offset + 3 ] = v; }
- }
-} );
- | true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/webgl_geometry_minecraft.html | @@ -49,10 +49,6 @@
<script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script>
- <script src="js/wip/TypedGeometry.js"></script>
- <script src="js/wip/IndexedTypedGeometry.js"></script>
- <script src="js/wip/PlaneTypedGeometry.js"></script>
-
<script>
if ( ! Detector.webgl ) {
@@ -96,38 +92,44 @@
var matrix = new THREE.Matrix4();
- var pxGeometry = new THREE.PlaneTypedGeometry( 100, 100 );
- pxGeometry.uvs[ 1 ] = 0.5;
- pxGeometry.uvs[ 3 ] = 0.5;
+ var pxGeometry = new THREE.PlaneBufferGeometry( 100, 100 );
+ pxGeometry.attributes.uv.array[ 1 ] = 0.5;
+ pxGeometry.attributes.uv.array[ 3 ] = 0.5;
pxGeometry.applyMatrix( matrix.makeRotationY( Math.PI / 2 ) );
pxGeometry.applyMatrix( matrix.makeTranslation( 50, 0, 0 ) );
- var nxGeometry = new THREE.PlaneTypedGeometry( 100, 100 );
- nxGeometry.uvs[ 1 ] = 0.5;
- nxGeometry.uvs[ 3 ] = 0.5;
+ var nxGeometry = new THREE.PlaneBufferGeometry( 100, 100 );
+ nxGeometry.attributes.uv.array[ 1 ] = 0.5;
+ nxGeometry.attributes.uv.array[ 3 ] = 0.5;
nxGeometry.applyMatrix( matrix.makeRotationY( - Math.PI / 2 ) );
nxGeometry.applyMatrix( matrix.makeTranslation( - 50, 0, 0 ) );
- var pyGeometry = new THREE.PlaneTypedGeometry( 100, 100 );
- pyGeometry.uvs[ 5 ] = 0.5;
- pyGeometry.uvs[ 7 ] = 0.5;
+ var pyGeometry = new THREE.PlaneBufferGeometry( 100, 100 );
+ pyGeometry.attributes.uv.array[ 5 ] = 0.5;
+ pyGeometry.attributes.uv.array[ 7 ] = 0.5;
pyGeometry.applyMatrix( matrix.makeRotationX( - Math.PI / 2 ) );
pyGeometry.applyMatrix( matrix.makeTranslation( 0, 50, 0 ) );
- var pzGeometry = new THREE.PlaneTypedGeometry( 100, 100 );
- pzGeometry.uvs[ 1 ] = 0.5;
- pzGeometry.uvs[ 3 ] = 0.5;
+ var pzGeometry = new THREE.PlaneBufferGeometry( 100, 100 );
+ pzGeometry.attributes.uv.array[ 1 ] = 0.5;
+ pzGeometry.attributes.uv.array[ 3 ] = 0.5;
pzGeometry.applyMatrix( matrix.makeTranslation( 0, 0, 50 ) );
- var nzGeometry = new THREE.PlaneTypedGeometry( 100, 100 );
- nzGeometry.uvs[ 1 ] = 0.5;
- nzGeometry.uvs[ 3 ] = 0.5;
+ var nzGeometry = new THREE.PlaneBufferGeometry( 100, 100 );
+ nzGeometry.attributes.uv.array[ 1 ] = 0.5;
+ nzGeometry.attributes.uv.array[ 3 ] = 0.5;
nzGeometry.applyMatrix( matrix.makeRotationY( Math.PI ) );
nzGeometry.applyMatrix( matrix.makeTranslation( 0, 0, -50 ) );
//
- var geometry = new THREE.TypedGeometry( worldWidth * worldDepth * 2 * 5 ); // 2 triangles, 5 possible sides
+ // BufferGeometry cannot be merged yet.
+ var tmpGeometry = new THREE.Geometry();
+ var pxTmpGeometry = new THREE.Geometry().fromBufferGeometry( pxGeometry );
+ var nxTmpGeometry = new THREE.Geometry().fromBufferGeometry( nxGeometry );
+ var pyTmpGeometry = new THREE.Geometry().fromBufferGeometry( pyGeometry );
+ var pzTmpGeometry = new THREE.Geometry().fromBufferGeometry( pzGeometry );
+ var nzTmpGeometry = new THREE.Geometry().fromBufferGeometry( nzGeometry );
for ( var z = 0; z < worldDepth; z ++ ) {
@@ -146,36 +148,37 @@
var pz = getY( x, z + 1 );
var nz = getY( x, z - 1 );
- geometry.merge( pyGeometry, matrix );
+ tmpGeometry.merge( pyTmpGeometry, matrix );
- if ( ( px != h && px != h + 1 ) || x == 0 ) {
+ if ( ( px !== h && px !== h + 1 ) || x === 0 ) {
- geometry.merge( pxGeometry, matrix );
+ tmpGeometry.merge( pxTmpGeometry, matrix );
}
- if ( ( nx != h && nx != h + 1 ) || x == worldWidth - 1 ) {
+ if ( ( nx !== h && nx !== h + 1 ) || x === worldWidth - 1 ) {
- geometry.merge( nxGeometry, matrix );
+ tmpGeometry.merge( nxTmpGeometry, matrix );
}
- if ( ( pz != h && pz != h + 1 ) || z == worldDepth - 1 ) {
+ if ( ( pz !== h && pz !== h + 1 ) || z === worldDepth - 1 ) {
- geometry.merge( pzGeometry, matrix );
+ tmpGeometry.merge( pzTmpGeometry, matrix );
}
- if ( ( nz != h && nz != h + 1 ) || z == 0 ) {
+ if ( ( nz !== h && nz !== h + 1 ) || z === 0 ) {
- geometry.merge( nzGeometry, matrix );
+ tmpGeometry.merge( nzTmpGeometry, matrix );
}
}
}
+ var geometry = new THREE.BufferGeometry().fromGeometry( tmpGeometry );
geometry.computeBoundingSphere();
var texture = THREE.ImageUtils.loadTexture( 'textures/minecraft/atlas.png' );
@@ -230,7 +233,7 @@
for ( var j = 0; j < 4; j ++ ) {
- if ( j == 0 ) for ( var i = 0; i < size; i ++ ) data[ i ] = 0;
+ if ( j === 0 ) for ( var i = 0; i < size; i ++ ) data[ i ] = 0;
for ( var i = 0; i < size; i ++ ) {
@@ -240,7 +243,7 @@
}
- quality *= 4
+ quality *= 4;
}
| true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | package.json | @@ -28,6 +28,7 @@
},
"homepage": "http://threejs.org/",
"devDependencies": {
- "jscs": "^1.13.1"
+ "jscs": "^1.13.1",
+ "lodash": "^3.10.0"
}
} | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/SmartComparer.js | @@ -0,0 +1,177 @@
+// Smart comparison of three.js objects.
+// Identifies significant differences between two objects.
+// Performs deep comparison.
+// Comparison stops after the first difference is found.
+// Provides an explanation for the failure.
+function SmartComparer() {
+ 'use strict';
+
+ // Diagnostic message, when comparison fails.
+ var message;
+
+ // Keys to skip during object comparison.
+ var omitKeys = [ 'id', 'uuid' ];
+
+ return {
+
+ areEqual: areEqual,
+
+ getDiagnostic: function() {
+
+ return message;
+
+ }
+
+ };
+
+
+ // val1 - first value to compare (typically the actual value)
+ // val2 - other value to compare (typically the expected value)
+ function areEqual( val1, val2 ) {
+
+ // Values are strictly equal.
+ if ( val1 === val2 ) return true;
+
+ // Null or undefined values.
+ /* jshint eqnull:true */
+ if ( val1 == null || val2 == null ) {
+
+ if ( val1 != val2 ) {
+
+ return makeFail( 'One value is undefined or null', val1, val2 );
+
+ }
+
+ // Both null / undefined.
+ return true;
+ }
+
+ // Don't compare functions.
+ if ( _.isFunction( val1 ) && _.isFunction( val2 ) ) return true;
+
+ // Array comparison.
+ var arrCmp = compareArrays( val1, val2 );
+ if ( arrCmp !== undefined ) return arrCmp;
+
+ // Has custom equality comparer.
+ if ( val1.equals ) {
+
+ if ( val1.equals( val2 ) ) return true;
+
+ return makeFail( 'Comparison with .equals method returned false' );
+
+ }
+
+ // Object comparison.
+ var objCmp = compareObjects( val1, val2 );
+ if ( objCmp !== undefined ) return objCmp;
+
+ // if (JSON.stringify( val1 ) == JSON.stringify( val2 ) ) return true;
+
+ // Continue with default comparison.
+ if ( _.isEqual( val1, val2 ) ) return true;
+
+ // Object differs (unknown reason).
+ return makeFail( 'Values differ', val1, val2 );
+ }
+
+
+ function compareArrays( val1, val2 ) {
+
+ var isArr1 = Array.isArray( val1 );
+ var isArr2 = Array.isArray( val2 );
+
+ // Compare type.
+ if ( isArr1 !== isArr2 ) return makeFail( 'Values are not both arrays' );
+
+ // Not arrays. Continue.
+ if ( !isArr1 ) return undefined;
+
+ // Compare length.
+ var N1 = val1.length;
+ var N2 = val2.length;
+ if ( N1 !== val2.length ) return makeFail( 'Array length differs', N1, N2 );
+
+ // Compare content at each index.
+ for ( var i = 0; i < N1; i ++ ) {
+
+ var cmp = areEqual( val1[ i ], val2[ i ] );
+ if ( !cmp ) return addContext( 'array index "' + i + '"' );
+
+ }
+
+ // Arrays are equal.
+ return true;
+ }
+
+
+ function compareObjects( val1, val2 ) {
+
+ var isObj1 = _.isObject( val1 );
+ var isObj2 = _.isObject( val2 );
+
+ // Compare type.
+ if ( isObj1 !== isObj2 ) return makeFail( 'Values are not both objects' );
+
+ // Not objects. Continue.
+ if ( !isObj1 ) return undefined;
+
+ // Compare keys.
+ var keys1 = _( val1 ).keys().difference( omitKeys ).value();
+ var keys2 = _( val2 ).keys().difference( omitKeys ).value();
+
+ var missingActual = _.difference( keys1, keys2 );
+ if ( missingActual.length !== 0 ) {
+
+ return makeFail( 'Property "' + missingActual[0] + '" is unexpected.' );
+
+ }
+
+ var missingExpected = _.difference( keys2, keys1 );
+ if ( missingExpected.length !== 0 ) {
+
+ return makeFail( 'Property "' + missingExpected[0] + '" is missing.' );
+
+ }
+
+ // Keys are the same. For each key, compare content until a difference is found.
+ var hadDifference = _.any( keys1, function ( key ) {
+
+ var prop1 = val1[key];
+ var prop2 = val2[key];
+
+ // Compare property content.
+ var eq = areEqual( prop1, prop2 );
+
+ // In case of failure, an message should already be set.
+ // Add context to low level message.
+ if ( !eq ) addContext( 'property "' + key + '"' );
+ return !eq;
+
+ });
+
+ return ! hadDifference;
+
+ }
+
+
+ function makeFail( msg, val1, val2 ) {
+
+ message = msg;
+ if ( arguments.length > 1) message += " (" + val1 + " vs " + val2 + ")";
+
+ return false;
+
+ }
+
+ function addContext( msg ) {
+
+ // There should already be a validation message. Add more context to it.
+ message = message || "Error";
+ message += ", at " + msg;
+
+ return false;
+
+ }
+
+} | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/ImageUtils.test.js | @@ -63,21 +63,21 @@ QUnit.test( "test cached texture", function( assert ) {
assert.ok( rtex1.image !== undefined, "texture 1 image is loaded" );
assert.equal( rtex1, tex1, "texture 1 callback is equal to return" );
-
+
var rtex2 = THREE.ImageUtils.loadTexture( good_url, undefined, function ( tex2 ) {
-
+
assert.ok( rtex2 !== undefined, "cached callback is async" );
assert.ok( rtex2.image !== undefined, "texture 2 image is loaded" );
assert.equal( rtex2, tex2, "texture 2 callback is equal to return" );
-
+
done();
});
assert.ok( rtex2, "texture 2 return is defined" );
});
-
+
assert.ok( rtex1, "texture 1 return is defined" );
assert.ok( rtex1.image === undefined, "texture 1 image is not loaded" );
| true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/BoxGeometry.tests.js | @@ -0,0 +1,38 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ width: 10,
+ height: 20,
+ depth: 30,
+ widthSegments: 2,
+ heightSegments: 3,
+ depthSegments: 4,
+ };
+
+ var geometries;
+ var box, cube, boxWithSegments;
+
+ QUnit.module( "Extras - Geometries - BoxGeometry", {
+
+ beforeEach: function() {
+
+ box = new THREE.BoxGeometry( parameters.width, parameters.height, parameters.depth );
+ cube = new THREE.CubeGeometry( parameters.width, parameters.height, parameters.depth );
+ boxWithSegments = new THREE.BoxGeometry( parameters.width, parameters.height, parameters.depth,
+ parameters.widthSegments, parameters.heightSegments, parameters.depthSegments );
+
+ geometries = [ box, cube, boxWithSegments ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/CircleBufferGeometry.tests.js | @@ -0,0 +1,38 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ segments: 20,
+ thetaStart: 0.1,
+ thetaLength: 0.2
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - CircleBufferGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.CircleBufferGeometry(),
+ new THREE.CircleBufferGeometry( parameters.radius ),
+ new THREE.CircleBufferGeometry( parameters.radius, parameters.segments ),
+ new THREE.CircleBufferGeometry( parameters.radius, parameters.segments, parameters.thetaStart ),
+ new THREE.CircleBufferGeometry( parameters.radius, parameters.segments, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/CircleGeometry.tests.js | @@ -0,0 +1,38 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ segments: 20,
+ thetaStart: 0.1,
+ thetaLength: 0.2
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - CircleGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.CircleGeometry(),
+ new THREE.CircleGeometry( parameters.radius ),
+ new THREE.CircleGeometry( parameters.radius, parameters.segments ),
+ new THREE.CircleGeometry( parameters.radius, parameters.segments, parameters.thetaStart ),
+ new THREE.CircleGeometry( parameters.radius, parameters.segments, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/CylinderGeometry.tests.js | @@ -0,0 +1,46 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radiusTop: 10,
+ radiusBottom: 20,
+ height: 30,
+ radialSegments: 20,
+ heightSegments: 30,
+ openEnded: true,
+ thetaStart: 0.1,
+ thetaLength: 2.0,
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - CylinderGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.CylinderGeometry(),
+ new THREE.CylinderGeometry( parameters.radiusTop ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height, parameters.radialSegments ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height, parameters.radialSegments, parameters.heightSegments ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height, parameters.radialSegments, parameters.heightSegments, parameters.openEnded ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height, parameters.radialSegments, parameters.heightSegments, parameters.openEnded, parameters.thetaStart ),
+ new THREE.CylinderGeometry( parameters.radiusTop, parameters.radiusBottom, parameters.height, parameters.radialSegments, parameters.heightSegments, parameters.openEnded, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/DodecahedronGeometry.tests.js | @@ -0,0 +1,34 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ detail: undefined
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - DodecahedronGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.DodecahedronGeometry(),
+ new THREE.DodecahedronGeometry( parameters.radius ),
+ new THREE.DodecahedronGeometry( parameters.radius, parameters.detail ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/ExtrudeGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/IcosahedronGeometry.tests.js | @@ -0,0 +1,34 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ detail: undefined
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - IcosahedronGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.IcosahedronGeometry(),
+ new THREE.IcosahedronGeometry( parameters.radius ),
+ new THREE.IcosahedronGeometry( parameters.radius, parameters.detail ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/LatheGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/OctahedronGeometry.tests.js | @@ -0,0 +1,34 @@
+(function() {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ detail: undefined
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - OctahedronGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.OctahedronGeometry(),
+ new THREE.OctahedronGeometry( parameters.radius ),
+ new THREE.OctahedronGeometry( parameters.radius, parameters.detail ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/ParametricGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/PlaneBufferGeometry.tests.js | @@ -0,0 +1,38 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ width: 10,
+ height: 30,
+ widthSegments: 3,
+ heightSegments: 5
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - PlaneBufferGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.PlaneBufferGeometry(),
+ new THREE.PlaneBufferGeometry( parameters.width ),
+ new THREE.PlaneBufferGeometry( parameters.width, parameters.height ),
+ new THREE.PlaneBufferGeometry( parameters.width, parameters.height, parameters.widthSegments ),
+ new THREE.PlaneBufferGeometry( parameters.width, parameters.height, parameters.widthSegments, parameters.heightSegments ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/PlaneGeometry.tests.js | @@ -0,0 +1,38 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ width: 10,
+ height: 30,
+ widthSegments: 3,
+ heightSegments: 5
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - PlaneGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.PlaneGeometry(),
+ new THREE.PlaneGeometry( parameters.width ),
+ new THREE.PlaneGeometry( parameters.width, parameters.height ),
+ new THREE.PlaneGeometry( parameters.width, parameters.height, parameters.widthSegments ),
+ new THREE.PlaneGeometry( parameters.width, parameters.height, parameters.widthSegments, parameters.heightSegments ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/PolyhedronGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/RingGeometry.tests.js | @@ -0,0 +1,42 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ innerRadius: 10,
+ outerRadius: 60,
+ thetaSegments: 12,
+ phiSegments: 14,
+ thetaStart: 0.1,
+ thetaLength: 2.0
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - RingGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.RingGeometry(),
+ new THREE.RingGeometry( parameters.innerRadius ),
+ new THREE.RingGeometry( parameters.innerRadius, parameters.outerRadius ),
+ new THREE.RingGeometry( parameters.innerRadius, parameters.outerRadius, parameters.thetaSegments ),
+ new THREE.RingGeometry( parameters.innerRadius, parameters.outerRadius, parameters.thetaSegments, parameters.phiSegments ),
+ new THREE.RingGeometry( parameters.innerRadius, parameters.outerRadius, parameters.thetaSegments, parameters.phiSegments, parameters.thetaStart ),
+ new THREE.RingGeometry( parameters.innerRadius, parameters.outerRadius, parameters.thetaSegments, parameters.phiSegments, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/ShapeGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/SphereBufferGeometry.tests.js | @@ -0,0 +1,44 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ widthSegments: 20,
+ heightSegments: 30,
+ phiStart: 0.5,
+ phiLength: 1.0,
+ thetaStart: 0.4,
+ thetaLength: 2.0,
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - SphereBufferGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.SphereBufferGeometry(),
+ new THREE.SphereBufferGeometry( parameters.radius ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength, parameters.thetaStart ),
+ new THREE.SphereBufferGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/SphereGeometry.tests.js | @@ -0,0 +1,44 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ widthSegments: 20,
+ heightSegments: 30,
+ phiStart: 0.5,
+ phiLength: 1.0,
+ thetaStart: 0.4,
+ thetaLength: 2.0,
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - SphereGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.SphereGeometry(),
+ new THREE.SphereGeometry( parameters.radius ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength, parameters.thetaStart ),
+ new THREE.SphereGeometry( parameters.radius, parameters.widthSegments, parameters.heightSegments, parameters.phiStart, parameters.phiLength, parameters.thetaStart, parameters.thetaLength ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/TetrahedronGeometry.tests.js | @@ -0,0 +1,34 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ detail: undefined
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - TetrahedronGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.TetrahedronGeometry(),
+ new THREE.TetrahedronGeometry( parameters.radius ),
+ new THREE.TetrahedronGeometry( parameters.radius, parameters.detail ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/TextGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/TorusGeometry.tests.js | @@ -0,0 +1,40 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ tube: 20,
+ radialSegments: 30,
+ tubularSegments: 10,
+ arc: 2.0,
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - TorusGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.TorusGeometry(),
+ new THREE.TorusGeometry( parameters.radius ),
+ new THREE.TorusGeometry( parameters.radius, parameters.tube ),
+ new THREE.TorusGeometry( parameters.radius, parameters.tube, parameters.radialSegments ),
+ new THREE.TorusGeometry( parameters.radius, parameters.tube, parameters.radialSegments, parameters.tubularSegments ),
+ new THREE.TorusGeometry( parameters.radius, parameters.tube, parameters.radialSegments, parameters.tubularSegments, parameters.arc ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/TorusKnotGeometry.tests.js | @@ -0,0 +1,42 @@
+(function () {
+
+ 'use strict';
+
+ var parameters = {
+ radius: 10,
+ tube: 20,
+ radialSegments: 30,
+ tubularSegments: 10,
+ p: 3,
+ q: 2,
+ heightScale: 2.0
+ };
+
+ var geometries;
+
+ QUnit.module( "Extras - Geometries - TorusKnotGeometry", {
+
+ beforeEach: function() {
+
+ geometries = [
+
+ new THREE.TorusKnotGeometry(),
+ new THREE.TorusKnotGeometry( parameters.radius ),
+ new THREE.TorusKnotGeometry( parameters.radius, parameters.tube ),
+ new THREE.TorusKnotGeometry( parameters.radius, parameters.tube, parameters.radialSegments ),
+ new THREE.TorusKnotGeometry( parameters.radius, parameters.tube, parameters.radialSegments, parameters.tubularSegments ),
+ new THREE.TorusKnotGeometry( parameters.radius, parameters.tube, parameters.radialSegments, parameters.tubularSegments, parameters.p, parameters.q, parameters.heightScale ),
+
+ ];
+
+ }
+
+ });
+
+ QUnit.test( "standard geometry tests", function( assert ) {
+
+ runStdGeometryTests( assert, geometries );
+
+ });
+
+})(); | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/TubeGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/extras/geometries/WireframeGeometry.tests.js | @@ -0,0 +1 @@
+// TODO
\ No newline at end of file | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/qunit-utils.js | @@ -5,13 +5,141 @@
QUnit.assert.success = function( message ) {
// Equivalent to assert( true, message );
- QUnit.assert.push( true, undefined, undefined, message );
+ QUnit.assert.push( true, undefined, undefined, message );
};
QUnit.assert.fail = function( message ) {
// Equivalent to assert( false, message );
- QUnit.assert.push( false, undefined, undefined, message );
+ QUnit.assert.push( false, undefined, undefined, message );
};
+
+QUnit.assert.numEqual = function( actual, expected, message ) {
+
+ var diff = Math.abs(actual - expected);
+ message = message || ( actual + " should be equal to " + expected );
+ QUnit.assert.push( diff < 0.1, actual, expected, message );
+
+};
+
+QUnit.assert.equalKey = function( obj, ref, key ) {
+
+ var actual = obj[key];
+ var expected = ref[key];
+ var message = actual + ' should be equal to ' + expected + ' for key "' + key + '"';
+ QUnit.assert.push( actual == expected, actual, expected, message );
+
+};
+
+QUnit.assert.smartEqual = function( actual, expected, message ) {
+
+ var cmp = new SmartComparer();
+
+ var same = cmp.areEqual(actual, expected);
+ var msg = cmp.getDiagnostic() || message;
+
+ QUnit.assert.push( same, actual, expected, msg );
+
+};
+
+
+
+//
+// GEOMETRY TEST HELPERS
+//
+
+function checkGeometryClone( geom ) {
+
+ // Clone
+ var copy = geom.clone();
+ QUnit.assert.notEqual( copy.uuid, geom.uuid, "clone uuid should differ from original" );
+ QUnit.assert.notEqual( copy.id, geom.id, "clone id should differ from original" );
+ QUnit.assert.smartEqual( copy, geom, "clone is equal to original" );
+
+
+ // json round trip with clone
+ checkGeometryJsonRoundtrip( copy );
+
+}
+
+// Compare json file with its source geometry.
+function checkGeometryJsonWriting( geom, json ) {
+
+ QUnit.assert.equal( json.metadata.version, "4.4", "check metadata version" );
+ QUnit.assert.equalKey( geom, json, 'type' );
+ QUnit.assert.equalKey( geom, json, 'uuid' );
+ QUnit.assert.equal( json.id, undefined, "should not persist id" );
+
+ // All parameters from geometry should be persisted.
+ _.forOwn( geom.parameters, function ( val, key ) {
+
+ QUnit.assert.equalKey( geom.parameters, json, key );
+
+ });
+
+ // All parameters from json should be transfered to the geometry.
+ // json is flat. Ignore first level json properties that are not parameters.
+ var notParameters = [ "metadata", "uuid", "type" ];
+ _.forOwn( json, function ( val, key ) {
+
+ if ( notParameters.indexOf( key) === -1 ) QUnit.assert.equalKey( geom.parameters, json, key );
+
+ });
+
+}
+
+// Check parsing and reconstruction of json geometry
+function checkGeometryJsonReading( json, geom ) {
+
+ var wrap = [ json ];
+
+ var loader = new THREE.ObjectLoader();
+ var output = loader.parseGeometries( wrap );
+
+ QUnit.assert.ok( output[geom.uuid], 'geometry matching source uuid not in output' );
+ QUnit.assert.smartEqual( output[geom.uuid], geom, 'Reconstruct geometry from ObjectLoader' );
+
+}
+
+// Verify geom -> json -> geom
+function checkGeometryJsonRoundtrip( geom ) {
+
+ var json = geom.toJSON();
+ checkGeometryJsonWriting( geom, json );
+ checkGeometryJsonReading( json, geom );
+
+}
+
+// Look for undefined and NaN values in numerical fieds.
+function checkFinite( geom ) {
+
+ var isNotFinite = _.any( geom.vertices, function ( v ) {
+
+ return ! ( _.isFinite( v.x ) || _.isFinite( v.y ) || _.isFinite( v.z ) );
+
+ });
+
+ // TODO Buffers, normal, etc.
+
+ QUnit.assert.ok( isNotFinite === false, "contains non-finite coordinates" );
+
+}
+
+// Run common geometry tests.
+function runStdGeometryTests( assert, geometries ) {
+
+ _.each( geometries, function( geom ) {
+
+ checkFinite( geom );
+
+ // Clone
+ checkGeometryClone( geom );
+
+ // json round trip
+ checkGeometryJsonRoundtrip( geom );
+
+ });
+
+} | true |
Other | mrdoob | three.js | faa8745f58c4ef155ab807f4ef04318ba021a3bd.json | Add unit tests
Covers construction, cloning, json import/export. Use lodash from npm. | test/unit/unittests_three.html | @@ -7,9 +7,11 @@
</head>
<body>
<div id="qunit"></div>
+ <script src="../../node_modules/lodash/index.js"></script>
<script src="qunit-1.18.0.js"></script>
<script src="qunit-utils.js"></script>
-
+ <script src="SmartComparer.js"></script>
+
<!-- add sources to test below -->
<script src="../../build/three.js"></script>
@@ -33,11 +35,38 @@
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script>
<script src="math/Frustum.js"></script>
-
+
<script src="geometry/EdgesGeometry.js"></script>
<script src="extras/ImageUtils.test.js"></script>
-
+
+ <script src="extras/geometries/BoxGeometry.tests.js"></script>
+ <script src="extras/geometries/CircleBufferGeometry.tests.js"></script>
+ <script src="extras/geometries/CircleGeometry.tests.js"></script>
+ <script src="extras/geometries/CylinderGeometry.tests.js"></script>
+ <script src="extras/geometries/DodecahedronGeometry.tests.js"></script>
+ <script src="extras/geometries/ExtrudeGeometry.tests.js"></script>
+ <script src="extras/geometries/IcosahedronGeometry.tests.js"></script>
+ <script src="extras/geometries/LatheGeometry.tests.js"></script>
+ <script src="extras/geometries/OctahedronGeometry.tests.js"></script>
+ <script src="extras/geometries/ParametricGeometry.tests.js"></script>
+ <script src="extras/geometries/PlaneBufferGeometry.tests.js"></script>
+ <script src="extras/geometries/PlaneGeometry.tests.js"></script>
+ <script src="extras/geometries/PolyhedronGeometry.tests.js"></script>
+ <script src="extras/geometries/RingGeometry.tests.js"></script>
+ <script src="extras/geometries/ShapeGeometry.tests.js"></script>
+ <script src="extras/geometries/SphereBufferGeometry.tests.js"></script>
+ <script src="extras/geometries/SphereGeometry.tests.js"></script>
+ <script src="extras/geometries/TetrahedronGeometry.tests.js"></script>
+ <script src="extras/geometries/TextGeometry.tests.js"></script>
+ <script src="extras/geometries/TorusGeometry.tests.js"></script>
+ <script src="extras/geometries/TorusKnotGeometry.tests.js"></script>
+ <script src="extras/geometries/TubeGeometry.tests.js"></script>
+ <script src="extras/geometries/WireframeGeometry.tests.js"></script>
+
+
<!-- for debug output -->
+ <!--
<script src="../../examples/js/controls/OrbitControls.js"></script>
+ -->
</body>
</html> | true |
Other | mrdoob | three.js | 6cc768f0b459a344f3f4464551576fbdb2e0626e.json | Remove recursive arg from Mesh.clone() | src/objects/Mesh.js | @@ -305,16 +305,16 @@ THREE.Mesh.prototype.raycast = ( function () {
}() );
-THREE.Mesh.prototype.clone = function ( recursive ) {
+THREE.Mesh.prototype.clone = function () {
var mesh = new THREE.Mesh( this.geometry, this.material );
return this.cloneProperties( mesh );
};
-THREE.Mesh.prototype.cloneProperties = function ( mesh, recursive ) {
+THREE.Mesh.prototype.cloneProperties = function ( mesh ) {
- THREE.Object3D.prototype.cloneProperties.call( this, mesh, recursive );
+ THREE.Object3D.prototype.cloneProperties.call( this, mesh );
return mesh;
| false |
Other | mrdoob | three.js | 1c568ed1f547b94b2aa5315ec24a91ec34fe5e13.json | fix an issue wher buffers don't get deleted | src/renderers/webgl/WebGLGeometries.js | @@ -2,7 +2,7 @@
* @author mrdoob / http://mrdoob.com/
*/
-THREE.WebGLGeometries = function ( gl, info ) {
+THREE.WebGLGeometries = function ( gl,properties, info ) {
var geometries = {};
@@ -48,12 +48,12 @@ THREE.WebGLGeometries = function ( gl, info ) {
for ( var name in buffergeometry.attributes ) {
var attribute = buffergeometry.attributes[ name ];
+ var buffer = getAttributeBuffer(attribute);
- if ( attribute.buffer !== undefined ) {
+ if ( buffer !== undefined ) {
- gl.deleteBuffer( attribute.buffer );
-
- delete attribute.buffer;
+ gl.deleteBuffer( buffer );
+ removeAttributeBuffer(attribute);
}
@@ -66,5 +66,30 @@ THREE.WebGLGeometries = function ( gl, info ) {
info.memory.geometries --;
}
+
+ function getAttributeBuffer( attribute ) {
+
+ if ( attribute instanceof THREE.InterleavedBufferAttribute ) {
+ return properties.get( attribute.data ).__webglBuffer;
+
+ }
+
+ return properties.get( attribute ).__webglBuffer;
+
+ };
+
+ function removeAttributeBuffer( attribute ) {
+
+ if ( attribute instanceof THREE.InterleavedBufferAttribute ) {
+
+ properties.delete( attribute.data );
+
+ } else {
+
+ properties.delete( attribute );
+
+ };
+
+ };
}; | true |
Other | mrdoob | three.js | 1c568ed1f547b94b2aa5315ec24a91ec34fe5e13.json | fix an issue wher buffers don't get deleted | src/renderers/webgl/WebGLObjects.js | @@ -8,7 +8,7 @@ THREE.WebGLObjects = function ( gl, properties, info ) {
var morphInfluences = new Float32Array( 8 );
- var geometries = new THREE.WebGLGeometries( gl, info );
+ var geometries = new THREE.WebGLGeometries( gl, properties, info );
//
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/controls/OrthographicTrackballControls.js | @@ -123,7 +123,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
var vector = new THREE.Vector2();
- return function ( pageX, pageY ) {
+ return function getMouseOnScreen ( pageX, pageY ) {
vector.set(
( pageX - _this.screen.left ) / _this.screen.width,
@@ -142,7 +142,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
var objectUp = new THREE.Vector3();
var mouseOnBall = new THREE.Vector3();
- return function ( pageX, pageY ) {
+ return function getMouseProjectionOnBall ( pageX, pageY ) {
mouseOnBall.set(
( pageX - _this.screen.width * 0.5 - _this.screen.left ) / _this.radius, | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/controls/TrackballControls.js | @@ -115,7 +115,7 @@ THREE.TrackballControls = function ( object, domElement ) {
var vector = new THREE.Vector2();
- return function ( pageX, pageY ) {
+ return function getMouseOnScreen ( pageX, pageY ) {
vector.set(
( pageX - _this.screen.left ) / _this.screen.width,
@@ -132,7 +132,7 @@ THREE.TrackballControls = function ( object, domElement ) {
var vector = new THREE.Vector2();
- return function ( pageX, pageY ) {
+ return function getMouseOnCircle ( pageX, pageY ) {
vector.set(
( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ), | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/exporters/STLBinaryExporter.js | @@ -15,7 +15,7 @@ THREE.STLBinaryExporter.prototype = {
var vector = new THREE.Vector3();
var normalMatrixWorld = new THREE.Matrix3();
- return function ( scene ) {
+ return function parse ( scene ) {
var triangles = 0;
scene.traverse( function ( object ) { | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/exporters/STLExporter.js | @@ -14,7 +14,7 @@ THREE.STLExporter.prototype = {
var vector = new THREE.Vector3();
var normalMatrixWorld = new THREE.Matrix3();
- return function ( scene ) {
+ return function parse ( scene ) {
var output = '';
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/renderers/RaytracingRenderer.js | @@ -103,7 +103,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
}
- return function ( rayOrigin, rayDirection, outputColor, recursionDepth ) {
+ return function spawnRay ( rayOrigin, rayDirection, outputColor, recursionDepth ) {
var ray = raycaster.ray;
@@ -355,7 +355,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
var tmpVec2 = new THREE.Vector3();
var tmpVec3 = new THREE.Vector3();
- return function ( outputVector, point, shading, face, vertices ) {
+ return function computePixelNormal ( outputVector, point, shading, face, vertices ) {
var faceNormal = face.normal;
var vertexNormals = face.vertexNormals;
@@ -424,7 +424,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
var pixelColor = new THREE.Color();
- return function ( blockX, blockY ) {
+ return function renderBlock ( blockX, blockY ) {
var index = 0;
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/js/wip/TypedGeometry.js | @@ -40,7 +40,7 @@ THREE.TypedGeometry.prototype.merge = ( function () {
var offset = 0;
var normalMatrix = new THREE.Matrix3();
- return function ( geometry, matrix, startOffset ) {
+ return function merge ( geometry, matrix, startOffset ) {
if ( startOffset !== undefined ) offset = startOffset;
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | examples/webgl_geometry_text2.html | @@ -77,7 +77,7 @@
<script>
THREE.Shape.Utils.triangulateShape = ( function () {
var pnlTriangulator = new PNLTRI.Triangulator();
- return function ( contour, holes ) {
+ return function triangulateShape ( contour, holes ) {
// console.log("new Triangulation: PnlTri.js " + PNLTRI.REVISION );
return pnlTriangulator.triangulate_polygon( [ contour ].concat(holes) );
}; | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/audio/Audio.js | @@ -123,7 +123,7 @@ THREE.Audio.prototype.updateMatrixWorld = ( function () {
var position = new THREE.Vector3();
- return function ( force ) {
+ return function updateMatrixWorld ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/audio/AudioListener.js | @@ -23,7 +23,7 @@ THREE.AudioListener.prototype.updateMatrixWorld = ( function () {
var orientation = new THREE.Vector3();
- return function ( force ) {
+ return function updateMatrixWorld ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/core/Gyroscope.js | @@ -1,65 +1,65 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
-
-THREE.Gyroscope = function () {
-
- THREE.Object3D.call( this );
-
-};
-
-THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.Gyroscope = function () {
+
+ THREE.Object3D.call( this );
+
+};
+
+THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
THREE.Gyroscope.prototype.constructor = THREE.Gyroscope;
-
-THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
-
- var translationObject = new THREE.Vector3();
- var quaternionObject = new THREE.Quaternion();
- var scaleObject = new THREE.Vector3();
-
- var translationWorld = new THREE.Vector3();
- var quaternionWorld = new THREE.Quaternion();
- var scaleWorld = new THREE.Vector3();
-
- return function ( force ) {
-
- this.matrixAutoUpdate && this.updateMatrix();
-
- // update matrixWorld
-
- if ( this.matrixWorldNeedsUpdate || force ) {
-
- if ( this.parent ) {
-
- this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
-
- this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
- this.matrix.decompose( translationObject, quaternionObject, scaleObject );
-
- this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
-
-
- } else {
-
- this.matrixWorld.copy( this.matrix );
-
- }
-
-
- this.matrixWorldNeedsUpdate = false;
-
- force = true;
-
- }
-
- // update children
-
- for ( var i = 0, l = this.children.length; i < l; i ++ ) {
-
- this.children[ i ].updateMatrixWorld( force );
-
- }
-
- };
-
-}() );
+
+THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
+
+ var translationObject = new THREE.Vector3();
+ var quaternionObject = new THREE.Quaternion();
+ var scaleObject = new THREE.Vector3();
+
+ var translationWorld = new THREE.Vector3();
+ var quaternionWorld = new THREE.Quaternion();
+ var scaleWorld = new THREE.Vector3();
+
+ return function updateMatrixWorld ( force ) {
+
+ this.matrixAutoUpdate && this.updateMatrix();
+
+ // update matrixWorld
+
+ if ( this.matrixWorldNeedsUpdate || force ) {
+
+ if ( this.parent ) {
+
+ this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
+
+ this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
+ this.matrix.decompose( translationObject, quaternionObject, scaleObject );
+
+ this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
+
+
+ } else {
+
+ this.matrixWorld.copy( this.matrix );
+
+ }
+
+
+ this.matrixWorldNeedsUpdate = false;
+
+ force = true;
+
+ }
+
+ // update children
+
+ for ( var i = 0, l = this.children.length; i < l; i ++ ) {
+
+ this.children[ i ].updateMatrixWorld( force );
+
+ }
+
+ };
+
+}() ); | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/helpers/ArrowHelper.js | @@ -22,7 +22,7 @@ THREE.ArrowHelper = ( function () {
var coneGeometry = new THREE.CylinderGeometry( 0, 0.5, 1, 5, 1 );
coneGeometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, - 0.5, 0 ) );
- return function ( dir, origin, length, color, headLength, headWidth ) {
+ return function ArrowHelper ( dir, origin, length, color, headLength, headWidth ) {
// dir is assumed to be normalized
@@ -58,7 +58,7 @@ THREE.ArrowHelper.prototype.setDirection = ( function () {
var axis = new THREE.Vector3();
var radians;
- return function ( dir ) {
+ return function setDirection ( dir ) {
// dir is assumed to be normalized
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/helpers/FaceNormalsHelper.js | @@ -59,7 +59,7 @@ THREE.FaceNormalsHelper.prototype.update = ( function () {
var v1 = new THREE.Vector3();
var v2 = new THREE.Vector3();
- return function() {
+ return function update ( ) {
this.object.updateMatrixWorld( true );
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/extras/helpers/VertexNormalsHelper.js | @@ -57,7 +57,7 @@ THREE.VertexNormalsHelper.prototype.update = ( function () {
var v1 = new THREE.Vector3();
var v2 = new THREE.Vector3();
- return function() {
+ return function update ( ) {
var keys = [ 'a', 'b', 'c' ];
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/loaders/Loader.js | @@ -1,398 +1,398 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
-
-THREE.Loader = function () {
-
- this.onLoadStart = function () {};
- this.onLoadProgress = function () {};
- this.onLoadComplete = function () {};
-
-};
-
-THREE.Loader.prototype = {
-
- constructor: THREE.Loader,
-
- crossOrigin: undefined,
-
- extractUrlBase: function ( url ) {
-
- var parts = url.split( '/' );
-
- if ( parts.length === 1 ) return './';
-
- parts.pop();
-
- return parts.join( '/' ) + '/';
-
- },
-
- initMaterials: function ( materials, texturePath, crossOrigin ) {
-
- var array = [];
-
- for ( var i = 0; i < materials.length; ++ i ) {
-
- array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );
-
- }
-
- return array;
-
- },
-
- needsTangents: function ( materials ) {
-
- for ( var i = 0, il = materials.length; i < il; i ++ ) {
-
- var m = materials[ i ];
-
- if ( m instanceof THREE.ShaderMaterial ) return true;
-
- }
-
- return false;
-
- },
-
- createMaterial: ( function () {
-
- var imageLoader;
-
- return function ( m, texturePath, crossOrigin ) {
-
- var scope = this;
-
- if ( crossOrigin === undefined && scope.crossOrigin !== undefined ) crossOrigin = scope.crossOrigin;
-
- if ( imageLoader === undefined ) imageLoader = new THREE.ImageLoader();
-
- function nearest_pow2( n ) {
-
- var l = Math.log( n ) / Math.LN2;
- return Math.pow( 2, Math.round( l ) );
-
- }
-
- function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
-
- var fullPath = texturePath + sourceFile;
-
- var texture;
-
- var loader = THREE.Loader.Handlers.get( fullPath );
-
- if ( loader !== null ) {
-
- texture = loader.load( fullPath );
-
- } else {
-
- texture = new THREE.Texture();
-
- loader = imageLoader;
- loader.setCrossOrigin( crossOrigin );
- loader.load( fullPath, function ( image ) {
-
- if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
- THREE.Math.isPowerOfTwo( image.height ) === false ) {
-
- var width = nearest_pow2( image.width );
- var height = nearest_pow2( image.height );
-
- var canvas = document.createElement( 'canvas' );
- canvas.width = width;
- canvas.height = height;
-
- var context = canvas.getContext( '2d' );
- context.drawImage( image, 0, 0, width, height );
-
- texture.image = canvas;
-
- } else {
-
- texture.image = image;
-
- }
-
- texture.needsUpdate = true;
-
- } );
-
- }
-
- texture.sourceFile = sourceFile;
-
- if ( repeat ) {
-
- texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
-
- if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
- if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
-
- }
-
- if ( offset ) {
-
- texture.offset.set( offset[ 0 ], offset[ 1 ] );
-
- }
-
- if ( wrap ) {
-
- var wrapMap = {
- 'repeat': THREE.RepeatWrapping,
- 'mirror': THREE.MirroredRepeatWrapping
- };
-
- if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
- if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
-
- }
-
- if ( anisotropy ) {
-
- texture.anisotropy = anisotropy;
-
- }
-
- where[ name ] = texture;
-
- }
-
- function rgb2hex( rgb ) {
-
- return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
-
- }
-
- // defaults
-
- var mtype = 'MeshLambertMaterial';
- var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
-
- // parameters from model file
-
- if ( m.shading ) {
-
- var shading = m.shading.toLowerCase();
-
- if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
- else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
-
- }
-
- if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
-
- mpars.blending = THREE[ m.blending ];
-
- }
-
- if ( m.transparent !== undefined ) {
-
- mpars.transparent = m.transparent;
-
- }
-
- if ( m.opacity !== undefined && m.opacity < 1.0 ) {
-
- mpars.transparent = true;
-
- }
-
- if ( m.depthTest !== undefined ) {
-
- mpars.depthTest = m.depthTest;
-
- }
-
- if ( m.depthWrite !== undefined ) {
-
- mpars.depthWrite = m.depthWrite;
-
- }
-
- if ( m.visible !== undefined ) {
-
- mpars.visible = m.visible;
-
- }
-
- if ( m.flipSided !== undefined ) {
-
- mpars.side = THREE.BackSide;
-
- }
-
- if ( m.doubleSided !== undefined ) {
-
- mpars.side = THREE.DoubleSide;
-
- }
-
- if ( m.wireframe !== undefined ) {
-
- mpars.wireframe = m.wireframe;
-
- }
-
- if ( m.vertexColors !== undefined ) {
-
- if ( m.vertexColors === 'face' ) {
-
- mpars.vertexColors = THREE.FaceColors;
-
- } else if ( m.vertexColors ) {
-
- mpars.vertexColors = THREE.VertexColors;
-
- }
-
- }
-
- // colors
-
- if ( m.colorDiffuse ) {
-
- mpars.color = rgb2hex( m.colorDiffuse );
-
- } else if ( m.DbgColor ) {
-
- mpars.color = m.DbgColor;
-
- }
-
- if ( m.colorSpecular ) {
-
- mpars.specular = rgb2hex( m.colorSpecular );
-
- }
-
- if ( m.colorEmissive ) {
-
- mpars.emissive = rgb2hex( m.colorEmissive );
-
- }
-
- // modifiers
-
- if ( m.transparency !== undefined ) {
-
- console.warn( 'THREE.Loader: transparency has been renamed to opacity' );
- m.opacity = m.transparency;
-
- }
-
- if ( m.opacity !== undefined ) {
-
- mpars.opacity = m.opacity;
-
- }
-
- if ( m.specularCoef ) {
-
- mpars.shininess = m.specularCoef;
-
- }
-
- // textures
-
- if ( m.mapDiffuse && texturePath ) {
-
- create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
-
- }
-
- if ( m.mapLight && texturePath ) {
-
- create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
-
- }
-
- if ( m.mapAO && texturePath ) {
-
- create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
-
- }
-
- if ( m.mapBump && texturePath ) {
-
- create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
-
- }
-
- if ( m.mapNormal && texturePath ) {
-
- create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
-
- }
-
- if ( m.mapSpecular && texturePath ) {
-
- create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
-
- }
-
- if ( m.mapAlpha && texturePath ) {
-
- create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
-
- }
-
- //
-
- if ( m.mapBumpScale ) {
-
- mpars.bumpScale = m.mapBumpScale;
-
- }
-
- if ( m.mapNormalFactor ) {
-
- mpars.normalScale = new THREE.Vector2( m.mapNormalFactor, m.mapNormalFactor );
-
- }
-
- var material = new THREE[ mtype ]( mpars );
-
- if ( m.DbgName !== undefined ) material.name = m.DbgName;
-
- return material;
-
- };
-
- } )()
-
-};
-
-THREE.Loader.Handlers = {
-
- handlers: [],
-
- add: function ( regex, loader ) {
-
- this.handlers.push( regex, loader );
-
- },
-
- get: function ( file ) {
-
- for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
-
- var regex = this.handlers[ i ];
- var loader = this.handlers[ i + 1 ];
-
- if ( regex.test( file ) ) {
-
- return loader;
-
- }
-
- }
-
- return null;
-
- }
-
-};
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.Loader = function () {
+
+ this.onLoadStart = function () {};
+ this.onLoadProgress = function () {};
+ this.onLoadComplete = function () {};
+
+};
+
+THREE.Loader.prototype = {
+
+ constructor: THREE.Loader,
+
+ crossOrigin: undefined,
+
+ extractUrlBase: function ( url ) {
+
+ var parts = url.split( '/' );
+
+ if ( parts.length === 1 ) return './';
+
+ parts.pop();
+
+ return parts.join( '/' ) + '/';
+
+ },
+
+ initMaterials: function ( materials, texturePath, crossOrigin ) {
+
+ var array = [];
+
+ for ( var i = 0; i < materials.length; ++ i ) {
+
+ array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );
+
+ }
+
+ return array;
+
+ },
+
+ needsTangents: function ( materials ) {
+
+ for ( var i = 0, il = materials.length; i < il; i ++ ) {
+
+ var m = materials[ i ];
+
+ if ( m instanceof THREE.ShaderMaterial ) return true;
+
+ }
+
+ return false;
+
+ },
+
+ createMaterial: ( function () {
+
+ var imageLoader;
+
+ return function createMaterial ( m, texturePath, crossOrigin ) {
+
+ var scope = this;
+
+ if ( crossOrigin === undefined && scope.crossOrigin !== undefined ) crossOrigin = scope.crossOrigin;
+
+ if ( imageLoader === undefined ) imageLoader = new THREE.ImageLoader();
+
+ function nearest_pow2( n ) {
+
+ var l = Math.log( n ) / Math.LN2;
+ return Math.pow( 2, Math.round( l ) );
+
+ }
+
+ function create_texture( where, name, sourceFile, repeat, offset, wrap, anisotropy ) {
+
+ var fullPath = texturePath + sourceFile;
+
+ var texture;
+
+ var loader = THREE.Loader.Handlers.get( fullPath );
+
+ if ( loader !== null ) {
+
+ texture = loader.load( fullPath );
+
+ } else {
+
+ texture = new THREE.Texture();
+
+ loader = imageLoader;
+ loader.setCrossOrigin( crossOrigin );
+ loader.load( fullPath, function ( image ) {
+
+ if ( THREE.Math.isPowerOfTwo( image.width ) === false ||
+ THREE.Math.isPowerOfTwo( image.height ) === false ) {
+
+ var width = nearest_pow2( image.width );
+ var height = nearest_pow2( image.height );
+
+ var canvas = document.createElement( 'canvas' );
+ canvas.width = width;
+ canvas.height = height;
+
+ var context = canvas.getContext( '2d' );
+ context.drawImage( image, 0, 0, width, height );
+
+ texture.image = canvas;
+
+ } else {
+
+ texture.image = image;
+
+ }
+
+ texture.needsUpdate = true;
+
+ } );
+
+ }
+
+ texture.sourceFile = sourceFile;
+
+ if ( repeat ) {
+
+ texture.repeat.set( repeat[ 0 ], repeat[ 1 ] );
+
+ if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
+ if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
+
+ }
+
+ if ( offset ) {
+
+ texture.offset.set( offset[ 0 ], offset[ 1 ] );
+
+ }
+
+ if ( wrap ) {
+
+ var wrapMap = {
+ 'repeat': THREE.RepeatWrapping,
+ 'mirror': THREE.MirroredRepeatWrapping
+ };
+
+ if ( wrapMap[ wrap[ 0 ] ] !== undefined ) texture.wrapS = wrapMap[ wrap[ 0 ] ];
+ if ( wrapMap[ wrap[ 1 ] ] !== undefined ) texture.wrapT = wrapMap[ wrap[ 1 ] ];
+
+ }
+
+ if ( anisotropy ) {
+
+ texture.anisotropy = anisotropy;
+
+ }
+
+ where[ name ] = texture;
+
+ }
+
+ function rgb2hex( rgb ) {
+
+ return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
+
+ }
+
+ // defaults
+
+ var mtype = 'MeshLambertMaterial';
+ var mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, normalMap: null, bumpMap: null, wireframe: false };
+
+ // parameters from model file
+
+ if ( m.shading ) {
+
+ var shading = m.shading.toLowerCase();
+
+ if ( shading === 'phong' ) mtype = 'MeshPhongMaterial';
+ else if ( shading === 'basic' ) mtype = 'MeshBasicMaterial';
+
+ }
+
+ if ( m.blending !== undefined && THREE[ m.blending ] !== undefined ) {
+
+ mpars.blending = THREE[ m.blending ];
+
+ }
+
+ if ( m.transparent !== undefined ) {
+
+ mpars.transparent = m.transparent;
+
+ }
+
+ if ( m.opacity !== undefined && m.opacity < 1.0 ) {
+
+ mpars.transparent = true;
+
+ }
+
+ if ( m.depthTest !== undefined ) {
+
+ mpars.depthTest = m.depthTest;
+
+ }
+
+ if ( m.depthWrite !== undefined ) {
+
+ mpars.depthWrite = m.depthWrite;
+
+ }
+
+ if ( m.visible !== undefined ) {
+
+ mpars.visible = m.visible;
+
+ }
+
+ if ( m.flipSided !== undefined ) {
+
+ mpars.side = THREE.BackSide;
+
+ }
+
+ if ( m.doubleSided !== undefined ) {
+
+ mpars.side = THREE.DoubleSide;
+
+ }
+
+ if ( m.wireframe !== undefined ) {
+
+ mpars.wireframe = m.wireframe;
+
+ }
+
+ if ( m.vertexColors !== undefined ) {
+
+ if ( m.vertexColors === 'face' ) {
+
+ mpars.vertexColors = THREE.FaceColors;
+
+ } else if ( m.vertexColors ) {
+
+ mpars.vertexColors = THREE.VertexColors;
+
+ }
+
+ }
+
+ // colors
+
+ if ( m.colorDiffuse ) {
+
+ mpars.color = rgb2hex( m.colorDiffuse );
+
+ } else if ( m.DbgColor ) {
+
+ mpars.color = m.DbgColor;
+
+ }
+
+ if ( m.colorSpecular ) {
+
+ mpars.specular = rgb2hex( m.colorSpecular );
+
+ }
+
+ if ( m.colorEmissive ) {
+
+ mpars.emissive = rgb2hex( m.colorEmissive );
+
+ }
+
+ // modifiers
+
+ if ( m.transparency !== undefined ) {
+
+ console.warn( 'THREE.Loader: transparency has been renamed to opacity' );
+ m.opacity = m.transparency;
+
+ }
+
+ if ( m.opacity !== undefined ) {
+
+ mpars.opacity = m.opacity;
+
+ }
+
+ if ( m.specularCoef ) {
+
+ mpars.shininess = m.specularCoef;
+
+ }
+
+ // textures
+
+ if ( m.mapDiffuse && texturePath ) {
+
+ create_texture( mpars, 'map', m.mapDiffuse, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );
+
+ }
+
+ if ( m.mapLight && texturePath ) {
+
+ create_texture( mpars, 'lightMap', m.mapLight, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );
+
+ }
+
+ if ( m.mapAO && texturePath ) {
+
+ create_texture( mpars, 'aoMap', m.mapAO, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );
+
+ }
+
+ if ( m.mapBump && texturePath ) {
+
+ create_texture( mpars, 'bumpMap', m.mapBump, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );
+
+ }
+
+ if ( m.mapNormal && texturePath ) {
+
+ create_texture( mpars, 'normalMap', m.mapNormal, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );
+
+ }
+
+ if ( m.mapSpecular && texturePath ) {
+
+ create_texture( mpars, 'specularMap', m.mapSpecular, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );
+
+ }
+
+ if ( m.mapAlpha && texturePath ) {
+
+ create_texture( mpars, 'alphaMap', m.mapAlpha, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );
+
+ }
+
+ //
+
+ if ( m.mapBumpScale ) {
+
+ mpars.bumpScale = m.mapBumpScale;
+
+ }
+
+ if ( m.mapNormalFactor ) {
+
+ mpars.normalScale = new THREE.Vector2( m.mapNormalFactor, m.mapNormalFactor );
+
+ }
+
+ var material = new THREE[ mtype ]( mpars );
+
+ if ( m.DbgName !== undefined ) material.name = m.DbgName;
+
+ return material;
+
+ };
+
+ } )()
+
+};
+
+THREE.Loader.Handlers = {
+
+ handlers: [],
+
+ add: function ( regex, loader ) {
+
+ this.handlers.push( regex, loader );
+
+ },
+
+ get: function ( file ) {
+
+ for ( var i = 0, l = this.handlers.length; i < l; i += 2 ) {
+
+ var regex = this.handlers[ i ];
+ var loader = this.handlers[ i + 1 ];
+
+ if ( regex.test( file ) ) {
+
+ return loader;
+
+ }
+
+ }
+
+ return null;
+
+ }
+
+}; | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/math/Vector2.js | @@ -256,7 +256,7 @@ THREE.Vector2.prototype = {
var min, max;
- return function ( minVal, maxVal ) {
+ return function clampScalar ( minVal, maxVal ) {
if ( min === undefined ) {
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/math/Vector3.js | @@ -486,7 +486,7 @@ THREE.Vector3.prototype = {
var min, max;
- return function ( minVal, maxVal ) {
+ return function clampScalar ( minVal, maxVal ) {
if ( min === undefined ) {
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/math/Vector4.js | @@ -498,7 +498,7 @@ THREE.Vector4.prototype = {
var min, max;
- return function ( minVal, maxVal ) {
+ return function clampScalar ( minVal, maxVal ) {
if ( min === undefined ) {
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/LOD.js | @@ -73,7 +73,7 @@ THREE.LOD.prototype.raycast = ( function () {
var matrixPosition = new THREE.Vector3();
- return function ( raycaster, intersects ) {
+ return function raycast ( raycaster, intersects ) {
matrixPosition.setFromMatrixPosition( this.matrixWorld );
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/Line.js | @@ -28,7 +28,7 @@ THREE.Line.prototype.raycast = ( function () {
var ray = new THREE.Ray();
var sphere = new THREE.Sphere();
- return function ( raycaster, intersects ) {
+ return function raycast ( raycaster, intersects ) {
var precision = raycaster.linePrecision;
var precisionSq = precision * precision; | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/Mesh.js | @@ -66,7 +66,7 @@ THREE.Mesh.prototype.raycast = ( function () {
var vB = new THREE.Vector3();
var vC = new THREE.Vector3();
- return function ( raycaster, intersects ) {
+ return function raycast ( raycaster, intersects ) {
var geometry = this.geometry;
var material = this.material; | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/PointCloud.js | @@ -21,7 +21,7 @@ THREE.PointCloud.prototype.raycast = ( function () {
var inverseMatrix = new THREE.Matrix4();
var ray = new THREE.Ray();
- return function ( raycaster, intersects ) {
+ return function raycast ( raycaster, intersects ) {
var object = this;
var geometry = object.geometry; | true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/Skeleton.js | @@ -145,7 +145,7 @@ THREE.Skeleton.prototype.update = ( function () {
var offsetMatrix = new THREE.Matrix4();
- return function () {
+ return function update ( ) {
// flatten bone matrices to array
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/objects/Sprite.js | @@ -14,7 +14,7 @@ THREE.Sprite = ( function () {
geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
- return function ( material ) {
+ return function Sprite ( material ) {
THREE.Object3D.call( this );
@@ -34,7 +34,7 @@ THREE.Sprite.prototype.raycast = ( function () {
var matrixPosition = new THREE.Vector3();
- return function ( raycaster, intersects ) {
+ return function raycast ( raycaster, intersects ) {
matrixPosition.setFromMatrixPosition( this.matrixWorld );
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/renderers/WebGLRenderer.js | @@ -312,7 +312,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var array;
- return function () {
+ return function getCompressedTextureFormats ( ) {
if ( array !== undefined ) {
@@ -439,7 +439,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var value;
- return function () {
+ return function getMaxAnisotropy() {
if ( value !== undefined ) return value;
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/renderers/webgl/WebGLProgram.js | @@ -76,7 +76,7 @@ THREE.WebGLProgram = ( function () {
}
- return function ( renderer, code, material, parameters ) {
+ return function WebGLProgram ( renderer, code, material, parameters ) {
var gl = renderer.context;
| true |
Other | mrdoob | three.js | 22b4a311c7c1af6f56578153f2d3944ef8d90f17.json | add function definintion to closured functions | src/renderers/webgl/WebGLShader.js | @@ -14,7 +14,7 @@ THREE.WebGLShader = ( function () {
};
- return function ( gl, type, string ) {
+ return function WebGLShader ( gl, type, string ) {
var shader = gl.createShader( type );
| true |
Other | mrdoob | three.js | 342d064345ea802c0fba82d1f389e3ae5800d7fe.json | add example usage | src/objects/Mesh.js | @@ -65,6 +65,11 @@ THREE.Mesh.prototype.raycast = ( function () {
var vA = new THREE.Vector3();
var vB = new THREE.Vector3();
var vC = new THREE.Vector3();
+
+ var tempA = new THREE.Vector3();
+ var tempB = new THREE.Vector3();
+ var tempC = new THREE.Vector3();
+
return function ( raycaster, intersects ) {
@@ -221,6 +226,7 @@ THREE.Mesh.prototype.raycast = ( function () {
var vertices = geometry.vertices;
var faces = geometry.faces;
+
for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
var face = faces[ f ];
@@ -248,18 +254,10 @@ THREE.Mesh.prototype.raycast = ( function () {
if ( influence === 0 ) continue;
var targets = morphTargets[ t ].vertices;
-
- vA.x += ( targets[ face.a ].x - a.x ) * influence;
- vA.y += ( targets[ face.a ].y - a.y ) * influence;
- vA.z += ( targets[ face.a ].z - a.z ) * influence;
-
- vB.x += ( targets[ face.b ].x - b.x ) * influence;
- vB.y += ( targets[ face.b ].y - b.y ) * influence;
- vB.z += ( targets[ face.b ].z - b.z ) * influence;
-
- vC.x += ( targets[ face.c ].x - c.x ) * influence;
- vC.y += ( targets[ face.c ].y - c.y ) * influence;
- vC.z += ( targets[ face.c ].z - c.z ) * influence;
+
+ vA.addScaledVector(tempA.subVectors(targets[ face.a ], a),influence);
+ vB.addScaledVector(tempB.subVectors(targets[ face.b ], b),influence);
+ vC.addScaledVector(tempC.subVectors(targets[ face.c ], c),influence);
}
| false |
Other | mrdoob | three.js | 38ad9b560e25db5d5fd596160652884ad5bd1bbd.json | Use version counter for texture updates.
- Use version counter for texture updates.
- WebGLTextures is not used (removed). | src/renderers/WebGLRenderer.js | @@ -3217,9 +3217,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- this.uploadTexture = function ( texture, slot ) {
-
- var textureProperties = properties.get( texture );
+ function uploadTexture( textureProperties, texture, slot ) {
if ( textureProperties.__webglInit === undefined ) {
@@ -3329,15 +3327,17 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( texture.generateMipmaps && isImagePowerOfTwo ) _gl.generateMipmap( _gl.TEXTURE_2D );
- texture.needsUpdate = false;
+ textureProperties.__version = texture.version;
if ( texture.onUpdate ) texture.onUpdate( texture );
- };
+ }
this.setTexture = function ( texture, slot ) {
- if ( texture.needsUpdate === true ) {
+ var textureProperties = properties.get( texture );
+
+ if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
var image = texture.image;
@@ -3355,13 +3355,13 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- _this.uploadTexture( texture, slot );
+ uploadTexture( textureProperties, texture, slot );
return;
}
state.activeTexture( _gl.TEXTURE0 + slot );
- state.bindTexture( _gl.TEXTURE_2D, properties.get( texture ).__webglTexture );
+ state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );
};
@@ -3397,7 +3397,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( texture.image.length === 6 ) {
- if ( texture.needsUpdate ) {
+ if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
if ( ! textureProperties.__image__webglTextureCube ) {
@@ -3492,7 +3492,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- texture.needsUpdate = false;
+ textureProperties.__version = texture.version;
if ( texture.onUpdate ) texture.onUpdate( texture );
| true |
Other | mrdoob | three.js | 38ad9b560e25db5d5fd596160652884ad5bd1bbd.json | Use version counter for texture updates.
- Use version counter for texture updates.
- WebGLTextures is not used (removed). | src/renderers/webgl/WebGLTextures.js | @@ -1,41 +0,0 @@
-/**
-* @author mrdoob / http://mrdoob.com/
-*/
-
-THREE.WebGLTextures = function ( gl ) {
-
- var textures = {};
-
- this.get = function ( texture ) {
-
- if ( textures[ texture.id ] !== undefined ) {
-
- return textures[ texture.id ];
-
- }
-
- return this.create( texture );
-
- };
-
- this.create = function ( texture ) {
-
- texture.addEventListener( 'dispose', this.delete );
-
- textures[ texture.id ] = gl.createTexture();
-
- return textures[ texture.id ];
-
- };
-
- this.delete = function ( texture ) {
-
- texture.removeEventListener( 'dispose', this.delete );
-
- gl.deleteTexture( textures[ texture.id ] );
-
- delete textures[ texture.id ];
-
- };
-
-}; | true |
Other | mrdoob | three.js | 38ad9b560e25db5d5fd596160652884ad5bd1bbd.json | Use version counter for texture updates.
- Use version counter for texture updates.
- WebGLTextures is not used (removed). | src/textures/Texture.js | @@ -37,7 +37,7 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
this.flipY = true;
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
- this._needsUpdate = false;
+ this.version = 0;
this.onUpdate = null;
};
@@ -49,17 +49,11 @@ THREE.Texture.prototype = {
constructor: THREE.Texture,
- get needsUpdate () {
-
- return this._needsUpdate;
-
- },
-
set needsUpdate ( value ) {
if ( value === true ) this.update();
- this._needsUpdate = value;
+ this.version ++;
},
| true |
Other | mrdoob | three.js | d59c631422be24cfadd6ad51706dae37ba00113d.json | add code styling | package.json | @@ -26,5 +26,8 @@
"bugs": {
"url": "https://github.com/mrdoob/three.js/issues"
},
- "homepage": "http://threejs.org/"
+ "homepage": "http://threejs.org/",
+ "devDependencies": {
+ "jscs": "^1.13.1"
+ }
} | true |
Other | mrdoob | three.js | d59c631422be24cfadd6ad51706dae37ba00113d.json | add code styling | utils/codestyle/codestyle.sh | @@ -0,0 +1,5 @@
+
+jscs "../../src" --fix --preset=mdcs
+jscs "../../examples/js" --fix --preset=mdcs
+
+ | true |
Other | mrdoob | three.js | d59c631422be24cfadd6ad51706dae37ba00113d.json | add code styling | utils/codestyle/config.json | @@ -0,0 +1,13 @@
+{
+ "preset": "mdcs",
+ "excludeFiles": [
+ "build/**",
+ "docs/**",
+ "editor/**",
+ "examples/**",
+ "node_modules/**",
+ "test/**",
+ "utils/**"
+ ]
+
+}
\ No newline at end of file | true |
Other | mrdoob | three.js | 5c07056cdd54d7c52d5eb304c502ab1fb748c52f.json | implement XHRLoader in STLLoader.js | examples/js/loaders/STLLoader.js | @@ -8,32 +8,28 @@
* Supports both binary and ASCII encoded files, with automatic detection of type.
*
* Limitations:
- * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
- * There is perhaps some question as to how valid it is to always assume little-endian-ness.
- * ASCII decoding assumes file is UTF-8. Seems to work for the examples...
+ * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
+ * There is perhaps some question as to how valid it is to always assume little-endian-ness.
+ * ASCII decoding assumes file is UTF-8. Seems to work for the examples...
*
* Usage:
- * var loader = new THREE.STLLoader();
- * loader.addEventListener( 'load', function ( event ) {
- *
- * var geometry = event.content;
- * scene.add( new THREE.Mesh( geometry ) );
- *
- * } );
- * loader.load( './models/stl/slotted_disk.stl' );
+ * var loader = new THREE.STLLoader();
+ * loader.load( './models/stl/slotted_disk.stl', function(geometry){
+ * scene.add( new THREE.Mesh( geometry ) );
+ * });
*
* For binary STLs geometry might contain colors for vertices. To use it:
- * ... // use the same code to load STL as above
- * var geometry = event.content;
- * if (geometry.hasColors) {
- * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors });
- * } else { .... }
- * var mesh = new THREE.Mesh( geometry, material );
+ * ... // use the same code to load STL as above
+ * if (geometry.hasColors) {
+ * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors });
+ * } else { .... }
+ * var mesh = new THREE.Mesh( geometry, material );
*/
-THREE.STLLoader = function (manager) {
- this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+THREE.STLLoader = function (manager, crossOrigin) {
+ this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+ this.crossOrigin = crossOrigin;
};
THREE.STLLoader.prototype = {
@@ -42,53 +38,21 @@ THREE.STLLoader.prototype = {
};
-THREE.STLLoader.prototype.load = function ( url, callback ) {
-
- var scope = this;
-
- var xhr = new XMLHttpRequest();
-
- function onloaded( event ) {
-
- if ( event.target.status === 200 || event.target.status === 0 ) {
-
- var geometry = scope.parse( event.target.response || event.target.responseText );
-
- scope.dispatchEvent( { type: 'load', content: geometry } );
-
- if ( callback ) callback( geometry );
-
- } else {
-
- scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']', response: event.target.statusText } );
-
- }
-
- }
-
- xhr.addEventListener( 'load', function(event){
- onloaded(event);
- scope.manager.itemEnd( url );
- }, false );
-
- xhr.addEventListener( 'progress', function ( event ) {
-
- scope.dispatchEvent( { type: 'progress', loaded: event.loaded, total: event.total } );
-
- }, false );
+THREE.STLLoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
- xhr.addEventListener( 'error', function () {
+ var scope = this;
- scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']' } );
+ var loader = new THREE.XHRLoader( scope.manager );
+ loader.setCrossOrigin( this.crossOrigin );
+ loader.setResponseType('arraybuffer');
+ loader.load( url, function ( text ) {
- }, false );
+ var geometry = scope.parse( text );
- if ( xhr.overrideMimeType ) xhr.overrideMimeType( 'text/plain; charset=x-user-defined' );
- xhr.open( 'GET', url, true );
- xhr.responseType = 'arraybuffer';
- xhr.send( null );
+ if ( onLoad )
+ onLoad( geometry );
- scope.manager.itemStart( url );
+ }, onProgress, onError);
};
| false |
Other | mrdoob | three.js | 4a1c953d9cdc42be93ca5f7a4dd8cd74509213be.json | hook the loading manager in STLLoader.js | examples/js/loaders/STLLoader.js | @@ -2,6 +2,7 @@
* @author aleeper / http://adamleeper.com/
* @author mrdoob / http://mrdoob.com/
* @author gero3 / https://github.com/gero3
+ * @author zinefer / https://github.com/zinefer
*
* Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
*
@@ -32,7 +33,9 @@
*/
-THREE.STLLoader = function () {};
+THREE.STLLoader = function (manager) {
+ this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
+};
THREE.STLLoader.prototype = {
@@ -64,7 +67,10 @@ THREE.STLLoader.prototype.load = function ( url, callback ) {
}
- xhr.addEventListener( 'load', onloaded, false );
+ xhr.addEventListener( 'load', function(event){
+ onloaded(event);
+ scope.manager.itemEnd( url );
+ }, false );
xhr.addEventListener( 'progress', function ( event ) {
@@ -83,6 +89,8 @@ THREE.STLLoader.prototype.load = function ( url, callback ) {
xhr.responseType = 'arraybuffer';
xhr.send( null );
+ scope.manager.itemStart( url );
+
};
THREE.STLLoader.prototype.parse = function ( data ) { | false |
Other | mrdoob | three.js | 9e64158db30626c7ee1ae70c4b7caecd70a37d51.json | Convert global variables to local variables
This file is unnecessarily adding global variables with names like v, w, loader, etc. Polluting the global namespace is dangerous and makes everyone's code more prone to bugs.
I simply added "var" declarations to convert the global variables to local variables. | examples/js/loaders/ColladaLoader.js | @@ -635,7 +635,7 @@ THREE.ColladaLoader = function () {
var bones = [];
setupSkeleton( skeleton, bones, -1 );
setupSkinningMatrices( bones, skinController.skin );
- v = new THREE.Vector3();
+ var v = new THREE.Vector3();
var skinned = [];
for (var i = 0; i < geometry.vertices.length; i ++) {
@@ -648,14 +648,14 @@ THREE.ColladaLoader = function () {
if ( bones[ i ].type != 'JOINT' ) continue;
- for ( j = 0; j < bones[ i ].weights.length; j ++ ) {
+ for ( var j = 0; j < bones[ i ].weights.length; j ++ ) {
- w = bones[ i ].weights[ j ];
- vidx = w.index;
- weight = w.weight;
+ var w = bones[ i ].weights[ j ];
+ var vidx = w.index;
+ var weight = w.weight;
- o = geometry.vertices[vidx];
- s = skinned[vidx];
+ var o = geometry.vertices[vidx];
+ var s = skinned[vidx];
v.x = o.x;
v.y = o.y;
@@ -5188,7 +5188,7 @@ THREE.ColladaLoader = function () {
function loadTextureImage ( texture, url ) {
- loader = new THREE.ImageLoader();
+ var loader = new THREE.ImageLoader();
loader.load( url, function ( image ) {
| false |
Other | mrdoob | three.js | e48977f91658cc8cd896d2ac34445f232212c4f5.json | Remove unused variable in CombinedCamera.js | examples/js/cameras/CombinedCamera.js | @@ -29,8 +29,6 @@ THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orth
this.toPerspective();
- var aspect = width / height;
-
};
THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype ); | false |
Other | mrdoob | three.js | 1b8645ccae0659da5bf6d3f999a8b24d147df83e.json | Fix comment typo | examples/js/cameras/CombinedCamera.js | @@ -129,7 +129,7 @@ THREE.CombinedCamera.prototype.setFov = function( fov ) {
};
-// For mantaining similar API with PerspectiveCamera
+// For maintaining similar API with PerspectiveCamera
THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {
| false |