Why the stl loader does not work on ios (swift)

Hi Guys,

The following code works well on Android, but when I run it on wkwebview(IOS), it does not work.

Is there any ios configuration reason or anything else?
var lo

var loader = new THREE.STLLoader();
await loader.load( file, function ( geometry ) {
currentObj = geometry;
console.log(“call back”)
} );

Actually, I was trying the examples, all loaders did not work~~

What you mean by that? Can you please explain in more detail what’s happening?

I mean I cannot get the geometry, cannot console the “call back”. The load call back function doesn’t give me the call back response

Okay, so onLoad() is not fired. Do you see any errors if you add an onError() callback to your load() call?

I had the same problem when loading .obj files via a loader

the reason is that you have to enable/allow loading of files from javascript in WKWebview. See this post on github:

This allows the loading using XMLHttpRequest (wich three.js is using in the background to load resources)

	webView.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
	webView.configuration.setValue(true, forKey: "allowUniversalAccessFromFileURLs")

source:

1 Like