How to use the Geometry function from three

Find comprehensive JavaScript three.Geometry code examples handpicked from public code repositorys.

143
144
145
146
147
148
149
150
151
152
FlowField.prototype.getLines = function (main, subs) {
  var lines = [];

  var mainMaterial = new THREE.LineBasicMaterial({ color: this.parameters.mainColor });

  var mainGeometry = new THREE.Geometry();
  var mainPoints = main.getPoints(this.parameters.renderResolution);
  mainGeometry.vertices = mainPoints;

  var mainLine = new THREE.Line(mainGeometry, mainMaterial);
fork icon57
star icon254
watch icon10

+ 15 other calls in file

48
49
50
51
52
53
54
55
56
57
 */
Grid.prototype.init = function () {
  var width = (this.parameters.stepsX - 1) * this.parameters.stepSize;
  var height = (this.parameters.stepsY - 1) * this.parameters.stepSize;

  var points = new THREE.Geometry();

  for (var x = 0; x < this.parameters.stepsX; x++) {
    for (var y = 0; y < this.parameters.stepsY; y++) {
      var xPos = (x * this.parameters.stepSize) - (width / 2);
fork icon57
star icon254
watch icon10

+ 5 other calls in file

107
108
109
110
111
112
113
114
115
116
  } else {
    this._morphTargetId += 1;
  }
  opts.name = opts.name || 'morphTarget'+this._morphTargetId;
}
var subgeo = new THREE.Geometry();
for (i = 0; i < data.length; i += step) {
  lat = data[i];
  lng = data[i + 1];
  
fork icon40
star icon163
watch icon13

+ 3 other calls in file

6
7
8
9
10
11
12
13
14
this.size              = size;
this.amp               = amp;
this.index             = index;
this.points            = this.generatedPoints(fftData);

this.geometry          = new THREE.Geometry();
this.geometry.vertices = this.points;

this.material          = material;
fork icon40
star icon163
watch icon13

+ 7 other calls in file

229
230
231
232
233
234
235
236
237
var planetBody = new CANNON.Body({ mass: 0, material: groundMaterial, shape: planetShape });
world.add(planetBody);

// create stars
var particleCount = 1800,
  particles = new THREE.Geometry(),
  pMaterial = new THREE.PointsMaterial({
    color: 0xFFFFFF,
    size: 2
fork icon15
star icon47
watch icon10

+ 15 other calls in file

77
78
79
80
81
82
83
84
85
86
  outGeometry.addAttribute('uv', new THREE.BufferAttribute(new Float32Array(mesh.uv), 2));
  outGeometry.addAttribute('basePosition', new THREE.BufferAttribute(new Float32Array(mesh.basePosition), 3));
  const UintArray = mesh.index.length > 65535 ? Uint32Array : Uint16Array;
  outGeometry.setIndex(new THREE.BufferAttribute(new UintArray(mesh.index), 1));
  if (buffer) return outGeometry;
  else return new THREE.Geometry().fromBufferGeometry(outGeometry);
}

function pushVertex (array, attribute, index) {
  for (let i = 0; i < attribute.itemSize; i++) {
fork icon3
star icon39
watch icon2

+ 15 other calls in file

98
99
100
101
102
103
104
105
106
  geometry.computeFaceNormals();
  geometry.computeBoundingSphere();

  object.add( mesh );

  geometry = new THREE.Geometry();
  mesh = new THREE.Mesh( geometry, material );

}
fork icon5
star icon4
watch icon2

+ 27 other calls in file

33
34
35
36
37
38
39
40
41
42
    color: 0xff0000,
    transparent: true,
    opacity: 0.5,
});
for (let path of this.coinPaths) {
    let lineGeometry = new THREE.Geometry();
    lineGeometry.vertices.push(path.v1, path.v2);
    let line = new THREE.Line(lineGeometry, lineMaterial);
    this.tunnel.add(line);
}
fork icon2
star icon7
watch icon1

+ 3 other calls in file

4
5
6
7
8
9
10
11
12
    this.vertices = [v1, v2, v3];
    this.color = color;
};

draw () {
    let geometry = new THREE.Geometry();
    geometry.vertices = this.vertices;
    geometry.faces.push(new THREE.Face3(0, 1, 2));
    geometry.computeBoundingSphere();
fork icon2
star icon3
watch icon2

+ 12 other calls in file

1
2
3
4
5
6
7
8
9
const fontData = require('./helvetiker_regular.typeface.json');

var geometry, textGeometry, textShapes, grid, text, label, xaxis, yaxis, zaxis, material, object, size = 250, step = 25;

geometry = new three.Geometry();
textGeometry = new three.Geometry();
material = new three.LineBasicMaterial({color: 'black'});
object = new three.Object3D();
font = new three.Font(fontData);
fork icon305
star icon0
watch icon10

+ 11 other calls in file

20
21
22
23
24
25
26
27
28
29
}

this.geo_diamond = new THREE.SphereGeometry(1, 2, 2)
this.geo_sphere = new THREE.SphereGeometry(1, 12, 12)
this.geo_box = new THREE.BoxGeometry(1, 1, 1)
this.geo_cat = new THREE.Geometry()
for(var i = 0; i < cat_data.vertices.length; i++) {
    var v = new THREE.Vector3( cat_data.vertices[i][1], cat_data.vertices[i][2], cat_data.vertices[i][0]);
    this.geo_cat.vertices.push(v)
}
fork icon236
star icon0
watch icon2

14
15
16
17
18
19
20
21
22
23
     new THREE.Vector2( -2.5, 0 )
   ] );
