Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets

@param {THREE.BufferGeometry} geometry
@param {Array<GLTF.Target>} targets
@param {GLTFParser} parser
@return {Promise<THREE.BufferGeometry>}
506831
function addMorphTargets( geometry, targets, parser ) {

  let hasMorphPosition = false;
  let hasMorphNormal = false;

  for ( var i = 0, il = targets.length; i < il; i++ ) {

    var target = targets[ i ];

    if ( target.POSITION !== undefined ) hasMorphPosition = true;
    if ( target.NORMAL !== undefined ) hasMorphNormal = true;

    if ( hasMorphPosition && hasMorphNormal ) break;

  }

  if ( !hasMorphPosition && !hasMorphNormal ) return Promise.resolve( geometry );

  const pendingPositionAccessors = [];
  const pendingNormalAccessors = [];

  for ( var i = 0, il = targets.length; i < il; i++ ) {

    var target = targets[ i ];

    if ( hasMorphPosition ) {

      // TODO: Error-prone use of a callback inside a loop.
      var accessor = target.POSITION !== undefined
        ? parser.getDependency( 'accessor', target.POSITION )
          .then( ( accessor ) => {
            // Cloning not to pollute original accessor below
            return cloneBufferAttribute( accessor );
          } )
        : geometry.attributes.position;

      pendingPositionAccessors.push( accessor );

    }

    if ( hasMorphNormal ) {

      // TODO: Error-prone use of a callback inside a loop.
      var accessor = target.NORMAL !== undefined
        ? parser.getDependency( 'accessor', target.NORMAL )
          .then( ( accessor ) => {
            return cloneBufferAttribute( accessor );
          } )
        : geometry.attributes.normal;

      pendingNormalAccessors.push( accessor );

    }

  }

  return Promise.all( [
    Promise.all( pendingPositionAccessors ),
    Promise.all( pendingNormalAccessors ),
  ] ).then( ( accessors ) => {

    const morphPositions = accessors[ 0 ];
    const morphNormals = accessors[ 1 ];

    for ( let i = 0, il = targets.length; i < il; i++ ) {

      const target = targets[ i ];
      const attributeName = 'morphTarget' + i;

      if ( hasMorphPosition ) {

        // Three.js morph position is absolute value. The formula is
        //   basePosition
        //     + weight0 * ( morphPosition0 - basePosition )
        //     + weight1 * ( morphPosition1 - basePosition )
        //     ...
        // while the glTF one is relative
        //   basePosition
        //     + weight0 * glTFmorphPosition0
        //     + weight1 * glTFmorphPosition1
        //     ...
        // then we need to convert from relative to absolute here.

        if ( target.POSITION !== undefined ) {

          const positionAttribute = morphPositions[ i ];
          positionAttribute.name = attributeName;

          const position = geometry.attributes.position;

          for ( var j = 0, jl = positionAttribute.count; j < jl; j++ ) {

            positionAttribute.setXYZ(
              j,
              positionAttribute.getX( j ) + position.getX( j ),
              positionAttribute.getY( j ) + position.getY( j ),
              positionAttribute.getZ( j ) + position.getZ( j ),
            );

          }

        }

      }

      if ( hasMorphNormal ) {

        // see target.POSITION's comment

        if ( target.NORMAL !== undefined ) {

          const normalAttribute = morphNormals[ i ];
          normalAttribute.name = attributeName;

          const normal = geometry.attributes.normal;

          for ( var j = 0, jl = normalAttribute.count; j < jl; j++ ) {

            normalAttribute.setXYZ(
              j,
              normalAttribute.getX( j ) + normal.getX( j ),
              normalAttribute.getY( j ) + normal.getY( j ),
              normalAttribute.getZ( j ) + normal.getZ( j ),
            );

          }

        }

      }

    }

    if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
    if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;

    return geometry;

  } );

}
455071
function(target) {
        if (!target.geometry) {
            return false;
        } else {
            return (
                target.state !== OpenLayers.State.DELETE
            ) && (
                typeof target.geometry.split === "function"
            ) && (
                this.feature !== target
            ) && (
                !this.targetFilter ||
                this.targetFilter.evaluate(target.attributes)
            );
        }
    }
129467
public static Geometry drapeMultiPolygon(MultiPolygon polygons, Geometry triangles, STRtree sTRtree) {
        GeometryFactory factory = polygons.getFactory();         
        //Split the triangles in lines to perform all intersections
        Geometry triangleLines = LinearComponentExtracter.getGeometry(triangles, true);
        int nbPolygons = polygons.getNumGeometries();
        Polygon[] polygonsDiff = new Polygon[nbPolygons];
        for (int i = 0; i < nbPolygons; i++) {
            polygonsDiff[i] = processPolygon((Polygon) polygons.getGeometryN(i), triangleLines, factory);
        }
        Geometry diffExt = factory.createMultiPolygon(polygonsDiff);
        CoordinateSequenceFilter drapeFilter = new DrapeFilter(sTRtree);
        diffExt.apply(drapeFilter);
        return diffExt;
    }
