From b827aaef258831a02c846ad9468bf7889deef9a1 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 1 Apr 2014 17:21:12 -0700 Subject: [PATCH] Typed* to Proxy* --- src/core/{Geometry.js => ProxyGeometry.js} | 96 +++++++++---------- .../proxies/{TypedColor.js => ProxyColor.js} | 6 +- .../proxies/{TypedFace3.js => ProxyFace3.js} | 6 +- .../{TypedVector2.js => ProxyVector2.js} | 6 +- .../{TypedVector3.js => ProxyVector3.js} | 6 +- .../{TypedVector4.js => ProxyVector4.js} | 6 +- utils/build/includes/common.json | 12 +-- 7 files changed, 69 insertions(+), 69 deletions(-) rename src/core/{Geometry.js => ProxyGeometry.js} (83%) rename src/core/proxies/{TypedColor.js => ProxyColor.js} (78%) rename src/core/proxies/{TypedFace3.js => ProxyFace3.js} (84%) rename src/core/proxies/{TypedVector2.js => ProxyVector2.js} (71%) rename src/core/proxies/{TypedVector3.js => ProxyVector3.js} (76%) rename src/core/proxies/{TypedVector4.js => ProxyVector4.js} (80%) diff --git a/src/core/Geometry.js b/src/core/ProxyGeometry.js similarity index 83% rename from src/core/Geometry.js rename to src/core/ProxyGeometry.js index 0e1c672f9a..886256160d 100644 --- a/src/core/Geometry.js +++ b/src/core/ProxyGeometry.js @@ -8,7 +8,7 @@ * @author jbaicoianu / http://baicoianu.com */ -THREE.Geometry = function ( ) { +THREE.ProxyGeometry = function ( ) { THREE.BufferGeometry.call( this ); @@ -20,9 +20,9 @@ THREE.Geometry = function ( ) { }; -THREE.Geometry.prototype = Object.create( THREE.IndexedGeometry2.prototype ); +THREE.ProxyGeometry.prototype = Object.create( THREE.IndexedGeometry2.prototype ); -Object.defineProperties(THREE.Geometry.prototype, { +Object.defineProperties(THREE.ProxyGeometry.prototype, { vertices: { enumerable: true, configurable: true, @@ -70,7 +70,7 @@ Object.defineProperties(THREE.Geometry.prototype, { }, }); -THREE.Geometry.prototype.createVertexProxies = function(values) { +THREE.ProxyGeometry.prototype.createVertexProxies = function(values) { if (!this.hasOwnProperty('vertices')) { @@ -88,7 +88,7 @@ THREE.Geometry.prototype.createVertexProxies = function(values) { // If the attribute buffer has already been populated, set up proxy objects - this.populateProxyFromBuffer(this.vertices, "position", THREE.TypedVector3, 3); + this.populateProxyFromBuffer(this.vertices, "position", THREE.ProxyVector3, 3); // If values were passed in, store them in the buffer via the proxy objects @@ -107,7 +107,7 @@ THREE.Geometry.prototype.createVertexProxies = function(values) { } -THREE.Geometry.prototype.createFaceProxies = function(values) { +THREE.ProxyGeometry.prototype.createFaceProxies = function(values) { if (!this.hasOwnProperty("faces")) { @@ -155,7 +155,7 @@ THREE.Geometry.prototype.createFaceProxies = function(values) { var o = i * 3; - var face = new THREE.TypedFace3( indexarray, i * 3 ); + var face = new THREE.ProxyFace3( indexarray, i * 3 ); faces.push(face); } @@ -167,7 +167,7 @@ THREE.Geometry.prototype.createFaceProxies = function(values) { var o = i * 3; var v1 = i, v2 = i+1, v3 = i+2; - var face = new THREE.TypedFace3( v1, v2, v3 ); + var face = new THREE.ProxyFace3( v1, v2, v3 ); faces.push(face); } @@ -215,7 +215,7 @@ THREE.Geometry.prototype.createFaceProxies = function(values) { } -THREE.Geometry.prototype.createFaceVertexNormalProxies = function(values) { +THREE.ProxyGeometry.prototype.createFaceVertexNormalProxies = function(values) { if ( this.attributes[ 'normal' ] && this.attributes[ 'normal' ].array ) { @@ -226,9 +226,9 @@ THREE.Geometry.prototype.createFaceVertexNormalProxies = function(values) { var f = this.faces[i]; f.vertexNormals = [ - new THREE.TypedVector3(normalarray, f.a * 3), - new THREE.TypedVector3(normalarray, f.b * 3), - new THREE.TypedVector3(normalarray, f.c * 3), + 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); @@ -264,7 +264,7 @@ THREE.Geometry.prototype.createFaceVertexNormalProxies = function(values) { } -THREE.Geometry.prototype.createFaceVertexColorProxies = function(values) { +THREE.ProxyGeometry.prototype.createFaceVertexColorProxies = function(values) { if ( this.attributes[ 'color' ] && this.attributes[ 'color' ].array ) { @@ -275,17 +275,17 @@ THREE.Geometry.prototype.createFaceVertexColorProxies = function(values) { if ( this.attributes[ 'index' ] ) { f.vertexColors = [ - new THREE.TypedColor(colorarray, f.a * 3), - new THREE.TypedColor(colorarray, f.b * 3), - new THREE.TypedColor(colorarray, f.c * 3), + 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.TypedColor(colorarray, o), - new THREE.TypedColor(colorarray, o + 3), - new THREE.TypedColor(colorarray, o + 6), + new THREE.ProxyColor(colorarray, o), + new THREE.ProxyColor(colorarray, o + 3), + new THREE.ProxyColor(colorarray, o + 6), ]; } f.color = new THREE.MultiColor(f.vertexColors); @@ -322,7 +322,7 @@ THREE.Geometry.prototype.createFaceVertexColorProxies = function(values) { } -THREE.Geometry.prototype.createFaceVertexTangentProxies = function(values) { +THREE.ProxyGeometry.prototype.createFaceVertexTangentProxies = function(values) { if ( this.attributes[ 'tangent' ] && this.attributes[ 'tangent' ].array ) { @@ -333,9 +333,9 @@ THREE.Geometry.prototype.createFaceVertexTangentProxies = function(values) { var f = this.faces[i]; f.vertexTangents = [ - new THREE.TypedVector3(tangentarray, f.a * 3), - new THREE.TypedVector3(tangentarray, f.b * 3), - new THREE.TypedVector3(tangentarray, f.c * 3), + new THREE.ProxyVector3(tangentarray, f.a * 3), + new THREE.ProxyVector3(tangentarray, f.b * 3), + new THREE.ProxyVector3(tangentarray, f.c * 3), ]; } @@ -366,7 +366,7 @@ THREE.Geometry.prototype.createFaceVertexTangentProxies = function(values) { } -THREE.Geometry.prototype.createUvProxies = function(values) { +THREE.ProxyGeometry.prototype.createUvProxies = function(values) { // Replace the prototype getter with a local array property @@ -389,14 +389,14 @@ THREE.Geometry.prototype.createUvProxies = function(values) { this.faceVertexUvs[0][i] = []; if ( this.attributes[ 'index' ] ) { - this.faceVertexUvs[0][i][0] = new THREE.TypedVector2(uvarray, f.a * 2); - this.faceVertexUvs[0][i][1] = new THREE.TypedVector2(uvarray, f.b * 2); - this.faceVertexUvs[0][i][2] = new THREE.TypedVector2(uvarray, f.c * 2); + 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.TypedVector2(uvarray, o); - this.faceVertexUvs[0][i][1] = new THREE.TypedVector2(uvarray, o + 2); - this.faceVertexUvs[0][i][2] = new THREE.TypedVector2(uvarray, o + 4); + 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); } } @@ -426,7 +426,7 @@ THREE.Geometry.prototype.createUvProxies = function(values) { } -THREE.Geometry.prototype.createSkinIndexProxies = function(values) { +THREE.ProxyGeometry.prototype.createSkinIndexProxies = function(values) { // Replace the prototype getter with a local array property @@ -438,7 +438,7 @@ THREE.Geometry.prototype.createSkinIndexProxies = function(values) { // If the attribute buffer has already been populated, set up proxy objects - this.populateProxyFromBuffer(this.skinIndices, "skinIndex", THREE.TypedVector4, 4); + this.populateProxyFromBuffer(this.skinIndices, "skinIndex", THREE.ProxyVector4, 4); // If values were passed in, store them in the buffer via the proxy objects @@ -458,7 +458,7 @@ THREE.Geometry.prototype.createSkinIndexProxies = function(values) { } -THREE.Geometry.prototype.createSkinWeightProxies = function(values) { +THREE.ProxyGeometry.prototype.createSkinWeightProxies = function(values) { // Replace the prototype getter with a local array property @@ -470,7 +470,7 @@ THREE.Geometry.prototype.createSkinWeightProxies = function(values) { // If the attribute buffer has already been populated, set up proxy objects - this.populateProxyFromBuffer(this.skinWeights, "skinWeight", THREE.TypedVector4, 4); + this.populateProxyFromBuffer(this.skinWeights, "skinWeight", THREE.ProxyVector4, 4); // If values were passed in, store them in the buffer via the proxy objects @@ -490,7 +490,7 @@ THREE.Geometry.prototype.createSkinWeightProxies = function(values) { } -THREE.Geometry.prototype.createColorProxies = function(values) { +THREE.ProxyGeometry.prototype.createColorProxies = function(values) { // Replace the prototype getter with a local array property @@ -502,7 +502,7 @@ THREE.Geometry.prototype.createColorProxies = function(values) { // If the attribute buffer has already been populated, set up proxy objects - this.populateProxyFromBuffer(this.colors, "color", THREE.TypedColor, 3); + this.populateProxyFromBuffer(this.colors, "color", THREE.ProxyColor, 3); // If values were passed in, store them in the buffer via the proxy objects @@ -522,7 +522,7 @@ THREE.Geometry.prototype.createColorProxies = function(values) { } -THREE.Geometry.prototype.populateProxyFromBuffer = function(attr, buffername, proxytype, itemsize, offset, count) { +THREE.ProxyGeometry.prototype.populateProxyFromBuffer = function(attr, buffername, proxytype, itemsize, offset, count) { if ( this.attributes[ buffername ] && this.attributes[ buffername ].array ) { @@ -548,7 +548,7 @@ THREE.Geometry.prototype.populateProxyFromBuffer = function(attr, buffername, pr * and faces' vertices are updated. */ -THREE.Geometry.prototype.mergeVertices = function () { +THREE.ProxyGeometry.prototype.mergeVertices = function () { var verticesMap = {}; // Hashmap for looking up vertice by position coordinates (and making sure they are unique) var unique = [], changes = []; @@ -631,7 +631,7 @@ THREE.Geometry.prototype.mergeVertices = function () { } -THREE.Geometry.prototype.onGeometryAllocate = function (ev) { +THREE.ProxyGeometry.prototype.onGeometryAllocate = function (ev) { // Prevent allocate event listener from firing multiple times this.removeEventListener( 'allocate', this.onGeometryAllocate); @@ -694,7 +694,7 @@ THREE.Geometry.prototype.onGeometryAllocate = function (ev) { } } -THREE.Geometry.prototype.computeFaceNormals = function() { +THREE.ProxyGeometry.prototype.computeFaceNormals = function() { this.dispatchEvent( { type: 'allocate' } ); @@ -702,7 +702,7 @@ THREE.Geometry.prototype.computeFaceNormals = function() { } -THREE.Geometry.prototype.computeVertexNormals = function() { +THREE.ProxyGeometry.prototype.computeVertexNormals = function() { this.dispatchEvent( { type: 'allocate' } ); @@ -710,7 +710,7 @@ THREE.Geometry.prototype.computeVertexNormals = function() { } -THREE.Geometry.prototype.computeTangents = function() { +THREE.ProxyGeometry.prototype.computeTangents = function() { this.dispatchEvent( { type: 'allocate' } ); @@ -723,7 +723,7 @@ THREE.Geometry.prototype.computeTangents = function() { } -THREE.Geometry.prototype.computeBoundingSphere = function() { +THREE.ProxyGeometry.prototype.computeBoundingSphere = function() { this.dispatchEvent( { type: 'allocate' } ); @@ -731,17 +731,17 @@ THREE.Geometry.prototype.computeBoundingSphere = function() { } -THREE.Geometry.prototype.computeBoundingBox = function () { +THREE.ProxyGeometry.prototype.computeBoundingBox = function () { this.dispatchEvent( { type: 'allocate' } ); return THREE.BufferGeometry.prototype.computeBoundingBox.call(this); } -THREE.Geometry.prototype.clone = function () { +THREE.ProxyGeometry.prototype.clone = function () { var buff = THREE.BufferGeometry.prototype.clone.call(this); - var geo = new THREE.Geometry(); + var geo = new THREE.ProxyGeometry(); geo.attributes = buff.attributes; geo.offsets = buff.offsets; @@ -749,6 +749,6 @@ THREE.Geometry.prototype.clone = function () { } -THREE.EventDispatcher.prototype.apply( THREE.Geometry.prototype ); +THREE.EventDispatcher.prototype.apply( THREE.ProxyGeometry.prototype ); -THREE.GeometryIdCount = 0; +THREE.ProxyGeometryIdCount = 0; diff --git a/src/core/proxies/TypedColor.js b/src/core/proxies/ProxyColor.js similarity index 78% rename from src/core/proxies/TypedColor.js rename to src/core/proxies/ProxyColor.js index 2dc19506e9..2209bacaaa 100644 --- a/src/core/proxies/TypedColor.js +++ b/src/core/proxies/ProxyColor.js @@ -3,16 +3,16 @@ * @author jbaicoianu / http://baicoianu.com/ */ -THREE.TypedColor = function ( array, offset ) { +THREE.ProxyColor = function ( array, offset ) { this.array = array; this.offset = offset; } -THREE.TypedColor.prototype = Object.create( THREE.Color.prototype ); +THREE.ProxyColor.prototype = Object.create( THREE.Color.prototype ); -Object.defineProperties( THREE.TypedColor.prototype, { +Object.defineProperties( THREE.ProxyColor.prototype, { 'r': { enumerable: true, get: function () { return this.array[ this.offset ]; }, diff --git a/src/core/proxies/TypedFace3.js b/src/core/proxies/ProxyFace3.js similarity index 84% rename from src/core/proxies/TypedFace3.js rename to src/core/proxies/ProxyFace3.js index 546d4fe12d..a2a480f682 100644 --- a/src/core/proxies/TypedFace3.js +++ b/src/core/proxies/ProxyFace3.js @@ -2,7 +2,7 @@ * @author jbaicoianu / http://baicoianu.com/ */ -THREE.TypedFace3 = function ( array, offset, vertexNormals, vertexColors, vertexTangents ) { +THREE.ProxyFace3 = function ( array, offset, vertexNormals, vertexColors, vertexTangents ) { this.array = array; this.offset = offset; @@ -17,9 +17,9 @@ THREE.TypedFace3 = function ( array, offset, vertexNormals, vertexColors, vertex } -THREE.TypedFace3.prototype = Object.create( THREE.Face3.prototype ); +THREE.ProxyFace3.prototype = Object.create( THREE.Face3.prototype ); -Object.defineProperties( THREE.TypedFace3.prototype, { +Object.defineProperties( THREE.ProxyFace3.prototype, { 'a': { enumerable: true, get: function () { return this.array[ this.offset ]; }, diff --git a/src/core/proxies/TypedVector2.js b/src/core/proxies/ProxyVector2.js similarity index 71% rename from src/core/proxies/TypedVector2.js rename to src/core/proxies/ProxyVector2.js index ba76e22303..ee0230a655 100644 --- a/src/core/proxies/TypedVector2.js +++ b/src/core/proxies/ProxyVector2.js @@ -3,16 +3,16 @@ * @author jbaicoianu / http://baicoianu.com/ */ -THREE.TypedVector2 = function ( array, offset ) { +THREE.ProxyVector2 = function ( array, offset ) { this.array = array; this.offset = offset; }; -THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype ); +THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype ); -Object.defineProperties( THREE.TypedVector2.prototype, { +Object.defineProperties( THREE.ProxyVector2.prototype, { 'x': { get: function () { return this.array[ this.offset ]; }, set: function ( v ) { this.array[ this.offset ] = v; } diff --git a/src/core/proxies/TypedVector3.js b/src/core/proxies/ProxyVector3.js similarity index 76% rename from src/core/proxies/TypedVector3.js rename to src/core/proxies/ProxyVector3.js index 61ea566358..61cdc6b9ba 100644 --- a/src/core/proxies/TypedVector3.js +++ b/src/core/proxies/ProxyVector3.js @@ -3,16 +3,16 @@ * @author jbaicoianu / http://baicoianu.com/ */ -THREE.TypedVector3 = function ( array, offset ) { +THREE.ProxyVector3 = function ( array, offset ) { this.array = array; this.offset = offset; }; -THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype ); +THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype ); -Object.defineProperties( THREE.TypedVector3.prototype, { +Object.defineProperties( THREE.ProxyVector3.prototype, { 'x': { get: function () { return this.array[ this.offset ]; }, set: function ( v ) { this.array[ this.offset ] = v; } diff --git a/src/core/proxies/TypedVector4.js b/src/core/proxies/ProxyVector4.js similarity index 80% rename from src/core/proxies/TypedVector4.js rename to src/core/proxies/ProxyVector4.js index 071b1da8ee..6a6c5a228e 100644 --- a/src/core/proxies/TypedVector4.js +++ b/src/core/proxies/ProxyVector4.js @@ -3,16 +3,16 @@ * @author jbaicoianu / http://baicoianu.com/ */ -THREE.TypedVector4 = function ( array, offset ) { +THREE.ProxyVector4 = function ( array, offset ) { this.array = array; this.offset = offset; }; -THREE.TypedVector4.prototype = Object.create( THREE.Vector4.prototype ); +THREE.ProxyVector4.prototype = Object.create( THREE.Vector4.prototype ); -Object.defineProperties( THREE.TypedVector4.prototype, { +Object.defineProperties( THREE.ProxyVector4.prototype, { 'x': { get: function () { return this.array[ this.offset ]; }, set: function ( v ) { this.array[ this.offset ] = v; } diff --git a/utils/build/includes/common.json b/utils/build/includes/common.json index 0f7ddafe35..16082accb3 100644 --- a/utils/build/includes/common.json +++ b/utils/build/includes/common.json @@ -31,14 +31,14 @@ "src/core/BufferGeometryManipulator.js", "src/core/Geometry2.js", "src/core/IndexedGeometry2.js", - "src/core/Geometry.js", + "src/core/ProxyGeometry.js", "src/core/proxies/MultiColor.js", "src/core/proxies/MultiVector3.js", - "src/core/proxies/TypedColor.js", - "src/core/proxies/TypedVector2.js", - "src/core/proxies/TypedVector3.js", - "src/core/proxies/TypedVector4.js", - "src/core/proxies/TypedFace3.js", + "src/core/proxies/ProxyColor.js", + "src/core/proxies/ProxyVector2.js", + "src/core/proxies/ProxyVector3.js", + "src/core/proxies/ProxyVector4.js", + "src/core/proxies/ProxyFace3.js", "src/cameras/Camera.js", "src/cameras/OrthographicCamera.js", "src/cameras/PerspectiveCamera.js", -- GitLab