Viewer quality settings (for one viewer on the page) - autodesk-forge

I have two viewers on the same page. And I want to set performance settings for only one viewer with following code:
this.viewer.setQualityLevel(false, false);
this.viewer.setGroundShadow(false);
this.viewer.setGroundReflection(false);
this.viewer.setProgressiveRendering(true);
BUT (!) settings are applied for both viewers for some reason. Is there any way to apply them only for one viewer on the page?

The viewer settings are kept in localStorage, so changing them using methods like viewer.setQualityLevel probably propagates the updates to other viewer instances as well. Let me discuss this behavior with the dev team as (I think) it could be considered a bug.
In the meantime, if you need to change settings for a single instance of the viewer, consider using "lower level" methods that don't use the local storage. For example, instead of viewer.setQualityLevel(useSAO, useFXAA) you could use viewer.impl.togglePostProcess(useSAO, useFXAA), and instead of viewer.setGroundShadow(bool) you could use viewer.impl.toggleGroundShadow(bool).

EDIT
Also try the Profile API to persist settings - you can get the current profile with:
viewer.profile
I was unable to replicate the issue unfortunately ... looking at your code did you assign two viewers to the same handle? can you post your code to initialize viewers? what version of viewer btw?

Related

Error in add measure core extension in the viewer

I tried add the measure extension in my viewer and it broke.Javascript error image
Others extensions works as well but only measure broke...
Extensions declarations image
This error means that the extension expects a model to be loaded, so you should use the Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT and call viewer.loadExtension('Autodesk.Measure') in your event handler. Take a look at this blog post for more details about viewer events.
By the way I would recommend not to use the ViewingApplication but directly the Viewer, as described in the Basic Viewer tutorial. The ViewingApplication uses the same API is the background but encapsulate the Viewer and is less explicit. Also it will attempts to load all extensions at start, which may cause issue like the one you are facing.
The measure extension is loaded by default on my side, so why is it that you want to explicitly load it yourself?

Google Web Designer has a very long load time

I'm creating an html5 banner using Google Web Designer. I've created the banner and published it. When I view the published version I noticed that it takes sometime to load.
Someone else on my team is also creating HTML5 banners. The banner that he creates loads instantly even though its a larger file size. We compared our files and other than the actual assets, the way the banner was created and published is the same.
Does anyone have any ideas why this might be happening?
GWD add this code at the end of the banner and animation show up immediately:
<script data-exports-type="dclk-quick-preview">studio.Enabler.setRushSimulatedLocalEvents(true);</script>
Which environment are you using?
When creating a new project in GWD you are able to select an environment. By default is DoubleClick.
This adds additional file (in the case of DoubleClick, the Enabler library).
If you open your Chrome console, while running the banner, you will see that the banner is not initialized until the enabler is available.
You will also see how much time it takes to load the enabler.
If your colleague is creating a banner without that library, or without correctly listening to the event Enabler.initialized, this may be the main reason for the discrepancy.
If you don't want to include this additional library (that is used to integrate your banner in DoubleClick Studio), just select Generic from the environments dropdown.
There is also another reason that may cause the delay, and is the PoliteLoader.
You can select to politeLoad the banner from the Publish menu.
If the PoliteLoader is selected this cause the banner to be initialized only after the page is fully loaded. This may cause delays compared to a non polite loaded ads.
This all seems not to be a bug, but a feature of enabler.js simulates a test environment, when not beeing uploaded to Adwords (guess it similar in Doubleclick). Uploading to Google Environments should change the situation
Look at the console and see:
There is a long delay in alle items loading after the enabler.js.
It is NOT because of a long loading time of enabler.js - thats all fine.
Looking at the Logs, the enabler waits a second and throws out:
[ 1.008s] [studio.sdk] Using default ad parameters in test environment. Simulating local events.
When uploading to Google Adwords (i assume that this all is similar to DC Studio) - the enabler throws out different logs and the delay disappears.
Hope this was helpful.
By chance, I found out a way to make the Enabler loading fast. Instead of using Publish, use Preview to generate the HTML.
For some reasons, Enabler.js in preview-generated HTML only takes 0.019s to load as compared to Enabler.js in publish-generated HTML taking 1.015s to load.
Studio Enabler SDK looks for "e" parameter in iframe URL containing Studio creative. It expects a number and uses that to set the creative environment.
Setting e=1 in your preview environment (query string parameter in the iframe url pointing at the index.html for your studio creative) will tell Enabler to use LIVE mode.
I assume there is a reason why Enabler has this functionality (avoid counting impressions or paying for impressions from test/qa environment)...so I wouldn't suggest using this as a permanent setting.

Polymer - Don't load app until geolocation isn't set

I'm currently working on a webapp with the polymer-framework.
However, the whole application depends on the geolocation of the device. I'm setting the location in the app-globals file to use it globally, but it takes some time (around 500ms).
My question now is, how can I say to polymer that it should get to work, after the geolocation is set?
Thanks!
I think it depends on the specific behavior you're looking for. A few cases:
Everything still loads when the page loads, including perhaps some app UI and you have a loading icon or similar to indicate that the app is still starting up while you're waiting for the location.
You don't want to show the app until you have the location. Perhaps you don't want the app resources to be loaded at this time either.
You don't even want Polymer to be loaded until you have the location.
There's a lot of options & they may depend on your app architecture a bit, but for a general structure:
show a loader icon on startup & just wait to populate any templates you have until location is set
perhaps keep the hidden attribute on your main app element until location is available &/or don't append the element to the DOM until this point (although with similar resource loading opportunity caveat as in 3 below).
you could wait to add polymer & related elements until location is available, but generally seems silly to do this since your app could be doing this work while the user is waiting for a location to be found.
If you've got a more specific need then more details are probably needed.

How to retrieve the window.localStorage.storedparameters?

I'm storing the values in window.localstorage.storedparameters. When i'm pulling back, i have some issues. So i would like to know where these data storing in the browser ? Is this storing data differ based on browsers ?
You can use the chrome browser.
Just go to developer tools by pressing F12. And then go to "Resources" tab and then go to "Local storage" option. And you will see all your local storage of browser there.
You can retrieve them programmatically using the window.localStorage object. To get a single item, either localStorage.nameOfItem or localStorage.getItem('nameOfItem') will work.

Cross Domain Policy with JSON feeds and Dashcode. Is there a way to use JSONP and implement it with the datasource feature in dashcode UI?

I'm just trying to get data from a json feed from an external server into my webapp.
I don't know enough about javascript to custom build my webapp so I was relying on the dashcode UI (specifically the datasources, dragging fields, etc.)
Is there a way to get around the cross domain policy and continue to use the datasource part of dashcode? I tried doing a JSONP request, but whenever I put the .js file into the datasources it says it is not a valid feed.
Please tell me if it is possible to get around the crossdomain policy while also continuing to use the dashcode datasource UI to assign values such as title and content easily into the webapp.
This explanation might be a little confusing, I'm just concerned that it won't be possible to continue using the datasource UI because the code is not actually being run until the app is launched. Just looking for some clarity.
Click on “Widget Attributes” in the left-hand source pane. Under “Network / Disk Access”, make sure that “Allow Network Access” is checked.