From 73883858aa9da33e5d30631fa61d88aa61bf7ccc Mon Sep 17 00:00:00 2001 From: Esteban Fuentealba Date: Tue, 10 May 2022 21:07:19 -0400 Subject: [PATCH] Remove deprecated class THREE.Geometry and THREE.Face3 --- src/components/sliders/AnimatedPlane.js | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/sliders/AnimatedPlane.js b/src/components/sliders/AnimatedPlane.js index 2fa8c84..9455014 100644 --- a/src/components/sliders/AnimatedPlane.js +++ b/src/components/sliders/AnimatedPlane.js @@ -7,10 +7,9 @@ import { Object3D, Vector2, Vector3, + BufferGeometry } from 'three' -import { Geometry, Face3 } from 'three/examples/jsm/deprecated/Geometry.js' - export default class AnimatedPlane { constructor(params) { Object.entries(params).forEach(([key, value]) => { @@ -115,34 +114,34 @@ export default class AnimatedPlane { initGeometry() { // square - const geometry = new Geometry() - geometry.vertices.push(new Vector3(0, 0, 0)) - geometry.vertices.push(new Vector3(this.wSize, 0, 0)) - geometry.vertices.push(new Vector3(0, this.wSize, 0)) - geometry.vertices.push(new Vector3(this.wSize, this.wSize, 0)) - geometry.faces.push(new Face3(0, 2, 1)) - geometry.faces.push(new Face3(2, 3, 1)) + const geometry = new BufferGeometry() + const points = [ + new Vector3(0, this.wSize, 0), + new Vector3(this.wSize, 0, 0), + new Vector3(0, 0, 0), - geometry.faceVertexUvs[0].push([ - new Vector2(0, 0), - new Vector2(0, 1), - new Vector2(1, 0), - ]) - geometry.faceVertexUvs[0].push([ - new Vector2(0, 1), - new Vector2(1, 1), - new Vector2(1, 0), - ]) + new Vector3(0, 0, 0), + new Vector3(this.wSize, this.wSize, 0), + new Vector3(0, this.wSize, 0), - // geometry.computeFaceNormals(); - // geometry.computeVertexNormals(); + new Vector3(this.wSize, 0, 0), + new Vector3(this.wSize, this.wSize, 0), + new Vector3(0, 0, 0), + + new Vector3(0, this.wSize, 0), + new Vector3(this.wSize, this.wSize, 0), + new Vector3(this.wSize, 0, 0), + ] + + geometry.setFromPoints(points) + geometry.computeVertexNormals() // center this.dx = this.wSize / 2 this.dy = this.wSize / 2 geometry.translate(-this.dx, -this.dy, 0) - this.bGeometry = geometry.toBufferGeometry() + this.bGeometry = geometry } initAnimAttributes() {