Trouble replicating demo with my own data. .vtk [ - xtk

I am trying to replicate this example with my own data.
window.onload = function() {
// create and initialize a 3D renderer
var r = new X.renderer3D();
r.init();
// create a mesh and associate it to the VTK Point Data
var p = new X.mesh();
p.file = 'http://x.babymri.org/?pits.vtk';
I understand you cannot simply point to the local .vtk file. I have read that webgl required the file to be served, so I am now correctly serving it from localhost.
I have placed exactly the same data (as served to the above example) locally and saved it in the file DATA.vtk.
I have modified MIME types inside IIS manager so that .vtk is text/html and when you point to either the raw data's url (in the original example) or my localhost data, they look exactly the same.
However, it still does not work. Specifically, this is my error:
Uncaught TypeError: Cannot read property 'length' of null xtk.js:179
Here is a picture of what I'm talking about...

Related

Solid: correct way to store a JSON object

I want to store a standard JSON object in the user’s Solid pod. After working through the Solid getting started tutorial, I found I could get/set the object in the VCARD.note parameter, but I suspect this is not the right way to do it.
Any advice on how to do this properly? The JSON object will be updated regularly and will typically have ~10-100 key pairs.
There are two options here.
Option 1 - store as RDF (recommended)
Generally, the recommended thing to do is not to store data as a standard JSON object, but rather to save the data as RDF. So for example, if you have a JSON object like
const user = {
name: "Vincent",
};
assuming you're using the JavaScript library #inrupt/solid-client, you'd create what it calls a "Thing" like this:
import { createThing, addStringNoLocale } from "#inrupt/solid-client";
import { foaf } from "rdf-namespaces";
let userThing = createThing();
userThing = addStringNoLocale(userThing, foaf.fn, "Vincent");
You can read more about this approach at https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/read-write-data/
Option 2 - store a JSON blob directly
The other option is indeed to store a JSON file directly in the Pod. This works, although it goes a bit against the spirit of Solid, and requires you to overwrite the complete file every time, rather than allowing you to just update individual properties whenever you update the data. You could do that as follows:
import { overwriteFile } from "#inrupt/solid-client";
const user = {
name: "Vincent",
};
// This is assuming you're working in the browser;
// in Node, you'll have to create a Buffer instead of a Blob.
overwriteFile(
"https://my.pod/location-of-the-file.json",
new Blob([
JSON.stringify(user),
]),
{ type: "application/json" },
).then(() => console.log("Saved the JSON file.}));
You can read more about this approach here: https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/read-write-files/

How to use #FetchRequest data in Provider struct in iOS 14 Widget [duplicate]

I want to display data fetched from Core Data in a widget. But #FetchRequest doesn’t work on widgets.
As I understand, we have to create an app group and make a shared persistent container.
What I want to know is how to read (fetch) data on widgets from that shared persistent container or simply, how to display data fetched from Core Data in widgets.
First you need to create an AppGroup which will be used to create a Core Data Persistent Container (here is a good explanation how to do it)
Then you need to create your own CoreData stack (an example can be found when you create a new empty project with CoreData enabled).
Accessing Core Data Stack in MVVM application
Assuming you have already created your Core Data model (here called DataModel), you now need to set the container url to your custom shared container location:
Share data between main App and Widget in SwiftUI for iOS 14
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: <your_app_group>)!
let storeURL = containerURL.appendingPathComponent("DataModel.sqlite")
let description = NSPersistentStoreDescription(url: storeURL)
let container = NSPersistentContainer(name: "DataModel")
container.persistentStoreDescriptions = [description]
container.loadPersistentStores { ... }
Now you can get the managedObjectContext from your shared Persistent Container:
let moc = CoreDataStack.shared.managedObjectContext
and perform a fetch request with it (more information here)
let predicate = NSPredicate(format: "attribute1 == %#", "test")
let request = NSFetchRequest<SomeItem>(entityName: "SomeItem")
let result = try moc.fetch(request)
Apart from all the links above I recommend you also read this tutorial about Core Data:
Core Data with SwiftUI Tutorial: Getting Started
Here is a GitHub repository with different Widget examples including the Core Data Widget.
For people who did all the work above, and finally can get the connection to your Core Data (e.g. you can get the count of request), but can't fetch the request, is mostly because that the entity you're fetching contains transformable type, and for some reason this error occurred: Cannot decode object of class, try fix this.

Tiles not shown on cesium

I created a viewer and added a customized layer (which is provided by myself). I am using the akka map server. My problem is that my map tiles are not displayed, although I can see from the console that cesium has loaded the tiles.
The code looks like this:
var viewer = new Cesium.Viewer("cesiumContainer");
var layers = viewer.scene.imageryLayers;
var through = layers.addImageryProvider(new Cesium.UrlTemplateImageryProvider({
url : 'http://my_ip:8777/modis/ndvi/{z}/{x}/{y}.png',
format: "image/png"
}));
through.alpha = 0.5;
If I change the url to another map such as blackmarble, it loads correctly
(i.e. the tiles are displayed, but the position y must be changed to reverseY). Does any body know why my map can't be loaded on the cesium?
I had found the key point.
Cesium must add CORS add the TMS which you want add it to your layers.
So just add the akka CORS suport,then everything will ok!

EmberJS client side record management (ember-data)

I have just started trying to use ember-data. I have an ember app for which I need to produce all the data on the client side and then save it all at once. So my object graph has a "Project" as the root object, then a project can have many "Sections" and then each section can have many "Items".
I am up to the stage where I am trying to create Item records on the client side and add them to the correct Section. When I am ready to save the data I just want to use project.save() and have it go and save the object graph instead of saving every time the model changes.
I am trying to look up the section to place the items in by name using store.filter({name:"section1"}) but ember keeps trying to go to the server to look them up. I see this in the console: GET http://localhost:4200/sections?name=Section1 404 (Not Found).
This is what I am trying to do:
store.filter('section', {name:'Section1'}, function(section) {
return section;
}).then(function(section)
{
var record;
//create a record
section.pushObject(record);
});
You are doing server side filtering and you want client side filtering.
Please read this article carefully.
In short, you should do
store.filter('section', function(section) {
return section.get('name') == 'Section1';
});

Facebook Unity3d SDK doesnot include FBUtil and GameStateManager classes

I am trying to integrate facebook sdk in my unity android game. I can not find FBUtil and GameStateManager in SDK downloaded from developer site.
I got the userId using FB.UserId. Also got the response
"sending to Unity OnInitComplete({"access_token":"CAAUCMHNGlZCcBAHJBQAs7AoJNevkZAFbkpSRk60TURemvv4Y6IOu9NXjGcFjFRZAx9RoxwKT4ZBZASs0NLiYTmi4rl7RyWYdtxxhlKkSjoIWiqqDSBdSDKk0OppB2ZB4U6IgtqQs9PM8uNCaNF5xgqWn2c9DDkp4dJc9p38XONKpdwRF7qDHtM","user_id":"100003735696788","opened":true})"
Just after that when I tried to get profile picture of the user, using the code given on developer.facebook.com,
void LoginCallback() {
FB.API (
"/me/picture",
Facebook.HttpMethod.GET,
APICallback
);
}
The response I get is 4 question marks.
????
where is the problem? Please help..
I used this link using WWW in Unity and it worked well.. This is exactly what I did
Once you have the user id, create a WWW object like this:
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture?type=large");
Then in the LateUpdate I put an IF condition checking if the picture was loaded or not with a bool called loaded to avoid reloading the picture more than once
if (url.isDone && !loaded)
{
loaded = true;
Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.ARGB32, false); //TextureFormat must be DXT5
url.LoadImageIntoTexture(textFb2);
PLANE_OR_QUAD_OBJECT.renderer.material.mainTexture = textFb2;
}
NOTE: url is visible in the whole class as well as loaded
If you need further help with this, let me know!
Normally Facebook picture API should return data with Texture type NOT text
For example, If you use code like #jkgm777 answer,
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture");
You should get Texture type that can use to replace your texture object in scene.
But If you want to get image url, USE THIS
http://graph.facebook.com/INSERT_USER_ID_HERE/picture?redirect=false
You will get this JSON for response
data: {
url: "{#IMAGE_URL#}",
is_silhouette: false
}