395832
function ( relationships, deformerNodes ) {

			var rawMorphTargets = [];

			for ( var i = 0; i < relationships.children.length; i ++ ) {

				if ( i === 8 ) {

					console.warn( 'FBXLoader: maximum of 8 morph targets supported. Ignoring additional targets.' );

					break;

				}

				var child = relationships.children[ i ];

				var morphTargetNode = deformerNodes[ child.ID ];

				var rawMorphTarget = {

					name: morphTargetNode.attrName,
					initialWeight: morphTargetNode.DeformPercent,
					id: morphTargetNode.id,
					fullWeights: morphTargetNode.FullWeights.a

				};

				if ( morphTargetNode.attrType !== 'BlendShapeChannel' ) return;

				var targetRelationships = connections.get( parseInt( child.ID ) );

				targetRelationships.children.forEach( function ( child ) {

					if ( child.relationship === undefined ) rawMorphTarget.geoID = child.ID;

				} );

				rawMorphTargets.push( rawMorphTarget );

			}

			return rawMorphTargets;

		}
13263
function writePolygonGeometry_(geometry) {
  if (geometry instanceof olGeomPolygon) {
    const flatCoordinates = geometry.getFlatCoordinates();
    const stride = geometry.getStride();
    const ends = geometry.getEnds();
    const offset = 0;
    const textArray = ['a('];
    encodeRings_.call(this,
      flatCoordinates, stride, offset, ends, textArray);
    textArray.push(')');
    return textArray.join('');
  }
  return null;
}
344223
function createParticleBuffers ( geometry ) {

		geometry.__webglVertexBuffer = _gl.createBuffer();
		geometry.__webglColorBuffer = _gl.createBuffer();

		_this.info.geometries ++;

	}
522895
function morphyPromise( str, pos ) {
	/* jshint: -WO40 */
	var substitutions;
	var query;
	var i;
	if ( !pos ) {
		var resArray = [];
		for ( i = 0; i < POS_TAGS.length; i++ ){
			resArray.push( morphyPromise( str, POS_TAGS[i] ) );
		}
		return Promise.all( resArray ).then( function onDone( data ) {
			var reducedArray = [];
			var j;
			for ( j = 0; j < data.length; j++ ) {
				reducedArray.push( data[ j ] );
			}
			return _.flatten( reducedArray );
		});
	}

	substitutions = getSubstitutions( pos );

	if ( !this.DICTIONARY ) {
		query = 'SELECT DISTINCT ws.lemma AS lemma, syn.pos AS pos FROM words AS ws LEFT JOIN senses AS sen ON ws.wordid = sen.wordid LEFT JOIN ';
		query += 'synsets AS syn ON sen.synsetid = syn.synsetid';
		this.DICTIONARY = this.db.allAsync( query ).map( function mapper( elem ) {
			var obj = {
				lemma: elem.lemma,
				pos: elem.pos
			};
			return obj;
		});
	}

	if ( !this.EXCEPTIONS ) {
		query = 'SELECT lemma, morph, pos FROM morphology';
		this.EXCEPTIONS = db.allAsync( query );
	}

	var wordsPromise = Promise.join( this.DICTIONARY, this.EXCEPTIONS, function( dictionary, exceptions ) {
		var foundExceptions = [];
		var exceptionMorphs = exceptions.map( function( elem ) {
			return elem.morph;
		});
		var baseWord;
		var suffix;
		var index = exceptionMorphs.indexOf( str );

		while ( index !== -1 ) {
			if ( exceptions[index].pos === pos ) {
				baseWord = new this.Word( exceptions[index].lemma );
				baseWord.part_of_speech = pos;
				foundExceptions.push( baseWord );
			}
			index = exceptionMorphs.indexOf( str, index + 1 );
		}

		if ( foundExceptions.length > 0 ) {
			return foundExceptions;
		} else {
			if ( pos === 'n' && str.endsWith( 'ful' ) ) {
				suffix = 'ful';
				str = str.slice( 0, str.length - suffix.length );
			} else {
				suffix = '';
			}
			return rulesOfDetachment( str, substitutions );
		}
	});

	return wordsPromise;
}
1208046
private static Geometry[] convertGeometries(org.geomajas.gwt.client.spatial.geometry.Geometry geometry) {
		if (geometry.isEmpty()) {
			return null;
		}
		Geometry[] geometries = new Geometry[geometry.getNumGeometries()];
		for (int i = 0; i < geometries.length; i++) {
			geometries[i] = toDto(geometry.getGeometryN(i));
		}
		return geometries;
	}
