Sample projects :PlayCanvas 3D HTML5 Game Engine
Use the following method to reposition the space
var taprecenter = pc.createScript('taprecenter')
// Fire a 'recenter' event to move the camera back to its starting location in the scene.
taprecenter.prototype.initialize = function() {
this.app.touch.on(pc.EVENT_TOUCHSTART,
(event) => { if (event.touches.length !== 1) { return } this.app.fire('xr:recenter')})
}
I want to click there, the object is shown there.I’ll just change the code to look like this
var taprecenter = pc.createScript('taprecenter')
// Fire a 'recenter' event to move the camera back to its starting location in the scene.
taprecenter.prototype.initialize = function() {
this.cameraEntity= this.app.root.findByName('Camera');
this.app.touch.on(pc.EVENT_TOUCHSTART, this.touchStart, this);
// this.app.touch.on(pc.EVENT_TOUCHSTART,
// (event) => { if (event.touches.length !== 1) { return } this.app.fire('xr:recenter')})
}
taprecenter.prototype.touchStart = function (event) {
if (event.touches.length !== 1)
{ return }
//var point= this.cameraEntity.screenToWorld(event.x, event.y, this.cameraEntity.farClip);
var point= this.cameraEntity.camera.screenToWorld(event.x, event.y, this.cameraEntity.camera.farClip);
this.app.fire('xr:recenter',point);
//this.app.fire('xr:recenter')
};
Changing it to this way did not achieve the effect I want, positioning is still not quite accurate, how do I change to do?
Builds: 8the Wall AR Show - PLAYCANVAS