Hello everyone,
Kinda new to Threejs here,
I loaded a FBX model and it looks like this :
code source : `
const manager = new THREE.LoadingManager();
manager.addHandler(/\.tga$/i, new TGALoader());
const mesh1 = new FBXLoader(manager);
// const path = require("./models/fbx/Walking.fbx");
mesh1.load("/models/fbx/HEART.fbx", function (object) {
object.scale.multiplyScalar(0.02);
object.position.x = objectsDistance * 0.5;
object.position.y = -objectsDistance * 0.2;
object.traverse(function (child) {
if (child.isMesh) {
// child.material.map = stars;
// child.geometry = new THREE.BufferGeometry();
// console.log(child);
// const uvs = child.geometry.attributes.uv.array;
// child.geometry.setAttribute(
// "uv",
// new THREE.Float32BufferAttribute(uvs, 4)
// );
// child.material = new THREE.PointsMaterial({
// color: 0xff0000,
// size: 0.002,
// transparent: true,
// });
// console.log(child.geometry.attributes.uv);
child.castShadow = true;
child.receiveShadow = true;
}
});
scene.add(object);
});
`
and i want to transform it to Points material ( please correct me if im wrong), so i did this :
const manager = new THREE.LoadingManager();
manager.addHandler(/\.tga$/i, new TGALoader());
const mesh1 = new FBXLoader(manager);
// const path = require("./models/fbx/Walking.fbx");
mesh1.load("/models/fbx/HEART.fbx", function (object) {
object.scale.multiplyScalar(0.02);
object.position.x = objectsDistance * 0.5;
object.position.y = -objectsDistance * 0.2;
object.traverse(function (child) {
if (child.isMesh) {
// child.material.map = stars;
// child.geometry = new THREE.BufferGeometry();
console.log(child);
const uvs = child.geometry.attributes.uv.array;
child.geometry.setAttribute(
"uv",
new THREE.Float32BufferAttribute(uvs, 4)
);
child.material = new THREE.PointsMaterial({
color: 0xff0000,
size: 0.002,
transparent: true,
});
console.log(child.geometry.attributes.uv);
child.castShadow = true;
child.receiveShadow = true;
}
});
scene.add(object);
});
and the result look like this :
any help please ? thank you