|
@@ -3,7 +3,7 @@
|
|
|
* @author Larry Battle / http://bateru.com/news
|
|
|
*/
|
|
|
|
|
|
-var THREE = THREE || { REVISION: '52' };
|
|
|
+var THREE = THREE || { REVISION: '53dev' };
|
|
|
|
|
|
self.console = self.console || {
|
|
|
|
|
@@ -4865,7 +4865,8 @@ THREE.Geometry = function () {
|
|
|
this.name = '';
|
|
|
|
|
|
this.vertices = [];
|
|
|
- this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon
|
|
|
+ this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon
|
|
|
+ this.normals = []; // one-to-one vertex normals, used in Ribbon
|
|
|
|
|
|
this.materials = [];
|
|
|
|
|
@@ -4886,7 +4887,7 @@ THREE.Geometry = function () {
|
|
|
|
|
|
this.hasTangents = false;
|
|
|
|
|
|
- this.dynamic = true; // the intermediate typearrays will be deleted when set to false
|
|
|
+ this.dynamic = true; // the intermediate typed arrays will be deleted when set to false
|
|
|
|
|
|
// update flags
|
|
|
|
|
@@ -4897,6 +4898,8 @@ THREE.Geometry = function () {
|
|
|
this.tangentsNeedUpdate = false;
|
|
|
this.colorsNeedUpdate = false;
|
|
|
|
|
|
+ this.buffersNeedUpdate = false;
|
|
|
+
|
|
|
};
|
|
|
|
|
|
THREE.Geometry.prototype = {
|
|
@@ -7780,6 +7783,8 @@ THREE.JSONLoader = function ( showStatus ) {
|
|
|
|
|
|
THREE.Loader.call( this, showStatus );
|
|
|
|
|
|
+ this.withCredentials = false;
|
|
|
+
|
|
|
};
|
|
|
|
|
|
THREE.JSONLoader.prototype = Object.create( THREE.Loader.prototype );
|
|
@@ -7801,6 +7806,8 @@ THREE.JSONLoader.prototype.loadAjaxJSON = function ( context, url, callback, tex
|
|
|
|
|
|
var length = 0;
|
|
|
|
|
|
+ xhr.withCredentials = this.withCredentials;
|
|
|
+
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
|
|
if ( xhr.readyState === xhr.DONE ) {
|
|
@@ -8985,11 +8992,11 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
var urlBase = THREE.Loader.prototype.extractUrlBase( url );
|
|
|
|
|
|
- var dg, dm, dl, dc, df, dt,
|
|
|
+ var dg, dm, dc, df, dt,
|
|
|
g, m, l, d, p, r, q, s, c, t, f, tt, pp, u,
|
|
|
geometry, material, camera, fog,
|
|
|
texture, images,
|
|
|
- light,
|
|
|
+ light, hex, intensity,
|
|
|
counter_models, counter_textures,
|
|
|
total_models, total_textures,
|
|
|
result;
|
|
@@ -9083,6 +9090,8 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
var object = null;
|
|
|
|
|
|
+ // meshes
|
|
|
+
|
|
|
if ( o.geometry !== undefined ) {
|
|
|
|
|
|
geometry = result.geometries[ o.geometry ];
|
|
@@ -9205,6 +9214,69 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // lights
|
|
|
+
|
|
|
+ } else if ( o.type === "DirectionalLight" || o.type === "PointLight" || o.type === "AmbientLight" ) {
|
|
|
+
|
|
|
+ hex = ( o.color !== undefined ) ? o.color : 0xffffff;
|
|
|
+ intensity = ( o.intensity !== undefined ) ? o.intensity : 1;
|
|
|
+
|
|
|
+ if ( o.type === "DirectionalLight" ) {
|
|
|
+
|
|
|
+ p = o.direction;
|
|
|
+
|
|
|
+ light = new THREE.DirectionalLight( hex, intensity );
|
|
|
+ light.position.set( p[0], p[1], p[2] );
|
|
|
+ light.position.normalize();
|
|
|
+
|
|
|
+ } else if ( o.type === "PointLight" ) {
|
|
|
+
|
|
|
+ p = o.position;
|
|
|
+ d = o.distance;
|
|
|
+
|
|
|
+ light = new THREE.PointLight( hex, intensity, d );
|
|
|
+ light.position.set( p[0], p[1], p[2] );
|
|
|
+
|
|
|
+ } else if ( o.type === "AmbientLight" ) {
|
|
|
+
|
|
|
+ light = new THREE.AmbientLight( hex );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ parent.add( light );
|
|
|
+
|
|
|
+ light.name = dd;
|
|
|
+ result.lights[ dd ] = light;
|
|
|
+ result.objects[ dd ] = light;
|
|
|
+
|
|
|
+ // cameras
|
|
|
+
|
|
|
+ } else if ( o.type === "PerspectiveCamera" || o.type === "OrthographicCamera" ) {
|
|
|
+
|
|
|
+ if ( o.type === "PerspectiveCamera" ) {
|
|
|
+
|
|
|
+ camera = new THREE.PerspectiveCamera( o.fov, o.aspect, o.near, o.far );
|
|
|
+
|
|
|
+ } else if ( o.type === "OrthographicCamera" ) {
|
|
|
+
|
|
|
+ camera = new THREE.OrthographicCamera( c.left, c.right, c.top, c.bottom, c.near, c.far );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ p = o.position;
|
|
|
+ t = o.target;
|
|
|
+ u = o.up;
|
|
|
+
|
|
|
+ camera.position.set( p[0], p[1], p[2] );
|
|
|
+ camera.target = new THREE.Vector3( t[0], t[1], t[2] );
|
|
|
+ if ( u ) camera.up.set( u[0], u[1], u[2] );
|
|
|
+
|
|
|
+ parent.add( camera );
|
|
|
+
|
|
|
+ camera.name = dd;
|
|
|
+ result.cameras[ dd ] = camera;
|
|
|
+ result.objects[ dd ] = camera;
|
|
|
+
|
|
|
// pure Object3D
|
|
|
|
|
|
} else {
|
|
@@ -9350,73 +9422,6 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
// first go synchronous elements
|
|
|
|
|
|
- // cameras
|
|
|
-
|
|
|
- for( dc in data.cameras ) {
|
|
|
-
|
|
|
- c = data.cameras[ dc ];
|
|
|
-
|
|
|
- if ( c.type === "perspective" ) {
|
|
|
-
|
|
|
- camera = new THREE.PerspectiveCamera( c.fov, c.aspect, c.near, c.far );
|
|
|
-
|
|
|
- } else if ( c.type === "ortho" ) {
|
|
|
-
|
|
|
- camera = new THREE.OrthographicCamera( c.left, c.right, c.top, c.bottom, c.near, c.far );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- p = c.position;
|
|
|
- t = c.target;
|
|
|
- u = c.up;
|
|
|
-
|
|
|
- camera.position.set( p[0], p[1], p[2] );
|
|
|
- camera.target = new THREE.Vector3( t[0], t[1], t[2] );
|
|
|
- if ( u ) camera.up.set( u[0], u[1], u[2] );
|
|
|
-
|
|
|
- result.cameras[ dc ] = camera;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // lights
|
|
|
-
|
|
|
- var hex, intensity;
|
|
|
-
|
|
|
- for ( dl in data.lights ) {
|
|
|
-
|
|
|
- l = data.lights[ dl ];
|
|
|
-
|
|
|
- hex = ( l.color !== undefined ) ? l.color : 0xffffff;
|
|
|
- intensity = ( l.intensity !== undefined ) ? l.intensity : 1;
|
|
|
-
|
|
|
- if ( l.type === "directional" ) {
|
|
|
-
|
|
|
- p = l.direction;
|
|
|
-
|
|
|
- light = new THREE.DirectionalLight( hex, intensity );
|
|
|
- light.position.set( p[0], p[1], p[2] );
|
|
|
- light.position.normalize();
|
|
|
-
|
|
|
- } else if ( l.type === "point" ) {
|
|
|
-
|
|
|
- p = l.position;
|
|
|
- d = l.distance;
|
|
|
-
|
|
|
- light = new THREE.PointLight( hex, intensity, d );
|
|
|
- light.position.set( p[0], p[1], p[2] );
|
|
|
-
|
|
|
- } else if ( l.type === "ambient" ) {
|
|
|
-
|
|
|
- light = new THREE.AmbientLight( hex );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- result.scene.add( light );
|
|
|
-
|
|
|
- result.lights[ dl ] = light;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
// fogs
|
|
|
|
|
|
for( df in data.fogs ) {
|
|
@@ -9440,26 +9445,6 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // defaults
|
|
|
-
|
|
|
- if ( result.cameras && data.defaults.camera ) {
|
|
|
-
|
|
|
- result.currentCamera = result.cameras[ data.defaults.camera ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( result.fogs && data.defaults.fog ) {
|
|
|
-
|
|
|
- result.scene.fog = result.fogs[ data.defaults.fog ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- c = data.defaults.bgcolor;
|
|
|
- result.bgColor = new THREE.Color();
|
|
|
- result.bgColor.setRGB( c[0], c[1], c[2] );
|
|
|
-
|
|
|
- result.bgColorAlpha = data.defaults.bgalpha;
|
|
|
-
|
|
|
// now come potentially asynchronous elements
|
|
|
|
|
|
// geometries
|
|
@@ -9488,17 +9473,17 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
if ( g.type === "cube" ) {
|
|
|
|
|
|
- geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides );
|
|
|
+ geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.widthSegments, g.heightSegments, g.depthSegments, null, g.flipped, g.sides );
|
|
|
result.geometries[ dg ] = geometry;
|
|
|
|
|
|
} else if ( g.type === "plane" ) {
|
|
|
|
|
|
- geometry = new THREE.PlaneGeometry( g.width, g.height, g.segmentsWidth, g.segmentsHeight );
|
|
|
+ geometry = new THREE.PlaneGeometry( g.width, g.height, g.widthSegments, g.heightSegments );
|
|
|
result.geometries[ dg ] = geometry;
|
|
|
|
|
|
} else if ( g.type === "sphere" ) {
|
|
|
|
|
|
- geometry = new THREE.SphereGeometry( g.radius, g.segmentsWidth, g.segmentsHeight );
|
|
|
+ geometry = new THREE.SphereGeometry( g.radius, g.widthSegments, g.heightSegments );
|
|
|
result.geometries[ dg ] = geometry;
|
|
|
|
|
|
} else if ( g.type === "cylinder" ) {
|
|
@@ -9830,6 +9815,26 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
|
|
|
|
|
|
handle_objects();
|
|
|
|
|
|
+ // defaults
|
|
|
+
|
|
|
+ if ( result.cameras && data.defaults.camera ) {
|
|
|
+
|
|
|
+ result.currentCamera = result.cameras[ data.defaults.camera ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( result.fogs && data.defaults.fog ) {
|
|
|
+
|
|
|
+ result.scene.fog = result.fogs[ data.defaults.fog ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ c = data.defaults.bgcolor;
|
|
|
+ result.bgColor = new THREE.Color();
|
|
|
+ result.bgColor.setRGB( c[0], c[1], c[2] );
|
|
|
+
|
|
|
+ result.bgColorAlpha = data.defaults.bgalpha;
|
|
|
+
|
|
|
// synchronous callback
|
|
|
|
|
|
scope.callbackSync( result );
|
|
@@ -10765,6 +10770,8 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
|
|
|
|
|
|
this.id = THREE.TextureIdCount ++;
|
|
|
|
|
|
+ this.name = '';
|
|
|
+
|
|
|
this.image = image;
|
|
|
|
|
|
this.mapping = mapping !== undefined ? mapping : new THREE.UVMapping();
|
|
@@ -16036,6 +16043,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
geometry.__webglVertexBuffer = _gl.createBuffer();
|
|
|
geometry.__webglColorBuffer = _gl.createBuffer();
|
|
|
+ geometry.__webglNormalBuffer = _gl.createBuffer();
|
|
|
|
|
|
_this.info.memory.geometries ++;
|
|
|
|
|
@@ -16110,6 +16118,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
_gl.deleteBuffer( geometry.__webglVertexBuffer );
|
|
|
_gl.deleteBuffer( geometry.__webglColorBuffer );
|
|
|
+ _gl.deleteBuffer( geometry.__webglNormalBuffer );
|
|
|
|
|
|
_this.info.memory.geometries --;
|
|
|
|
|
@@ -16251,6 +16260,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
geometry.__vertexArray = new Float32Array( nvertices * 3 );
|
|
|
geometry.__colorArray = new Float32Array( nvertices * 3 );
|
|
|
+ geometry.__normalArray = new Float32Array( nvertices * 3 );
|
|
|
|
|
|
geometry.__webglVertexCount = nvertices;
|
|
|
|
|
@@ -16375,7 +16385,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {
|
|
|
+ if ( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {
|
|
|
|
|
|
attribute.__webglInitialized = true;
|
|
|
|
|
@@ -16985,18 +16995,23 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
function setRibbonBuffers ( geometry, hint ) {
|
|
|
|
|
|
- var v, c, vertex, offset, color,
|
|
|
+ var v, c, n, vertex, offset, color, normal,
|
|
|
|
|
|
vertices = geometry.vertices,
|
|
|
colors = geometry.colors,
|
|
|
+ normals = geometry.normals,
|
|
|
+
|
|
|
vl = vertices.length,
|
|
|
cl = colors.length,
|
|
|
+ nl = normals.length,
|
|
|
|
|
|
vertexArray = geometry.__vertexArray,
|
|
|
colorArray = geometry.__colorArray,
|
|
|
+ normalArray = geometry.__normalArray,
|
|
|
|
|
|
dirtyVertices = geometry.verticesNeedUpdate,
|
|
|
- dirtyColors = geometry.colorsNeedUpdate;
|
|
|
+ dirtyColors = geometry.colorsNeedUpdate,
|
|
|
+ dirtyNormals = geometry.normalsNeedUpdate;
|
|
|
|
|
|
if ( dirtyVertices ) {
|
|
|
|
|
@@ -17036,6 +17051,25 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( dirtyNormals ) {
|
|
|
+
|
|
|
+ for ( n = 0; n < nl; n ++ ) {
|
|
|
+
|
|
|
+ normal = normals[ n ];
|
|
|
+
|
|
|
+ offset = n * 3;
|
|
|
+
|
|
|
+ normalArray[ offset ] = normal.x;
|
|
|
+ normalArray[ offset + 1 ] = normal.y;
|
|
|
+ normalArray[ offset + 2 ] = normal.z;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglNormalBuffer );
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, normalArray, hint );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
};
|
|
|
|
|
|
function setMeshBuffers( geometryGroup, object, hint, dispose, material ) {
|
|
@@ -19742,6 +19776,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
geometry.verticesNeedUpdate = true;
|
|
|
geometry.colorsNeedUpdate = true;
|
|
|
+ geometry.normalsNeedUpdate = true;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -19896,6 +19931,12 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
material = getBufferMaterial( object, geometryGroup );
|
|
|
|
|
|
+ if ( geometry.buffersNeedUpdate ) {
|
|
|
+
|
|
|
+ initMeshBuffers( geometryGroup, object );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
|
|
|
|
|
|
if ( geometry.verticesNeedUpdate || geometry.morphTargetsNeedUpdate || geometry.elementsNeedUpdate ||
|
|
@@ -19916,13 +19957,15 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
geometry.colorsNeedUpdate = false;
|
|
|
geometry.tangentsNeedUpdate = false;
|
|
|
|
|
|
+ geometry.buffersNeedUpdate = false;
|
|
|
+
|
|
|
material.attributes && clearCustomAttributes( material );
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if ( object instanceof THREE.Ribbon ) {
|
|
|
|
|
|
- if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate ) {
|
|
|
+ if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || geometry.normalsNeedUpdate ) {
|
|
|
|
|
|
setRibbonBuffers( geometry, _gl.DYNAMIC_DRAW );
|
|
|
|
|
@@ -19930,6 +19973,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
geometry.verticesNeedUpdate = false;
|
|
|
geometry.colorsNeedUpdate = false;
|
|
|
+ geometry.normalsNeedUpdate = false;
|
|
|
|
|
|
} else if ( object instanceof THREE.Line ) {
|
|
|
|
|
@@ -23834,6 +23878,8 @@ THREE.ImageUtils = {
|
|
|
loader.crossOrigin = this.crossOrigin;
|
|
|
loader.load( url, image );
|
|
|
|
|
|
+ texture.sourceFile = url;
|
|
|
+
|
|
|
return texture;
|
|
|
|
|
|
},
|
|
@@ -29247,14 +29293,23 @@ THREE.CircleGeometry.prototype = Object.create( THREE.Geometry.prototype );
|
|
|
* based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
|
|
|
*/
|
|
|
|
|
|
-THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, sides ) {
|
|
|
+THREE.CubeGeometry = function ( width, height, depth, widthSegments, heightSegments, depthSegments, materials, sides ) {
|
|
|
|
|
|
THREE.Geometry.call( this );
|
|
|
|
|
|
- var scope = this,
|
|
|
- width_half = width / 2,
|
|
|
- height_half = height / 2,
|
|
|
- depth_half = depth / 2;
|
|
|
+ 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 mpx, mpy, mpz, mnx, mny, mnz;
|
|
|
|
|
@@ -29300,18 +29355,18 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei
|
|
|
|
|
|
}
|
|
|
|
|
|
- this.sides.px && buildPlane( 'z', 'y', - 1, - 1, depth, height, width_half, mpx ); // px
|
|
|
- this.sides.nx && buildPlane( 'z', 'y', 1, - 1, depth, height, - width_half, mnx ); // nx
|
|
|
- this.sides.py && buildPlane( 'x', 'z', 1, 1, width, depth, height_half, mpy ); // py
|
|
|
- this.sides.ny && buildPlane( 'x', 'z', 1, - 1, width, depth, - height_half, mny ); // ny
|
|
|
- this.sides.pz && buildPlane( 'x', 'y', 1, - 1, width, height, depth_half, mpz ); // pz
|
|
|
- this.sides.nz && buildPlane( 'x', 'y', - 1, - 1, width, height, - depth_half, mnz ); // nz
|
|
|
+ this.sides.px && buildPlane( 'z', 'y', - 1, - 1, this.depth, this.height, width_half, mpx ); // px
|
|
|
+ this.sides.nx && buildPlane( 'z', 'y', 1, - 1, this.depth, this.height, - width_half, mnx ); // nx
|
|
|
+ this.sides.py && buildPlane( 'x', 'z', 1, 1, this.width, this.depth, height_half, mpy ); // py
|
|
|
+ this.sides.ny && buildPlane( 'x', 'z', 1, - 1, this.width, this.depth, - height_half, mny ); // ny
|
|
|
+ this.sides.pz && buildPlane( 'x', 'y', 1, - 1, this.width, this.height, depth_half, mpz ); // pz
|
|
|
+ this.sides.nz && buildPlane( 'x', 'y', - 1, - 1, this.width, this.height, - depth_half, mnz ); // nz
|
|
|
|
|
|
function buildPlane( u, v, udir, vdir, width, height, depth, material ) {
|
|
|
|
|
|
var w, ix, iy,
|
|
|
- gridX = segmentsWidth || 1,
|
|
|
- gridY = segmentsHeight || 1,
|
|
|
+ gridX = scope.widthSegments,
|
|
|
+ gridY = scope.heightSegments,
|
|
|
width_half = width / 2,
|
|
|
height_half = height / 2,
|
|
|
offset = scope.vertices.length;
|
|
@@ -29323,12 +29378,12 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei
|
|
|
} else if ( ( u === 'x' && v === 'z' ) || ( u === 'z' && v === 'x' ) ) {
|
|
|
|
|
|
w = 'y';
|
|
|
- gridY = segmentsDepth || 1;
|
|
|
+ gridY = scope.depthSegments;
|
|
|
|
|
|
} else if ( ( u === 'z' && v === 'y' ) || ( u === 'y' && v === 'z' ) ) {
|
|
|
|
|
|
w = 'x';
|
|
|
- gridX = segmentsDepth || 1;
|
|
|
+ gridX = scope.depthSegments;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -30483,16 +30538,26 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
|
|
|
|
|
|
THREE.Geometry.call( this );
|
|
|
|
|
|
- var ix, iz,
|
|
|
- width_half = width / 2,
|
|
|
- height_half = height / 2,
|
|
|
- gridX = widthSegments || 1,
|
|
|
- gridZ = heightSegments || 1,
|
|
|
- gridX1 = gridX + 1,
|
|
|
- gridZ1 = gridZ + 1,
|
|
|
- segment_width = width / gridX,
|
|
|
- segment_height = height / gridZ,
|
|
|
- normal = new THREE.Vector3( 0, 0, 1 );
|
|
|
+ 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 ++ ) {
|
|
|
|
|
@@ -30545,7 +30610,10 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
|
|
|
|
|
|
THREE.Geometry.call( this );
|
|
|
|
|
|
- radius = radius || 50;
|
|
|
+ this.radius = radius || 50;
|
|
|
+
|
|
|
+ this.widthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );
|
|
|
+ this.heightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );
|
|
|
|
|
|
phiStart = phiStart !== undefined ? phiStart : 0;
|
|
|
phiLength = phiLength !== undefined ? phiLength : Math.PI * 2;
|
|
@@ -30553,25 +30621,22 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
|
|
|
thetaStart = thetaStart !== undefined ? thetaStart : 0;
|
|
|
thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
|
|
|
|
|
|
- var segmentsX = Math.max( 3, Math.floor( widthSegments ) || 8 );
|
|
|
- var segmentsY = Math.max( 2, Math.floor( heightSegments ) || 6 );
|
|
|
-
|
|
|
var x, y, vertices = [], uvs = [];
|
|
|
|
|
|
- for ( y = 0; y <= segmentsY; y ++ ) {
|
|
|
+ for ( y = 0; y <= this.heightSegments; y ++ ) {
|
|
|
|
|
|
var verticesRow = [];
|
|
|
var uvsRow = [];
|
|
|
|
|
|
- for ( x = 0; x <= segmentsX; x ++ ) {
|
|
|
+ for ( x = 0; x <= this.widthSegments; x ++ ) {
|
|
|
|
|
|
- var u = x / segmentsX;
|
|
|
- var v = y / segmentsY;
|
|
|
+ var u = x / this.widthSegments;
|
|
|
+ var v = y / this.heightSegments;
|
|
|
|
|
|
var vertex = new THREE.Vector3();
|
|
|
- vertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
- vertex.y = radius * Math.cos( thetaStart + v * thetaLength );
|
|
|
- vertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
+ vertex.x = - this.radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
+ vertex.y = this.radius * Math.cos( thetaStart + v * thetaLength );
|
|
|
+ vertex.z = this.radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );
|
|
|
|
|
|
this.vertices.push( vertex );
|
|
|
|
|
@@ -30585,9 +30650,9 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
|
|
|
|
|
|
}
|
|
|
|
|
|
- for ( y = 0; y < segmentsY; y ++ ) {
|
|
|
+ for ( y = 0; y < this.heightSegments; y ++ ) {
|
|
|
|
|
|
- for ( x = 0; x < segmentsX; x ++ ) {
|
|
|
+ for ( x = 0; x < this.widthSegments; x ++ ) {
|
|
|
|
|
|
var v1 = vertices[ y ][ x + 1 ];
|
|
|
var v2 = vertices[ y ][ x ];
|
|
@@ -30604,12 +30669,12 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
|
|
|
var uv3 = uvs[ y + 1 ][ x ].clone();
|
|
|
var uv4 = uvs[ y + 1 ][ x + 1 ].clone();
|
|
|
|
|
|
- if ( Math.abs( this.vertices[ v1 ].y ) == radius ) {
|
|
|
+ if ( Math.abs( this.vertices[ v1 ].y ) === this.radius ) {
|
|
|
|
|
|
this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) );
|
|
|
this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] );
|
|
|
|
|
|
- } else if ( Math.abs( this.vertices[ v3 ].y ) == radius ) {
|
|
|
+ } else if ( Math.abs( this.vertices[ v3 ].y ) === this.radius ) {
|
|
|
|
|
|
this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) );
|
|
|
this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] );
|
|
@@ -30628,7 +30693,7 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
|
|
|
this.computeCentroids();
|
|
|
this.computeFaceNormals();
|
|
|
|
|
|
- this.boundingSphere = { radius: radius };
|
|
|
+ this.boundingSphere = { radius: this.radius };
|
|
|
|
|
|
};
|
|
|
|
|
@@ -33996,7 +34061,8 @@ THREE.SpritePlugin = function ( ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- size = sprite.map.image.width / ( sprite.scaleByViewport ? viewportHeight : 1 );
|
|
|
+ //size = sprite.map.image.width / ( sprite.scaleByViewport ? viewportHeight : 1 );
|
|
|
+ size = 1 / ( sprite.scaleByViewport ? viewportHeight : 1 );
|
|
|
|
|
|
scale[ 0 ] = size * invAspect * sprite.scale.x;
|
|
|
scale[ 1 ] = size * sprite.scale.y;
|