I am working in a forest project using angular and cesiumjs, and when I upload 100 trees into cesium ion and call it from my code, my viewer is completly slow. So, I found that instancing is a good idea to solve that problem, but I don't know how to instance it
I what tryin with this code:
const treePOsitions = [
[-77.029383, -12.125592],
[-77.02938, -12.125692],
[-77.029382, -12.125804],
[-77.029384, -12.125916],
[-77.029382, -12.12535]
]
const resource = await IonResource.fromAssetId(2331166);
treePOsitions.forEach((tree) =>
this.createNAddModels({ resource, x: tree[0], y: tree[1], z: 0, modelid: 0 })
);
async createNAddModels({ resource, x, y, z, modelid }) {
try {
const origin = Cartesian3.fromDegrees(x, y, z);
const hpr = new HeadingPitchRoll(0.0, 0.0, 0.0);
const modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr);
const model = varCesiumViewer.scene.primitives.add(
await Model.fromGltfAsync({
url: resource,
modelMatrix: modelMatrix,
})
);
} catch (error) {console.log(error)}
}
but my fps is still in 17fps and when I move fast it downs to 9fps or less. this is the correct way? or there is another way to improve the instancing and improve my fps.
Thank you!!