Skip to content
Prev Previous commit
Next Next commit
KTX2 seem to be working, verifying...
  • Loading branch information
James Kane committed Aug 25, 2022
commit 9fa1a246fe34679aa533c9db3151e89c6a0d39f3
4 changes: 2 additions & 2 deletions examples/test/model/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<a-assets>
<a-asset-item id="crate-obj" src="../../assets/models/crate/crate.obj"></a-asset-item>
<a-asset-item id="crate-mtl" src="../../assets/models/crate/crate.mtl"></a-asset-item>
<a-asset-item id="brainstem" src="https://cdn.aframe.io/test-models/models/glTF-2.0/brainstem/BrainStem.gltf"></a-asset-item>
<a-asset-item id="brainstem" src="https://cdn.glitch.global/f43e6264-95fc-43e8-8049-dc53b985b1e3/grip-compressed.glb?v=1661368839319"></a-asset-item>
</a-assets>

<a-entity position="0 0 -12">
<a-entity gltf-model="#brainstem" position="-2 -1 5" scale="3 3 3"></a-entity>
<a-text value="glTF" color="#000000" position="-2 -2 6" scale="1.5 1.5 1.5"></a-text>
<a-text value="glTF w/ KTX2 texture" color="#000000" position="-2 -2 6" scale="1.5 1.5 1.5"></a-text>

<a-entity obj-model="obj: #crate-obj; mtl: #crate-mtl" position="5 0 5"></a-entity>
<a-entity obj-model="obj: #crate-obj; mtl: #crate-mtl" position="5 2 5"></a-entity>
Expand Down
5 changes: 3 additions & 2 deletions src/components/gltf-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ module.exports.Component = registerComponent('gltf-model', {
this.ready = meshoptDecoder.then(function (meshoptDecoder) {
self.loader.setMeshoptDecoder(meshoptDecoder);
});
} if (ktxLoader) {
this.loader.setKTX2Loader(ktxLoader);
} else {
this.ready = Promise.resolve();
}
if (ktxLoader) {
this.loader.setKTX2Loader(ktxLoader);
}
},

update: function () {
Expand Down
1 change: 1 addition & 0 deletions src/lib/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require('super-three/examples/js/loaders/OBJLoader'); // THREE.OBJLoader
require('super-three/examples/js/loaders/MTLLoader'); // THREE.MTLLoader
require('super-three/examples/js/utils/BufferGeometryUtils'); // THREE.BufferGeometryUtils
require('super-three/examples/js/lights/LightProbeGenerator'); // THREE.LightProbeGenerator
require('super-three/examples/js/utils/WorkerPool'); // WorkerPool used by KTX2Loader

THREE.DRACOLoader.prototype.crossOrigin = 'anonymous';
THREE.GLTFLoader.prototype.crossOrigin = 'anonymous';
Expand Down
2 changes: 1 addition & 1 deletion src/systems/gltf-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports.System = registerSystem('gltf-model', {
}
if (!this.ktx2Loader && basisTranscoderPath) {
this.ktx2Loader = new THREE.KTX2Loader();
this.ktx2Loader.setTranscoderPath(basisTranscoderPath);
this.ktx2Loader.setTranscoderPath(basisTranscoderPath).detectSupport( this.el.renderer );
}
if (!this.meshoptDecoder && meshoptDecoderPath) {
this.meshoptDecoder = fetchScript(meshoptDecoderPath)
Expand Down