|
@@ -15357,6 +15357,7 @@ function PlaneGeometry( width, height, widthSegments, heightSegments ) {
|
|
};
|
|
};
|
|
|
|
|
|
this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
|
|
this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
|
|
|
|
+ this.mergeVertices();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -20093,7 +20094,8 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
this.forceContextLoss = function () {
|
|
this.forceContextLoss = function () {
|
|
|
|
|
|
- extensions.get( 'WEBGL_lose_context' ).loseContext();
|
|
|
|
|
|
+ var extension = extensions.get( 'WEBGL_lose_context' );
|
|
|
|
+ if ( extension ) extension.loseContext();
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -24268,11 +24270,15 @@ function ParametricBufferGeometry( func, slices, stacks ) {
|
|
|
|
|
|
var indices = [];
|
|
var indices = [];
|
|
var vertices = [];
|
|
var vertices = [];
|
|
|
|
+ var normals = [];
|
|
var uvs = [];
|
|
var uvs = [];
|
|
|
|
|
|
|
|
+ var EPS = 0.00001;
|
|
|
|
+ var pu = new Vector3(), pv = new Vector3(), normal = new Vector3();
|
|
|
|
+
|
|
var i, j;
|
|
var i, j;
|
|
|
|
|
|
- // generate vertices and uvs
|
|
|
|
|
|
+ // generate vertices, normals and uvs
|
|
|
|
|
|
var sliceCount = slices + 1;
|
|
var sliceCount = slices + 1;
|
|
|
|
|
|
@@ -24287,6 +24293,33 @@ function ParametricBufferGeometry( func, slices, stacks ) {
|
|
var p = func( u, v );
|
|
var p = func( u, v );
|
|
vertices.push( p.x, p.y, p.z );
|
|
vertices.push( p.x, p.y, p.z );
|
|
|
|
|
|
|
|
+ // approximate tangent vectors via finite differences
|
|
|
|
+
|
|
|
|
+ if ( u - EPS >= 0 ) {
|
|
|
|
+
|
|
|
|
+ pu.subVectors( p, func( u - EPS, v ) );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ pu.subVectors( func( u + EPS, v ), p );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( v - EPS >= 0 ) {
|
|
|
|
+
|
|
|
|
+ pv.subVectors( p, func( u, v - EPS ) );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ pv.subVectors( func( u, v + EPS ), p );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // cross product of tangent vectors returns surface normal
|
|
|
|
+
|
|
|
|
+ normal.crossVectors( pu, pv ).normalize();
|
|
|
|
+ normals.push( normal.x, normal.y, normal.z );
|
|
|
|
+
|
|
uvs.push( u, v );
|
|
uvs.push( u, v );
|
|
|
|
|
|
}
|
|
}
|
|
@@ -24317,12 +24350,9 @@ function ParametricBufferGeometry( func, slices, stacks ) {
|
|
|
|
|
|
this.setIndex( indices );
|
|
this.setIndex( indices );
|
|
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
|
|
|
|
+ this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
|
|
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
|
|
|
|
|
|
- // generate normals
|
|
|
|
-
|
|
|
|
- this.computeVertexNormals();
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
|
|
ParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
|
|
@@ -25176,7 +25206,6 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
|
|
|
|
|
|
var vertex = new Vector3();
|
|
var vertex = new Vector3();
|
|
var normal = new Vector3();
|
|
var normal = new Vector3();
|
|
- var uv = new Vector2();
|
|
|
|
|
|
|
|
var P1 = new Vector3();
|
|
var P1 = new Vector3();
|
|
var P2 = new Vector3();
|
|
var P2 = new Vector3();
|
|
@@ -25314,6 +25343,7 @@ function TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {
|
|
};
|
|
};
|
|
|
|
|
|
this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
|
|
this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
|
|
|
|
+ this.mergeVertices();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27022,6 +27052,7 @@ function SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLen
|
|
};
|
|
};
|
|
|
|
|
|
this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
|
|
this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
|
|
|
|
+ this.mergeVertices();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27164,6 +27195,7 @@ function RingGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, the
|
|
};
|
|
};
|
|
|
|
|
|
this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
|
|
this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
|
|
|
|
+ this.mergeVertices();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27817,7 +27849,6 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
|
|
// helper variables
|
|
// helper variables
|
|
|
|
|
|
var index = 0;
|
|
var index = 0;
|
|
- var indexOffset = 0;
|
|
|
|
var indexArray = [];
|
|
var indexArray = [];
|
|
var halfHeight = height / 2;
|
|
var halfHeight = height / 2;
|
|
var groupStart = 0;
|
|
var groupStart = 0;
|
|
@@ -28120,6 +28151,7 @@ function CircleGeometry( radius, segments, thetaStart, thetaLength ) {
|
|
};
|
|
};
|
|
|
|
|
|
this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
|
|
this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
|
|
|
|
+ this.mergeVertices();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|