buffer-geometry

Three.js: Correct way to setIndex / indices for BufferGeometry?

梦想与她 提交于 2020-06-25 21:11:33
问题 I'm trying to set per-face UV indices in a BufferGeometry. I'm starting with a Geometry. Each face of my geometry has a face.materialIndex corresponding to a UV index. I'm trying to convert this to a BufferGeometry, and then map over the face.materialIndex to the BufferGeometry . Here's what I have so far: // Convert geometry > buffergeometry const bufGeo = new BufferGeometry().fromGeometry( geometry ); // Get an array of all the original geometry's indices... const faceIndices = geometry

Transitioning vertices between 3D models with three.js

喜夏-厌秋 提交于 2019-12-24 07:01:13
问题 I am trying to achieve polygon blowing and reassembling effect similar to: http://na.leagueoflegends.com/en/featured/skins/project-2016 https://tkmh.me/ In both of these examples, you can see how they are morphing / transitioning the vertices from one 3d model to another, resulting in a pretty cool effect. I have something similar working, but I can't wrap my head around how they are transitioning the vertices with velocity offsets (please refer to the first link and see how the particles don

tweening particles in buffergeometry

廉价感情. 提交于 2019-12-13 18:40:00
问题 This question piggybacks on the following questions: Three.js - Buffer geometry particles, need to animate random groups of particles in system How to quickly update a large BufferGeometry? I'm starting a new project that will have tens of thousands of particles in the scene at any time. The concept is that there will be clusters of particles that look like galaxies spread throughout the scene. Sometimes I will need animate a galaxy and its thousands of particles. Can I do this while the

Three.js mesh based on BufferGeometry not appearing

落花浮王杯 提交于 2019-12-11 23:35:22
问题 I'm working on a WebGL game using Three.js & I've decided to switch to a THREE.BufferGeometry implementation from my (working) regular THREE.Geometry solution. I'm messing something up, because the mesh does not draw. I've given the relevant parts of my code below. If I switch to a regular geometry, everything works fine. It's a voxel based game and I've pre-created each face of each cube as a regular THREE.Geometry . The positionVertices function takes the vertices and faces from each face

Load positions attribute from a JSON file in Three JS Buffer Geometry Points

吃可爱长大的小学妹 提交于 2019-12-11 16:21:04
问题 I am new in using Three JS Buffer Geometry my task is to draw Buffer Geometry Points, I have position attribute and color attribute value saved in a separate JSON file, how can I use them to populate on Buffer Geometry points? I tried FileReader function to read the JSON but its a asynchronous call. I also tried Loader of Three JS but I couldn't success. My buffer geometry code init() function loop that creates position and set color: for ( var i = 0; i < 81; i += 3 ) { // positions //var x =

Three js buffergeometry for spheres

若如初见. 提交于 2019-12-11 09:18:11
问题 Im trying to make a three js document which shows lots of spherical objects, the quickest way to do this is by using buffergeometry. From this post here I learned that I could convert normal geometry into buffergeometry using: var sphere = new THREE.SphereGeometry( 4, 0.05, 0.025 ); var geometry = THREE.BufferGeometryUtils.fromGeometry( sphere ); But this does not seem to work for me, the rest of the code that creates the object reads: var positions = new Float32Array( x_GAMA.length * 3 );

How to add faces to THREE.BufferGeometry?

北战南征 提交于 2019-12-10 23:43:00
问题 I have created programmatically a simple mesh: var CreateSimpleMesh = new function () { var xy = [], maxX = 7, maxY = 10, river = [[0, 5], [0, 4], [1, 3], [2, 2], [3, 2], [4, 1], [5, 1], [6, 0]], grassGeometry = new THREE.BufferGeometry(), grassVertexPositions = [] this.init = function () { for (i = 0; i < maxX; i++) { for (j = 0; j < maxY; j++) { xy.push([i, j]) } } for (var i = 0; i < xy.length; i++) { grassVertexPositions.push([xy[i][0], xy[i][1], 0]) grassVertexPositions.push([xy[i][0] +

Three.js BufferGeometry vs Geometry for particles

柔情痞子 提交于 2019-12-10 16:49:34
问题 Some particle examples use THREE.BufferGeometry and others use a simply THREE.Geometry . Some lines about pros and cons of every method? 回答1: THREE.BufferGeometry is slowly replacing THREE.Geometry as it is computationally more efficient. The THREE.BufferGeometry API may still be undergoing changes, so you have to be prepared for that. The THREE.Geometry API is easier to use, perhaps, but that may be because it is more familiar. Currently they are both supported. Which one you use is up to

ThreeJS bufferGeometry position attribute not updating when translation applied

两盒软妹~` 提交于 2019-12-10 09:24:41
问题 I used STLLoader to load an stl onto a threeJS scene returning a BufferGeometry. I then used myMesh.position.set( x,y,z ) myMesh.rotation.setFromQuaternion ( quaternion , 'XYZ'); to translate the geometry. This effectively changes the myMesh.position myMesh.quaternion Translation is happening in the scene and all works well. I expected that the myMesh.geometry.attributes.position.array would be different before and after the translation - but it remained identical. I want to extract the new

BufferGeometry offsets and indices

本小妞迷上赌 提交于 2019-12-10 08:11:21
问题 I was just wondering for a while now what exactly "offsets" and "indices / index" are. Offsets are e.g. mentioned in https://github.com/mrdoob/three.js/blob/dev/src/core/BufferGeometry.js and indices were mentioned in IndexedGeometry, however I can't currently find it anymore in the dev tree. Although indices seem rather obvious and although I could dive into the code to figure out some maybe-correct answer for myself I'd love to hear an "official" statement :) Thanks! 回答1: There are two ways