813081
public void writeGeometries( Geometry[] geometries ) throws IOException {
        File file = new File(path);
        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "rw");

            int major = JTSVersion.MAJOR;
            int minor = JTSVersion.MINOR;

            raf.writeChars("jts");
            raf.writeInt(major);
            raf.writeInt(minor);

            long geometriesStart = INDEX_ADDRESS_POSITION + INDEX_ADDRESS_SIZE + INDEX_LENGTH_SIZE;
            raf.seek(geometriesStart);
            System.out.println("geometriesStart: " + geometriesStart);

            long fileIndex = geometriesStart;
            STRtree tree = new STRtree(geometries.length);
            for( int i = 0; i < geometries.length; i++ ) {
                Geometry geometry = geometries[i];

                if (geometry.isEmpty()) {
                    continue;
                }
                Envelope envelope = geometry.getEnvelopeInternal();

                byte[] geomBytes = serialize(geometry);
                raf.write(geomBytes);

                /*
                 * the tree contains the envelope of a geometry
                 * and the array with the exact position in the file where the 
                 * geometry bytes start + the length. 
                 */
                tree.insert(envelope, new long[]{fileIndex, geomBytes.length});

                fileIndex = fileIndex + geomBytes.length;
                System.out.println("geom: " + i + " finished at: " + fileIndex);
            }

            raf.seek(INDEX_ADDRESS_POSITION);
            raf.writeLong(fileIndex);

            System.out.println("INDEX_ADDRESS_POSITION: " + fileIndex);

            /*
             * serialize index
             */
            byte[] treeBytes = serialize(tree);

            long treeSize = treeBytes.length;
            raf.seek(fileIndex);
            raf.write(treeBytes, 0, (int) treeSize);

            System.out.println("treeSize: " + treeSize);

            raf.seek(INDEX_ADDRESS_POSITION + INDEX_ADDRESS_SIZE);
            raf.writeLong(treeSize);

            long length = raf.length();
            System.out.println(length);

        } finally {
            System.out.println("close");
            if (raf != null)
                raf.close();
        }
    }
210845
function setupDepthRenderbuffer( renderTarget ) {

		var renderTargetProperties = properties.get( renderTarget );

		var isCube = ( renderTarget instanceof THREE.WebGLRenderTargetCube );

		if ( renderTarget.depthTexture ) {

			if ( isCube ) throw new Error('target.depthTexture not supported in Cube render targets');

			setupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );

		} else {

			if ( isCube ) {

				renderTargetProperties.__webglDepthbuffer = [];

				for ( var i = 0; i < 6; i ++ ) {

					_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );
					renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();
					setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget );

				}

			} else {

				_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
				renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
				setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget );

			}

		}

		_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );

	}
1144157
function toBufferGeometry (geometry, doBuffer) {
  var bufferGeometry;
  if (!doBuffer) { return geometry; }

  bufferGeometry = new THREE.BufferGeometry().fromGeometry(geometry);
  bufferGeometry.metadata = {type: geometry.type, parameters: geometry.parameters || {}};
  geometry.dispose();  // Dispose no longer needed non-buffer geometry.
  return bufferGeometry;
}
1324279
function ( geometry ) {

		geometry.computeBoundingBox();

		var bb = geometry.boundingBox;

		var offset = new THREE.Vector3();

		offset.addVectors( bb.min, bb.max );
		offset.multiplyScalar( -0.5 );

		geometry.applyMatrix( new THREE.Matrix4().makeTranslation( offset.x, offset.y, offset.z ) );
		geometry.computeBoundingBox();

		return offset;

	}
173113
function morph (value, input) {
  const result = input || readable()
  const cb = map[type(value)] || end
  cb(result, value)
  return new Proxy(result, {
    get(target, key, receiver) {
      if (key !== 'pipe') return target[key]
      return function (dest) {
        pump(result, dest)
        return dest
      }
    }
  })
}
287371
private function readGeometryCollectionText(WKTParser $parser, CoordinateSystem $cs) : GeometryCollection
    {
        $parser->matchOpener();
        $geometries = [];

        do {
            $geometries[] = $this->readGeometry($parser, $cs->SRID());
            $nextToken = $parser->getNextCloserOrComma();
        } while ($nextToken === ',');

        return new GeometryCollection($cs, ...$geometries);
    }
