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);
57
254
10
+ 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);
57
254
10
+ 5 other calls in file
GitHub: fluuuid/labs
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];
40
163
13
+ 3 other calls in file
GitHub: fluuuid/labs
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;
40
163
13
+ 7 other calls in file
GitHub: kentywang/Agamari
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
15
47
10
+ 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++) {
3
39
2
+ 15 other calls in file
GitHub: AVGP/spaceblaster
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 ); }
5
4
2
+ 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); }
2
7
1
+ 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();
2
3
2
+ 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);
305
0
10
+ 11 other calls in file
GitHub: vidartf/ipyvolume
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) }
236
0
2
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 = [];
31
0
2
+ 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 = [];
13
30
17
GitHub: matrix3d/patrollaya
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 ),
6
21
2
+ 5 other calls in file
GitHub: fagan2888/EuroGridLayer
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 => {
6
0
0
+ 9 other calls in file
GitHub: pevers/K3D-jupyter
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); }
117
0
1
GitHub: zeesaas/Three-MapGL
36 37 38 39 40 41 42 43 44 45
this.loader = new SVGLoader() } // 创建几何体 createGeometry() { return new THREE.Geometry() } // 创建拉伸几何体 createExtrudeGeometry(shape) {
4
7
1
+ 3 other calls in file
GitHub: zya/apophenia
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();
2
28
3
GitHub: hobuinc/usgs-lidar
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({
13
110
0
GitHub: PandeoF1/px_botnet
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 });
7
23
0
three.Vector3 is the most popular function in three (22341 examples)