I have been customizing the vertices of various box geometries to create unique shapes or adjust their heights. Everything looks great in my scenes (check out this example https://i.sstatic.net/w7Z3G.jpg).
However, I encountered an issue when using the ObjectExporter
and attempting to load the scene into . None of the vertex modifications were appearing. Additionally, loading the scene.json
file into Blender resulted in an error mentioning KeyError:'vertices'
The process involves editing geometry vertices via a UI, saving these changes into a matrix, then verifying the matrix upon scene load. The relevant function snippet is shown below:
setBaseTileVertices:function()
{
var scope = this;
scope.baseTiles.children.forEach(function(tile , t)
{
tile.geometry.vertices.forEach(function(vertex , v)
{
vertex.x = (tile.userData.vertices[v].x) ? tile.userData.vertices[v].x : vertex.x;
vertex.y = (tile.userData.vertices[v].y) ? tile.userData.vertices[v].y : vertex.y;
vertex.z = (tile.userData.vertices[v].z) ? tile.userData.vertices[v].z : vertex.z;
});
});
}
Is there a more accurate method for editing vertices so that the changes reflect in the editor and/or Blender? Have I selected the appropriate exporter? I attempted to use the THREE.SceneExporter
, but faced errors indicated here
Edit
Upon further investigation, I noticed that all modified box geometries shared a similar matrix value in the JSON output, while a square pyramid I created had the correct matrix. It seems I need to update the matrix of each geometry after modification. Although uncertain about the exact approach, I am making progress towards a solution.
Edit 2
Upon confirming that the matrices for each geometry are being updated, I am perplexed by why only the pyramid renders correctly, whereas the box geometries appear flat without any vertex changes reflected. An illustrative screenshot from the editor can be seen here: https://i.sstatic.net/mtU0J.jpg, note how the bounding box helper recognizes the height of baseTiles
, indicating edited vertices are considered.
Edit 3
Conducting a test, I modified lines 65 - 74 of ObjectExporter.js
as follows:
} else if ( geometry instanceof THREE.BoxGeometry ) {
data.type = 'Geometry';
data.data = geometryExporter.parse( geometry );
delete data.data.metadata;
//handleParameters( [ 'width', 'height', 'depth', 'widthSegments', 'heightSegments', 'depthSegments' ] );}
This alteration resulted in the shape of my level looking correct on the editor (https://i.sstatic.net/E4sdU.jpg), yet the colors or materials were not transferring over. Every element appeared black in contrast to the intended green color on the +Y faces.
Here is an example of exporting with the unedited ObjectExporter for comparison:
{
"metadata": {
"version": 4.3,
"type": "Object",
"generator": "ObjectExporter"
},
...
}
And here is a sample of edited JSON resulting from parsing box geometries as geometry instead of the entire scene, leading to this outcome: https://i.sstatic.net/E4sdU.jpg
Any insights or suggestions?