179139
function parseTMXShapes() {
         var i = 0;
         var shapes = []; // add an ellipse shape

         if (this.isEllipse === true) {
           // ellipse coordinates are the center position, so set default to the corresonding radius
           shapes.push(new me.Ellipse(this.width / 2, this.height / 2, this.width, this.height).rotate(this.rotation));
         } // add a polygon
         else if (this.isPolygon === true) {
             shapes.push(new me.Polygon(0, 0, this.points).rotate(this.rotation));
           } // add a polyline
           else if (this.isPolyLine === true) {
               var p = this.points;
               var p1, p2;
               var segments = p.length - 1;

               for (i = 0; i < segments; i++) {
                 // clone the value before, as [i + 1]
                 // is reused later by the next segment
                 p1 = new me.Vector2d(p[i].x, p[i].y);
                 p2 = new me.Vector2d(p[i + 1].x, p[i + 1].y);

                 if (this.rotation !== 0) {
                   p1 = p1.rotate(this.rotation);
                   p2 = p2.rotate(this.rotation);
                 }

                 shapes.push(new me.Line(0, 0, [p1, p2]));
               }
             } // it's a rectangle, returns a polygon object anyway
             else {
                 shapes.push(new me.Polygon(0, 0, [new me.Vector2d(), new me.Vector2d(this.width, 0), new me.Vector2d(this.width, this.height), new me.Vector2d(0, this.height)]).rotate(this.rotation));
               } // Apply isometric projection


         if (this.orientation === "isometric") {
           for (i = 0; i < shapes.length; i++) {
             shapes[i].toIso();
           }
         }

         return shapes;
       }
358674
function handleMesh (mesh, gltf, ctx, renderer) {
  return mesh.primitives.map((primitive) => {
    const geometryCmp = renderer.geometry(
      handlePrimitive(primitive, gltf, ctx, renderer)
    )
    const materialCmp =
      primitive.material !== undefined
        ? renderer.material(
          handleMaterial(
            gltf.materials[primitive.material],
            gltf,
            ctx,
            renderer
          )
        )
        : renderer.material()

    const components = [
      geometryCmp,
      materialCmp
    ]

    // Create morph
    if (primitive.targets) {
      let sources = {}
      const targets = primitive.targets.reduce((targets, target) => {
        const targetKeys = Object.keys(target)

        targetKeys.forEach(targetKey => {
          const targetName = PEX_ATTRIBUTE_NAME_MAP[targetKey] || targetKey
          targets[targetName] = targets[targetName] || []

          const accessor = getAccessor(gltf.accessors[target[targetKey]], gltf.bufferViews)

          targets[targetName].push(accessor._data)

          if (!sources[targetName]) {
            const sourceAccessor = getAccessor(gltf.accessors[primitive.attributes[targetKey]], gltf.bufferViews)
            sources[targetName] = sourceAccessor._data
          }
        })
        return targets
      }, {})

      const morphCmp = renderer.morph({
        sources,
        targets,
        weights: mesh.weights
      })
      components.push(morphCmp)
    }

    return components
  })
}
425334
function ( shapes, curveSegments ) {

	BufferGeometry.call( this );

	this.type = '';

	this.parameters = {
		shapes: shapes,
		curveSegments: curveSegments
	};

	curveSegments = curveSegments || 12;

	// buffers

	var indices = [];
	var vertices = [];
	var normals = [];
	var uvs = [];

	// helper variables

	var groupStart = 0;
	var groupCount = 0;

	// allow single and array values for "shapes" parameter

	if ( Array.isArray( shapes ) === false ) {

		addShape( shapes );

	} else {

		for ( var i = 0; i < shapes.length; i ++ ) {

			addShape( shapes[ i ] );

			this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support

			groupStart += groupCount;
			groupCount = 0;

		}

	}

	// build geometry

	this.setIndex( indices );
	this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
	this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
	this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );


	// helper functions

	function addShape( shape ) {

		var i, l, shapeHole;

		var indexOffset = vertices.length / 3;
		var points = shape.extractPoints( curveSegments );

		var shapeVertices = points.shape;
		var shapeHoles = points.holes;

		// check direction of vertices

		if ( ShapeUtils.isClockWise( shapeVertices ) === false ) {

			shapeVertices = shapeVertices.reverse();

		}

		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {

			shapeHole = shapeHoles[ i ];

			if ( ShapeUtils.isClockWise( shapeHole ) === true ) {

				shapeHoles[ i ] = shapeHole.reverse();

			}

		}

		var faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );

		// join vertices of inner and outer paths to a single array

		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {

			shapeHole = shapeHoles[ i ];
			shapeVertices = shapeVertices.concat( shapeHole );

		}

		// vertices, normals, uvs

		for ( i = 0, l = shapeVertices.length; i < l; i ++ ) {

			var vertex = shapeVertices[ i ];

			vertices.push( vertex.x, vertex.y, 0 );
			normals.push( 0, 0, 1 );
			uvs.push( vertex.x, vertex.y ); // world uvs

		}

		// incides

		for ( i = 0, l = faces.length; i < l; i ++ ) {

			var face = faces[ i ];

			var a = face[ 0 ] + indexOffset;
			var b = face[ 1 ] + indexOffset;
			var c = face[ 2 ] + indexOffset;

			indices.push( a, b, c );
			groupCount += 3;

		}

	}

}