Is it possible to scale the size of a ObjectSymbol3DLayer based on the zoom level?

1017
1
Jump to solution
03-07-2017 10:35 AM
GeoffMoen
New Contributor

For example set a pixel size of the object instead of by meters. I am referencing a 3D json model which is working, I just want it to appear at the same pixel size independent on zoom level.  

var rendererUNIT = new UniqueValueRenderer({
   field: "IN_COM",
   defaultSymbol: new PointSymbol3D({
   symbolLayers: [new ObjectSymbol3DLayer({
   heading: 90,
   height: 5,
   material: { color: "grey" },
   resource: {
         href:"/maps/json/van.json"
      }

    })]
 })
});

0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Occasional Contributor III

As far as I know you can't set width/depth/height in pixels directly.  You could use an icon symbol 3D layer, which can be sized in pixels, but won't have volume (it can be either painted on the map or billboarded): IconSymbol3DLayer | API Reference | ArcGIS API for JavaScript 4.3

If the icon symbol 3D layer won't do, one option would be to recalculate the width, height, and depth in meters every time the zoom changes.  This is a lot of trouble, but it may get you the effect you're looking for.

Original sample, without the scaling: JS Bin - Collaborative JavaScript Debugging 

Same sample, except with some scaling logic added at the bottom of the JS: JS Bin - Collaborative JavaScript Debugging 

I found that I couldn't redefine the width and height on the symbol layer, I had to generate an entirely new renderer.  In this example it's a simple renderer but for you it would be a unique value renderer.  I'm also performing this check on every zoom event.  It might be better to only perform the calculation when the view stops changing, which you could do by watching the stationary property of the view like this:

JS Bin - Collaborative JavaScript Debugging 

View solution in original post

1 Reply
ThomasSolow
Occasional Contributor III

As far as I know you can't set width/depth/height in pixels directly.  You could use an icon symbol 3D layer, which can be sized in pixels, but won't have volume (it can be either painted on the map or billboarded): IconSymbol3DLayer | API Reference | ArcGIS API for JavaScript 4.3

If the icon symbol 3D layer won't do, one option would be to recalculate the width, height, and depth in meters every time the zoom changes.  This is a lot of trouble, but it may get you the effect you're looking for.

Original sample, without the scaling: JS Bin - Collaborative JavaScript Debugging 

Same sample, except with some scaling logic added at the bottom of the JS: JS Bin - Collaborative JavaScript Debugging 

I found that I couldn't redefine the width and height on the symbol layer, I had to generate an entirely new renderer.  In this example it's a simple renderer but for you it would be a unique value renderer.  I'm also performing this check on every zoom event.  It might be better to only perform the calculation when the view stops changing, which you could do by watching the stationary property of the view like this:

JS Bin - Collaborative JavaScript Debugging