Recognize the uploaded obj is cylinder or Not how to do that
Quite literally your only option, unless you set up specific boundaries of what defines a cylinder (shape / level of detail / lids / dents / aspect ratio, there’s quite a lot of properties - and modifying any even slightly can technically turn a cylinder into a sphere / cube)
The objs are literally created from blender does that help in anyway
Nope, geometry is geometry - what you’re looking for is a way to define what is a cylinder in a mathematical way - what separates the shape you’re looking for from all the other shapes.
Before the AI ​​Era, OpenCV was an incredible image analysis tool, made in c++
I know that it is capable of doing this, and I know that there is also a javascript version of it.
and
https://docs.opencv.org/4.x/d5/d10/tutorial_js_root.html
Open the OBJ file and see if there is any metadata that blender may have stored on the objects…
Like maybe its named “cylinder” or has a comment indicating what generated it.
Otherwise, this is basically a doomed concept.
If you could explain why you need to identify cylinders, we might be able to offer some more practical approaches.
I need to scale an OBJ file. If the object is a cylinder type, when its length is increased, the breadth should also increase proportionally, and vice versa. For other shapes, the object should scale based on its length, breadth, and height."
https://didisoftwares.ddns.net/6/index.html
I needed to add this to scale models based on height by importing a model of whatever height into tpose, needed because skinedmesh its hard to get correct box when skelleton changed pose,
Maybe you can give some idea of ​​something easier if you don’t have a skeleton
this.options.modelsize its a constant height defines model size
used fixModelScale(model)
_expandAABB(skinnedMesh, aabb) {
var vertex = new THREE.Vector3();
var temp = new THREE.Vector3();
var skinned = new THREE.Vector3();
var skinIndices = new THREE.Vector4();
var skinWeights = new THREE.Vector4();
var boneMatrix = new THREE.Matrix4();
var skeleton = skinnedMesh.skeleton;
var boneMatrices = skeleton.boneMatrices;
var geometry = skinnedMesh.geometry;
var index = geometry.index;
var position = geometry.attributes.position;
var skinIndex = geometry.attributes.skinIndex;
var skinWeight = geometry.attributes.skinWeight;
var bindMatrix = skinnedMesh.bindMatrix;
var bindMatrixInverse = skinnedMesh.bindMatrixInverse;
skeleton.update();
function expand() {
vertex.applyMatrix4(bindMatrix);
skinned.set(0, 0, 0);
for (var j = 0; j < 4; j++) {
var si = skinIndices.getComponent(j);
var sw = skinWeights.getComponent(j);
boneMatrix.fromArray(boneMatrices, si * 16);
temp.copy(vertex).applyMatrix4(boneMatrix).multiplyScalar(sw);
skinned.add(temp);
}
skinned.applyMatrix4(bindMatrixInverse);
aabb.expandByPoint(skinned);
}
if (index !== null) {
for (var i = 0; i < index.count; i++) {
vertex.fromBufferAttribute(position, index.getX(i));
skinIndices.fromBufferAttribute(skinIndex, index.getX(i));
skinWeights.fromBufferAttribute(skinWeight, index.getX(i));
expand();
}
} else {
for (var i = 0; i < position.count; i++) {
vertex.fromBufferAttribute(position, i);
skinIndices.fromBufferAttribute(skinIndex, i);
skinWeights.fromBufferAttribute(skinWeight, i);
expand();
}
}
}
getModelBox3D(object3D) {
var aabb = new THREE.Box3();
var matrixWorld = new THREE.Matrix4();
var skinnedMeshes = [];
// Traverse the object3D to find all SkinnedMeshes
object3D.traverse(function(child) {
if (child.isSkinnedMesh && child.skeleton) {
skinnedMeshes.push(child);
}
});
if (skinnedMeshes.length === 0)
return;
// Expand the AABB to include all SkinnedMeshes
skinnedMeshes.forEach(skinnedMesh => {
var tempAABB = new THREE.Box3();
this._expandAABB(skinnedMesh, tempAABB);
tempAABB.applyMatrix4(skinnedMesh.matrixWorld);
aabb.union(tempAABB);
}
);
return aabb;
}
fixModelScale(object3D) {
//put model on TPOSE
// Calculate the bounding box of the newModel
let modelSize = new THREE.Vector3();
this.getModelBox3D(object3D).getSize(modelSize);
let biggervalue = Math.max(modelSize.x, modelSize.y, modelSize.z);
//reescale to maintain aspect ratio
let newscale = this.options.modelsize / biggervalue;
object3D.scale.multiplyScalar(newscale);
if (object3D.userData.mixamo == undefined)
object3D.userData.mixamo = {};
object3D.userData.mixamo.scale = newscale;
//put hips on same position
return object3D;
}