Hi Sean,
1) My tileset is split across thousands of .b3dm files. I am not sure if this is a valid way to verify how many indices there are in my model, but I spot inspected a few of the .b3dm files and seemed to find there is only one indices array for my model. I inspected the glTF for each of these .b3dm files and found only one mesh with one primitive. The primitive defines POSITION and TEXCOORD_0 attributes and defines a single indices property. Additionally, the mode property is set to 4. This all seems to line up.
I also tried this process out with a different 3D Tiles example I found online, however this tileset did have multiple indices.
For clarity, here is the patch to store the indices and position typed arrays. It is pretty straightforward:
diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js
index a895bb838..6523ce3bd 100644
--- a/Source/Scene/Model.js
+++ b/Source/Scene/Model.js
@@ -1659,29 +1659,31 @@ define([
CreateVertexBufferJob.prototype.execute = function() {
createVertexBuffer(this.id, this.model, this.context);
};
///////////////////////////////////////////////////////////////////////////
function createVertexBuffer(bufferViewId, model, context) {
var loadResources = model._loadResources;
var bufferViews = model.gltf.bufferViews;
var bufferView = bufferViews[bufferViewId];
+ var buffer = loadResources.getBuffer(bufferView);
var vertexBuffer = Buffer.createVertexBuffer({
context : context,
- typedArray : loadResources.getBuffer(bufferView),
+ typedArray : buffer,
usage : BufferUsage.STATIC_DRAW
});
vertexBuffer.vertexArrayDestroyable = false;
model._rendererResources.buffers[bufferViewId] = vertexBuffer;
model._geometryByteLength += vertexBuffer.sizeInBytes;
+ model.vertexBuffer = buffer;
}
///////////////////////////////////////////////////////////////////////////
var CreateIndexBufferJob = function() {
this.id = undefined;
this.componentType = undefined;
this.model = undefined;
this.context = undefined;
};
@@ -1696,30 +1698,32 @@ define([
CreateIndexBufferJob.prototype.execute = function() {
createIndexBuffer(this.id, this.componentType, this.model, this.context);
};
///////////////////////////////////////////////////////////////////////////
function createIndexBuffer(bufferViewId, componentType, model, context) {
var loadResources = model._loadResources;
var bufferViews = model.gltf.bufferViews;
var bufferView = bufferViews[bufferViewId];
+ var buffer = loadResources.getBuffer(bufferView);
var indexBuffer = Buffer.createIndexBuffer({
context : context,
- typedArray : loadResources.getBuffer(bufferView),
+ typedArray : buffer,
usage : BufferUsage.STATIC_DRAW,
indexDatatype : componentType
});
indexBuffer.vertexArrayDestroyable = false;
model._rendererResources.buffers[bufferViewId] = indexBuffer;
model._geometryByteLength += indexBuffer.sizeInBytes;
+ model.indexBuffer = buffer;
}
When I inspect model.indexBuffer after createIndexBuffer has been called, this is the result:
[0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 3, 0, 5, 0, 6, 0, 3, 0, 7, 0, 4, 0, 8, 0, 3, 0, 9, 0, 10, 0, 7, 0, 3, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, ...]
Similarly, for the example I found online, this is the result:
[37, 0, 38, 0, 39, 0, 37, 0, 250, 1, 251, 1, 37, 0, 39, 0, 102, 3, 37, 0, 109, 4, 250, 1, 37, 0, 102, 3, 109, 4, 20, 2, 37, 0, 58, 4, 38, 0 ...]
As you can see, many of these indices don't seem to define real triangles. I thought that some of these might just be 'noise' or 'outliers' that appear from the program I am using to generate the tiles, but the online example seems to have the same problem. On top of that, I have performed some manual testing by placing visual markers in the scene at the calculated triangle vertex locations (including the transformations) and the results do not look correct (overly large triangles that don't correspond to any geometry on the model). I've also manually tested with Cesium.IntersectionTests by building a ray from the camera to a point on the model where I click and have not been able to trigger a successful intersection. I am a bit stuck on this, and I am wondering if you have any other thoughts?
2) I've implemented the transformation correctly as far as I can tell. Due to the issues above I am not 100% certain.
If I can't get past this soon, I will probably try the ShadowMap approach you mentioned before.
Thank you,
Eric