var PathLayer1 = new THREE.Path(curve.getPoints(50)); //50 is the numberOfFeathers initially
var splineGeom = PathLayer1.createPointsGeometry(50);
var featherMesh = new THREE.Mesh();
var featherGeo = new THREE.Geometry();
var oldNum = 50;
var featherOriginalX = [];
var featherOriginalY = [];
var featherOriginalZ = [];
fork icon31
star icon0
watch icon2

+ 3 other calls in file

121
122
123
124
125
126
127
128
129
130
var postProcessWorld = function (json) {
    var loader = new THREE.ObjectLoader();

    var obj = loader.parse(json);

    var mergedMeshesGeometry = new THREE.Geometry();
    var mergedMaterialsCollection = [];

    var entitiesCollection = new THREE.Object3D(),
        ents = [];
fork icon13
star icon30
watch icon17

34
35
36
37
38
39
40
41
42
43
});

test('pathing near close, adjacent nodes', (t) => {
  const pathfinding = new Pathfinding();

  const geometry = new THREE.Geometry();
  // Make a geometry that looks something like ./diagrams/close-adjacent-nodes.png
  geometry.vertices.push(
    new THREE.Vector3(  0,  0,  0  ),
    new THREE.Vector3(  1,  0,  0  ),
fork icon6
star icon21
watch icon2

+ 5 other calls in file

35
36
37
38
39
40
41
42
43
44
let pointsMaterial;

var cells = [];
//TODO use BufferGeometry() rather than Geometry()?
//see https://threejsfundamentals.org/threejs/lessons/threejs-custom-buffergeometry.html
const pointsGeometry = new THREE.Geometry();
const colors = [];

showLoading();
getCSV("../assets/csv/pop_2km.csv", data => {
fork icon6
star icon0
watch icon0

+ 9 other calls in file

51
52
53
54
55
56
57
58
59
60
        wireframe: config.wireframe
    });
}

if (config.flat_shading === false) {
    var geo = new THREE.Geometry().fromBufferGeometry(geometry);
    geo.mergeVertices();
    geo.computeVertexNormals();
    geometry.fromGeometry(geo);
}
fork icon117
star icon0
watch icon1

36
37
38
39
40
41
42
43
44
45
  this.loader = new SVGLoader()
}

// 创建几何体
createGeometry() {
  return new THREE.Geometry()
}

// 创建拉伸几何体
createExtrudeGeometry(shape) {
fork icon4
star icon7
watch icon1

+ 3 other calls in file

44
45
46
47
48
49
50
51
52

module.exports.load = function (cb) {
  var urlPath = location.pathname;

  loader.load(urlPath + 'assets/models/rose.obj', function (object) {
    geometry = new THREE.Geometry().fromBufferGeometry(object.children[0].geometry);
    geometry.center();
    geometry.computeFaceNormals();
    geometry.computeVertexNormals();
fork icon2
star icon28
watch icon3

1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
	n = points[i+1];

if (p.id !== n.id)
	continue; // don't connect if they belong to different segments

var g = new THREE.Geometry();
g.vertices.push(p);
g.vertices.push(n);

var m = new THREE.LineBasicMaterial({
fork icon13
star icon110
watch icon0

61
62
63
64
65
66
67
68
69
70
this.smokeVisible = opts.showSmoke;
this.labelVisible = opts.showLabel;

/* the line */

this.lineGeometry = new THREE.Geometry();
lineMaterial = new THREE.LineBasicMaterial({
    color: opts.lineColor,
    linewidth: opts.lineWidth
});
fork icon7
star icon23
watch icon0

Other functions in three

Sorted by popularity

function icon

three.Vector3 is the most popular function in three (22341 examples)