我从这里下载了这个 javascript 库:https ://github.com/webarkit/ARnft 我开始做一些测试。
一切都很好,但是当我尝试使用上传自定义 nft 的链接时,什么都没有了。也许有人可以帮助我理解?我正在使用 arNEFT_gltf_example.html 这是我的代码:
<script src="js/ARnftThreejs.js"></script>
<script src="../dist/ARnft.js"></script>
<script>
ARnft.ARnft.init(1280, 720, ["https://arjs-cors-proxy.herokuapp.com/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/trex-image/trex"], ['pinball'], 'config.json', true)
.then((nft) => {
document.addEventListener('containerEvent', function (ev) {
let canvas = document.getElementById('canvas');
let fov = 0.8 * 180 / Math.PI;
let ratio = window.clientWidth / window.clientHeight;
let config = {
"renderer": {
"alpha": true,
"antialias": true,
"context": null,
"precision": "mediump",
"premultipliedAlpha": true,
"stencil": true,
"depth": true,
"logarithmicDepthBuffer": true
},
"camera": {
"fov": fov,
"ratio": ratio,
"near": 0.01,
"far": 1000
}
}
let sceneThreejs = new ARnftThreejs.SceneRendererTJS(config, canvas, nft.uuid,
true);
sceneThreejs.initRenderer();
const renderer = sceneThreejs.getRenderer();
const scene = sceneThreejs.getScene();
renderer.outputEncoding = THREE.sRGBEncoding;
renderer.physicallyCorrectLights = true;
let directionalLight = new THREE.DirectionalLight('#fff', 0.4);
directionalLight.position.set(0.5, 0, 0.866);
scene.add(directionalLight)
let nftAddTJS = new ARnftThreejs.NFTaddTJS(nft.uuid);
nftAddTJS.oef = true;
nftAddTJS.addModel('./Data/models/Duck/glTF/Duck.glb', 'pinball', 170, false);
const tick = () => {
sceneThreejs.draw();
window.requestAnimationFrame(tick)
}
tick()
})
}).catch((error) => {
console.log(error);
});
</script>
谢谢