import * as THREE from 'three';
import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, innerWidth / innerHeight, 0.1, 1000 );
camera.position.z = 10;
// create material and 2 sphere:
const material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );
const sphere_geo1 = new THREE.SphereGeometry( 2, 32, 32 );
// sphere_geo1.setAttribute('position', new THREE.BufferAttribute( new Float32Array([-5,0,0]), 3));
const sphere_geo2 = new THREE.SphereGeometry( 2, 32, 32 );
// merge spheres and add merged to scene:
var merged_geo = BufferGeometryUtils.mergeGeometries([sphere_geo1, sphere_geo2], false);
const merged = new THREE.Mesh( merged_geo, material );
scene.add(merged);
Currently facing an issue before merging where I am trying to set the position of the first sphere to x=-5
using setAttribute('position')
. However, when that line is uncommented, the sphere_geo1
does not seem to appear in the expected position. Any ideas on what might be going wrong?
Using r161