How to use the TriangleStripDrawMode function from three
Find comprehensive JavaScript three.TriangleStripDrawMode code examples handpicked from public code repositorys.
three.TriangleStripDrawMode is a constant that represents a triangle strip draw mode used for rendering in Three.js.
63 64 65 66 67 68 69 70 71 72
/** * Sets desired mode for generated geometry indices. * Can be either: * THREE.TrianglesDrawMode * THREE.TriangleStripDrawMode */ setDrawMode: function(drawMode) { this.drawMode = drawMode; return this;
4
26
0
+ 5 other calls in file
2399 2400 2401 2402 2403 2404 2405 2406 2407 2408
// it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs mesh.normalizeSkinWeights(); } if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) { mesh.drawMode = THREE.TriangleStripDrawMode; } else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) { mesh.drawMode = THREE.TriangleFanDrawMode; } } else if (primitive.mode === WEBGL_CONSTANTS.LINES) {
3
7
8
+ 14 other calls in file
How does three.TriangleStripDrawMode work?
In Three.js, TriangleStripDrawMode is a value representing a draw mode for a BufferGeometry, where vertices are interpreted as a series of connected triangles in a strip formation, where the first three vertices create the first triangle, and every subsequent vertex adds another triangle by forming a new triangle with the two most recent vertices.
69 70 71 72 73 74 75 76 77
this.scene.add(this.line); geometry = new THREE.BufferGeometry(); geometry.addAttribute('position', new THREE.BufferAttribute(this.array, 3)); this.mesh = new THREE.Mesh(geometry, this.facesMaterial); this.mesh.drawMode = THREE.TriangleStripDrawMode; scene.add(this.mesh); this.currentPosition = new THREE.Vector3(0, 0, 0);
2
6
6
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
const geometry = new THREE.BufferGeometry(); const vertices = new Float32Array([ 0, 0, 0, // first vertex 1, 0, 0, // second vertex 0, 1, 0, // third vertex 1, 1, 0, // fourth vertex 2, 1, 0, // fifth vertex ]); geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3)); geometry.setDrawRange(0, 3); // draws first three vertices as triangle geometry.setIndex(new THREE.BufferAttribute(new Uint16Array([2, 1, 3, 4]), 1)); // using indices to specify triangles forming a strip const material = new THREE.MeshBasicMaterial({ color: 0xff0000 }); const mesh = new THREE.Mesh(geometry, material); mesh.drawMode = THREE.TriangleStripDrawMode; // sets the draw mode to TriangleStrip scene.add(mesh);
three.Vector3 is the most popular function in three (22341 examples)