Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three.js removed Geometry in favor of BufferGeometry #68

Open
Megidd opened this issue Dec 21, 2022 · 1 comment
Open

Three.js removed Geometry in favor of BufferGeometry #68

Megidd opened this issue Dec 21, 2022 · 1 comment

Comments

@Megidd
Copy link
Contributor

Megidd commented Dec 21, 2022

Problem

According to this: https://stackoverflow.com/a/68000360/3405291

Three.js r125 removed support for Geometry. We have to now use custom BufferGeometry now onwards. https://threejsfundamentals.org/threejs/lessons/threejs-custom-buffergeometry.html

Solution 1: older version

PR #67 is a workaround by using an older version of ThreeJS. But that might not be possible for all the projects.

Solution 2: Refactor

A stable solution is to change the source code. There is a PR doing the same refactor for another library, maybe helpful: tengbao/vanta#118

@Vikms95
Copy link

Vikms95 commented Dec 22, 2022

Currently looking to migrate an app using three.js r94 to r140. I'm facing an issue on the ThreeBSP constructor where the faces, faceVertexUvs are being used. vertices is also being used, but I have an idea on how to handle it. These properties are now gone on BufferGeometry, any ocurrence on how to update this part of the code? Here is the problematic snippet:

for ( i = 0, _length_i = geometry.faces.length; i < _length_i; i++ ) {
      face = geometry.faces[ i ];
      faceVertexUvs = geometry.faceVertexUvs[ 0 ][ i ];
      polygon = new Polygon();

      if ( face instanceof THREE.Face3 ) {
        vertex = geometry.vertices[ face.a ];
        uvs = faceVertexUvs ? new THREE.Vector2( faceVertexUvs[ 0 ].x, faceVertexUvs[ 0 ].y ) : null;
        vertex = new Vertex( vertex.x, vertex.y, vertex.z, face.vertexNormals[ 0 ], uvs );
        vertex.applyMatrix4( this.matrix );
        polygon.vertices.push( vertex );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants