can gltf model geometries be combined / instanced?

497 views
Skip to first unread message

der.f...@gmail.com

unread,
Feb 3, 2017, 9:25:50 AM2/3/17
to cesium-dev
hi,

I have a gltf model that needs to be statically displayed many (tens of) thousand times on the surface of the globe. I'm looking into ways to ensure the best possible performance.

what I am currently doing is (in a loop):

———————

const locationMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
Cesium.Cartesian3.fromDegrees(pos.lng, pos.lat)
);
const rotationMatrix = Cesium.Matrix3.fromRotationZ(randomRotation);
const rotationMatrix4 = Cesium.Matrix4.fromRotationTranslation(
rotationMatrix,
undefined,
undefined
);
const modelMatrix = new Cesium.Matrix4();
Cesium.Matrix4.multiply(
locationMatrix,
rotationMatrix4,
modelMatrix
);
const model = Cesium.Model.fromGltf({
url: './model/plane.gltf',
modelMatrix,
scale: 1.0,
});
scene.primitives.add(model);

———————

from what I can tell, the model file is only requested once, and cached, so that's not an issue. but is there also a way to create instances of the model in a combined geometry, similar to what is described here? http://cesiumjs.org/tutorials/Geometry-and-Appearances/#combining-geometries

thanks a lot in advance.

Hannah Pinkos

unread,
Feb 3, 2017, 11:00:02 AM2/3/17
to cesium-dev, der.f...@gmail.com
Hello,

We don't have model instancing support in the Cesium release yet, but it has been added to our 3d-tiles branch: https://github.com/AnalyticalGraphicsInc/cesium/tree/3d-tiles
And we have instructions for cloning and building the code base here: https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/BuildGuide

Best,

Hannah

Frederic Brodbeck

unread,
Feb 3, 2017, 1:23:08 PM2/3/17
to cesium-dev
thanks a lot hannah. — what a difference that makes!

there is two new problems though:
1. picking does not work anymore

const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(
(action) => {
const pickedObject = scene.pick(action.position);
console.log(pickedObject); // → is `undefined`, although mouse pointer is definitely over a model
},
Cesium.ScreenSpaceEventType.LEFT_CLICK
);

———

2. the model is supposed to be white, but is displayed darker than before:

Inline image 1

Sean Lilley

unread,
Feb 5, 2017, 11:24:09 PM2/5/17
to cesium-dev, der.f...@gmail.com
Yeah picking does not seem to be working for ModelInstanceCollection. Looking at the code I see the root cause but it may be a little while before I get to fixing it. I would like to revamp the system a bit to be able to pick instances and modify their model matrices, rather than the default picking behavior for models.

I'm not sure what's causing the difference in color, are you able to send over the model you're using? 

Frederic Brodbeck

unread,
Feb 6, 2017, 4:40:31 AM2/6/17
to cesium-dev
On Mon, Feb 6, 2017 at 5:24 AM, Sean Lilley <lill...@gmail.com> wrote:
Yeah picking does not seem to be working for ModelInstanceCollection. Looking at the code I see the root cause but it may be a little while before I get to fixing it.

could you point me to what you think the root cause is?
for the project I am working on I will definitely need picking – maybe I can have a stab at it.
 
I would like to revamp the system a bit to be able to pick instances and modify their model matrices, rather than the default picking behavior for models.

I'm not sure what's causing the difference in color, are you able to send over the model you're using?

not sure why it looked different before, but changing the diffuse color of the material fixed it.

Sean Lilley

unread,
Feb 8, 2017, 12:24:19 AM2/8/17
to cesium-dev, der.f...@gmail.com
The root cause is the model options set pickVertexShaderLoaded, pickFragmentShaderLoaded, pickUniformMapLoaded which override the model's default picking behavior. However unless the ModelInstanceCollection is backed by a batchTable for Instanced3DModel3DTileContent the pick ids/shaders are not being set. I was going to look into this issue during the bug bash this week, but if I don't get to it feel free to take it up.

Patrick Cozzi

unread,
Feb 10, 2017, 9:02:45 AM2/10/17
to cesium-dev, der.f...@gmail.com
This was added in #4975 at the bug bash.

Patrick

Frederic Brodbeck

unread,
Feb 10, 2017, 9:05:37 AM2/10/17
to cesium-dev
thanks so much!

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/sUcx0GLI4Qc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages