Autodesk-Forge / forge-dataviz-iot-data-modules

Re-usable Iot data modules that can be used to create your own Autodesk Forge Viewer-based IoT application.
Apache License 2.0
4 stars 5 forks source link

problem with sprites icon rendering #3

Open casper5822 opened 2 years ago

casper5822 commented 2 years ago

Hello, i have a problem with icon url for sprites. I have different icons for each sprite, the images are png 512x512px and they are passed as base64 encoded string images.

This is my code:

` let viewableData = new Autodesk.DataVisualization.Core.ViewableData({ atlasWidth: 512, atlasHeight: 512 }); viewableData.spriteSize = 36;

  for(var i = 0; i < this.sensors.length;i++){
    let sensor = this.sensors[i];
    const style = new Autodesk.DataVisualization.Core.ViewableStyle(Autodesk.DataVisualization.Core.ViewableType.SPRITE, new THREE.Color(0xffffff), sensor.img);
    const viewable = new Autodesk.DataVisualization.Core.SpriteViewable(new THREE.Vector3(sensor.x,sensor.y,sensor.z), style, sensor.dbId);
    viewableData.addViewable(viewable);
  }

  viewableData.finish()
  .then(()=>{
      this.dataVizExtn.addViewables(viewableData);
  },error =>{
    console.log(error)
  });`

I have 7 sensors and there is a problem with the last sensor because all the previous sprites show the wrong image (they show the latest sensor icon). How this can be possible?

Other info: Angular 11 app wrapper: "ng2-adsk-forge-viewer": "^1.4.0"

Thank you.

screencapture-localhost-4200-viewer-2021-11-22-17_48_35

RustyRaptor commented 7 months ago

I am having a similar issue where there is some randomness to it too. Some sensors won't render, and others will and usually it will only use one of the sprites I chose for all the sensors. It's strange because in the debugger it shows that all the styles for each viewable are set correctly. So, this must be a bug happening in the 3D rendering.

I am using a modified version of the APS IOT demo.

RustyRaptor commented 7 months ago

@casper5822 I just figured out the issue I was having. It turns out that when the image being used for the icon is too big the delay in the loading causes rendering errors. My solution was the scale down the icon significantly. SVG icons also seem to cause this issue. In my case I was using the option for icon size 32 so I scaled them all down to 32 by 32 pixels. I wonder if you're experiencing the same issue.