I don't know if it is a bug: I can't find nothing simillar on github bug/issue tracking or stackoverflow either.
The problem is that when I import an object with children objects with OBJMTLloader, the position and rotation appears to be set to 0 on the children.
The parent object has correct positioning data.
I assume this is not the correct behaviour. How I can know the position of every children of the object?
Thank you in advance,
I think that is the limitation of the OBJ format itself:
http://help.sketchup.com/en/article/114389
Try using Collada or GLtF instead.
Related
Currently, I am trying to dive deeper into grouped objects or better hierachic ordered objects. However I got a strange issue with the position and the visibility of a object3D and childs of those.
So i have a set of objects, a light source with is the main object so far, and a few spheres for example, which are childs of the the main object.
The problem is, that child objects, which are positioned behind another object ( siblings ) ( from the camera view ) are visible. And all childs objects appear infront of the main object while those actually positioned behind the main object.
Sadly i can't reproduce this in a codePen so i had to take some pictures of the scene, many apologies for that.
In the pictures, the camera rotates clockwise around the light source (main object to the left).
So basically what I am doing is:
mObj = new THREE.Object3D();
mObj.add(new THREE.Mesh(someGeometry, someMaterial);
cObj = new THREE.Object3D();
cObj.add(new THREE.Mesh(someGeometry, someMaterial);
mObj.add(cObj);
scene.add(mObj);
Is that related to the object hierachic order or something else?
The second more negligible issue is, that on one of my pc's, those parts of objects which are dark (because of no lighting), generate those strange black/grey faces, which i cant explain. Maybe Graphicscard/driver or something?
What's the distance between these objects? It could be a floating point rounding issue. I've run into it myself.
If it's so, and you're getting flickering models, you'll need to keep your camera and the active model at the origin, and move the universe around you to keep precision in the important places (near the player).
I created a scene;
How can I get it by id(name)?
Like jquery(#test)?
In three.js doc,I just find the scene.getObjectById() to get children obj.
There is a getObjectByName method for this here in the Object3D class.
And here it is also mentioned in the documentation.
Update
Both the getObjectByName and the getObjectById methods are to find children objects inside a parent object. A scene doesn't have a parent so finding scene by id or finding scene by name doesn't make much sense...
In threejs, LOD objects created with clone() method show all levels of details at once.
If i have two LODs, named LOD1 & LOD2, if LOD2 is a clone of the first and that both are updated in the render loop, then LOD1 will behave as expected. But LOD2 will yet display an instance of all level meshes at the nearest distance, and add an other instance of those mesh if it is the current one.
Did i miss something or is it an issue ?
Until next revision it can be solved by removing or commenting
THREE.Object3D.prototype.clone.call( this, object );
in
THREE.LOD.prototype.clone
I'm working with the three.js editor where I parse an object from JSON format. As usual it first parses the materials and geometries, then I create meshes from it. While parsing materials I also load textures. The issue now is that I have to call...
object.geometry.uvsNeedUpdate = true;
object.geometry.buffersNeedUpdate = true;
... after the image for the texture completely loaded - but why?! The geometry never changed before, neither did its uvs or anything like it. It's still the plain old geometry, yet I always get a GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 2 when trying to render. It only works with this "hack" although the geometry is always the same.
In my opinion it should also work perfectly when I update the uvs after object creation (or not at all). I didn't find anything in the three.js editor code that would update the geometry or its faceVertexUvs.
I know it's a bit of an abstract problem, I'm mainly looking for some hints or insights why this hack might be necessary.
Thanks!
Three.js "guesses" whether uvs are needed according to your used textures in bufferGuessUVType. If you want to preallocate uv buffers you can either init a map attribute with an empty THREE.Texture, update the geometry after the map was assigned, etc.
Is it somehow possible to filter rendered objects based on distance between camera and object ? I would like to specify that some object can be rendered only from close distance ( like details on complicated meshes etc ). I know i can handle this myself but before that I'm looking if there is any build in solution.
Yes, a feature is available for that. It is called level-of-detail ( LOD ).
See http://threejs.org/examples/webgl_lod.html. Click the mouse to see the effect.
three.js r.62