refactor: update geometry creation to use BufferGeometry for improved performance
This commit is contained in:
+12
-2
@@ -14,8 +14,18 @@ const scene = new THREE.Scene();
|
|||||||
/**
|
/**
|
||||||
* Object
|
* Object
|
||||||
*/
|
*/
|
||||||
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
// const geometry = new THREE.BoxGeometry(1, 1, 1);
|
||||||
const material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
|
|
||||||
|
const positionsArray = new Float32Array([
|
||||||
|
0, 0, 0,
|
||||||
|
0, 1, 0,
|
||||||
|
1, 0, 0
|
||||||
|
]);
|
||||||
|
|
||||||
|
const geometry = new THREE.BufferGeometry();
|
||||||
|
geometry.setAttribute('position', new THREE.BufferAttribute(positionsArray, 3));
|
||||||
|
|
||||||
|
const material = new THREE.MeshBasicMaterial({ color: 0xff0000, wireframe: true });
|
||||||
const mesh = new THREE.Mesh(geometry, material);
|
const mesh = new THREE.Mesh(geometry, material);
|
||||||
scene.add(mesh);
|
scene.add(mesh);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user