After some research, I decided to explore the possibility of importing a DirectX Model and stumbled upon this XLoader. However, despite my best efforts, I am unable to initialize it successfully. As someone who prefers linking directly to libraries for easy updates without having to constantly re-download and re-upload, my test code snippet looks like this:
<html>
<body>
<script src="https://threejs.org/build/three.js"></script>
<script type="module" src="https://threejs.org/examples/jsm/loaders/XLoader.js"></script>
<script>
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.001, 10000 );
var manager = new THREE.LoadingManager();
var Texloader = new THREE.TextureLoader();
var loader = new THREE.XLoader(manager, Texloader);
loader.load(['FrigateHull.x'], function (object) {
console.log(object);
},function (xhr) {
if (xhr.lengthComputable) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log(Math.round(percentComplete, 2) + '% downloaded');
}},
function (xhr) {
console.log(xhr);
});
</script>
</body>
</html>
The error message I keep encountering with this setup is:
TypeError: THREE.XLoader is not a constructor
I have attempted using the import
method as shown in the examples, but it still results in the same error. I also tried downloading the git repository to the server and linking to it, only to receive an error about global is undefined
. Is there something crucial that I am overlooking, or perhaps another alternative DirectX Model Loader that I could experiment with?