Browse Source

Add both buffergeometry and geometry + change textgeometry

gero3 8 years ago
parent
commit
6fee14a363

+ 1 - 1
examples/webgl_geometry_text.html

@@ -363,7 +363,7 @@
 
 
 			function createText() {
 			function createText() {
 
 
-				textGeo = new THREE.TextGeometry( text, {
+				textGeo = new THREE.TextBufferGeometry( text, {
 
 
 					font: font,
 					font: font,
 
 

+ 32 - 7
src/geometries/ExtrudeGeometry.js

@@ -27,9 +27,33 @@ import { ShapeUtils } from '../extras/ShapeUtils';
  *
  *
  * }
  * }
  **/
  **/
+ 
+ import { Geometry } from '../core/Geometry';
 
 
 function ExtrudeGeometry( shapes, options ) {
 function ExtrudeGeometry( shapes, options ) {
 
 
+	Geometry.call( this );
+
+	this.type = 'ExtrudeGeometry';
+
+	this.parameters = {
+		shapes: shapes,
+		options: options
+	};
+
+	this.fromBufferGeometry( new ExtrudeBufferGeometry( shapes, options ) );
+	this.mergeVertices();
+
+}
+
+
+ExtrudeGeometry.prototype = Object.create( Geometry.prototype );
+ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
+
+ 
+
+function ExtrudeBufferGeometry( shapes, options ) {
+
 	if ( typeof(shapes) === "undefined") {
 	if ( typeof(shapes) === "undefined") {
 
 
 		shapes = [];
 		shapes = [];
@@ -39,7 +63,7 @@ function ExtrudeGeometry( shapes, options ) {
 
 
 	BufferGeometry.call(this);
 	BufferGeometry.call(this);
 
 
-	this.type = 'ExtrudeGeometry';
+	this.type = 'ExtrudeBufferGeometry';
 
 
 	shapes = Array.isArray(shapes) ? shapes : [shapes];
 	shapes = Array.isArray(shapes) ? shapes : [shapes];
 
 
@@ -57,10 +81,10 @@ function ExtrudeGeometry( shapes, options ) {
 
 
 }
 }
 
 
-ExtrudeGeometry.prototype = Object.create(BufferGeometry.prototype);
-ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
+ExtrudeBufferGeometry.prototype = Object.create(BufferGeometry.prototype);
+ExtrudeBufferGeometry.prototype.constructor = ExtrudeBufferGeometry;
 
 
-ExtrudeGeometry.prototype.getArrays = function() {
+ExtrudeBufferGeometry.prototype.getArrays = function() {
 
 
 	var positionAttribute = this.getAttribute("position");
 	var positionAttribute = this.getAttribute("position");
 	var verticesArray = positionAttribute ? Array.prototype.slice.call(positionAttribute.array) : [];
 	var verticesArray = positionAttribute ? Array.prototype.slice.call(positionAttribute.array) : [];
@@ -79,7 +103,7 @@ ExtrudeGeometry.prototype.getArrays = function() {
 
 
 };
 };
 
 
-ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
+ExtrudeBufferGeometry.prototype.addShapeList = function(shapes, options) {
 
 
 	var sl = shapes.length;
 	var sl = shapes.length;
 	options.arrays = this.getArrays();
 	options.arrays = this.getArrays();
@@ -97,7 +121,7 @@ ExtrudeGeometry.prototype.addShapeList = function(shapes, options) {
 
 
 };
 };
 
 
-ExtrudeGeometry.prototype.addShape = function(shape, options) {
+ExtrudeBufferGeometry.prototype.addShape = function(shape, options) {
 
 
 	var arrays = options.arrays ? options.arrays : this.getArrays();
 	var arrays = options.arrays ? options.arrays : this.getArrays();
 	var verticesArray = arrays.position;
 	var verticesArray = arrays.position;
@@ -792,5 +816,6 @@ ExtrudeGeometry.WorldUVGenerator = {
 
 
 
 
 export {
 export {
-	ExtrudeGeometry
+	ExtrudeGeometry,
+	ExtrudeBufferGeometry
 };
 };

+ 2 - 2
src/geometries/Geometries.js

@@ -8,13 +8,13 @@ export { PolyhedronGeometry, PolyhedronBufferGeometry } from './PolyhedronGeomet
 export { TubeGeometry, TubeBufferGeometry } from './TubeGeometry.js';
 export { TubeGeometry, TubeBufferGeometry } from './TubeGeometry.js';
 export { TorusKnotGeometry, TorusKnotBufferGeometry } from './TorusKnotGeometry.js';
 export { TorusKnotGeometry, TorusKnotBufferGeometry } from './TorusKnotGeometry.js';
 export { TorusGeometry, TorusBufferGeometry } from './TorusGeometry.js';
 export { TorusGeometry, TorusBufferGeometry } from './TorusGeometry.js';
-export { TextGeometry } from './TextGeometry.js';
+export { TextGeometry, TextBufferGeometry } from './TextGeometry.js';
 export { SphereGeometry, SphereBufferGeometry } from './SphereGeometry.js';
 export { SphereGeometry, SphereBufferGeometry } from './SphereGeometry.js';
 export { RingGeometry, RingBufferGeometry } from './RingGeometry.js';
 export { RingGeometry, RingBufferGeometry } from './RingGeometry.js';
 export { PlaneGeometry, PlaneBufferGeometry } from './PlaneGeometry.js';
 export { PlaneGeometry, PlaneBufferGeometry } from './PlaneGeometry.js';
 export { LatheGeometry, LatheBufferGeometry } from './LatheGeometry.js';
 export { LatheGeometry, LatheBufferGeometry } from './LatheGeometry.js';
 export { ShapeGeometry, ShapeBufferGeometry } from './ShapeGeometry.js';
 export { ShapeGeometry, ShapeBufferGeometry } from './ShapeGeometry.js';
-export { ExtrudeGeometry } from './ExtrudeGeometry.js';
+export { ExtrudeGeometry, ExtrudeBufferGeometry } from './ExtrudeGeometry.js';
 export { EdgesGeometry } from './EdgesGeometry.js';
 export { EdgesGeometry } from './EdgesGeometry.js';
 export { ConeGeometry, ConeBufferGeometry } from './ConeGeometry.js';
 export { ConeGeometry, ConeBufferGeometry } from './ConeGeometry.js';
 export { CylinderGeometry, CylinderBufferGeometry } from './CylinderGeometry.js';
 export { CylinderGeometry, CylinderBufferGeometry } from './CylinderGeometry.js';

+ 30 - 6
src/geometries/TextGeometry.js

@@ -1,4 +1,4 @@
-import { ExtrudeGeometry } from './ExtrudeGeometry';
+import { ExtrudeBufferGeometry } from './ExtrudeGeometry';
 import { Geometry } from '../core/Geometry';
 import { Geometry } from '../core/Geometry';
 
 
 /**
 /**
@@ -19,8 +19,29 @@ import { Geometry } from '../core/Geometry';
  *  bevelSize: <float> // how far from text outline is bevel
  *  bevelSize: <float> // how far from text outline is bevel
  * }
  * }
  */
  */
+ 
 
 
-function TextGeometry( text, parameters ) {
+function TextGeometry(  text, parameters ) {
+
+	Geometry.call( this );
+
+	this.type = 'TextGeometry';
+
+	this.parameters = {
+		text: text,
+		parameters: parameters
+	};
+
+	this.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );
+	this.mergeVertices();
+
+}
+
+TextGeometry.prototype = Object.create( Geometry.prototype );
+TextGeometry.prototype.constructor = TextGeometry;
+
+
+function TextBufferGeometry( text, parameters ) {
 
 
 	parameters = parameters || {};
 	parameters = parameters || {};
 
 
@@ -45,14 +66,17 @@ function TextGeometry( text, parameters ) {
 	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
 	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
 	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
 	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
 
 
-	ExtrudeGeometry.call( this, shapes, parameters );
+	ExtrudeBufferGeometry.call( this, shapes, parameters );
 
 
 	this.type = 'TextGeometry';
 	this.type = 'TextGeometry';
 
 
 }
 }
 
 
-TextGeometry.prototype = Object.create( ExtrudeGeometry.prototype );
-TextGeometry.prototype.constructor = TextGeometry;
+TextBufferGeometry.prototype = Object.create( ExtrudeBufferGeometry.prototype );
+TextBufferGeometry.prototype.constructor = TextBufferGeometry;
 
 
 
 
-export { TextGeometry };
+export { 
+	TextGeometry,
+	TextBufferGeometry 
+};