3D渲染 threejs。
技术支持:无间科技
完整代码请查看https://github.com/wujianar/webar-track
1. 初始化WebAR
// 初始化WebAR this.webAR = new window.WUJIAN.WebAR({ container: container, endpointUrl: 'https://iss-cn2.wujianar.com', token: 'MDU5........UzNjU2MjIwfQ==', scaleOffset: new THREE.Vector3(1.5, 3, 4), }); // 设置threejs this.webAR.setThree({ scene: this.scene, camera: this.camera, renderer: this.renderer });
2. 打开相机
this.webAR.openCamera().then(() => { // 相机打开后加载本地特征数据,加载模型等。 }).catch((err: any) => { });
3. 加载特征数据及跟踪
// 使用预编译好的特征数据 this.webAR.loadData('assets/data/kl.dat').then(() => { this.addCube(); this.render(); // 打开跟踪功能 this.webAR.start(); }).catch