| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /**
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.DynamicGeometry = function () {
- Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
- this.uuid = THREE.Math.generateUUID();
- this.name = '';
- this.type = 'DynamicGeometry';
- this.vertices = [];
- this.colors = [];
- this.normals = [];
- this.colors = [];
- this.uvs = [];
- this.faces = [];
- // this.lineDistances = [];
- this.boundingBox = null;
- this.boundingSphere = null;
- // update flags
- this.verticesNeedUpdate = false;
- this.normalsNeedUpdate = false;
- this.colorsNeedUpdate = false;
- this.uvsNeedUpdate = false;
- };
- THREE.DynamicGeometry.prototype = {
- constructor: THREE.DynamicGeometry,
- computeBoundingBox: THREE.Geometry.prototype.computeBoundingBox,
- computeBoundingSphere: THREE.Geometry.prototype.computeBoundingSphere,
- computeFaceNormals: function () {
- console.warn( 'THREE.DynamicGeometry: computeFaceNormals() is not a method of this type of geometry.' );
- return this;
- },
- computeVertexNormals: function () {
- console.warn( 'THREE.DynamicGeometry: computeVertexNormals () is not a method of this type of geometry.' );
- return this;
- },
- fromGeometry: function ( geometry ) {
- this.vertices = geometry.vertices;
- this.faces = geometry.faces;
- var faces = geometry.faces;
- var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
- for ( var i = 0, il = faces.length; i < il; i ++ ) {
- var face = faces[ i ];
- var indices = [ face.a, face.b, face.c ];
- var vertexNormals = face.vertexNormals;
- var vertexColors = face.vertexColors;
- var vertexUvs = faceVertexUvs[ i ];
- for ( var j = 0, jl = vertexNormals.length; j < jl; j ++ ) {
- this.normals[ indices[ j ] ] = vertexNormals[ j ];
- }
- for ( var j = 0, jl = vertexColors.length; j < jl; j ++ ) {
- this.colors[ indices[ j ] ] = vertexColors[ j ];
- }
- for ( var j = 0, jl = vertexUvs.length; j < jl; j ++ ) {
- this.uvs[ indices[ j ] ] = vertexUvs[ j ];
- }
- }
- if ( geometry.morphTargets ) this.morphTargets = geometry.morphTargets.slice( 0 );
- if ( geometry.morphColors ) this.morphColors = geometry.morphColors.slice( 0 );
- if ( geometry.morphNormals ) this.morphNormals = geometry.morphNormals.slice( 0 );
- if ( geometry.skinIndices ) this.skinIndices = geometry.skinIndices.slice( 0 );
- if ( geometry.skinWeights ) this.skinWeights = geometry.skinWeights.slice( 0 );
- return this;
- },
- dispose: function () {
- this.dispatchEvent( { type: 'dispose' } );
- }
- };
- THREE.EventDispatcher.prototype.apply( THREE.DynamicGeometry.prototype );
|