Скриншоты ПК скриншоты телефона

Я могу выбирать объекты на ПК. Но я запускаю его по телефону, это не работает!

ПРИМЕЧАНИЕ: я повернул холст на телефоне на 90 градусов с помощью CSS (думаю, это из-за этой операции, но я не знаю почему) :

transform-origin: left top; transform: rotate(90deg); 
 import * as THREE from 'three'; export class PickupManager { raycaster: THREE.Raycaster; camera: THREE.Camera; scene: THREE.Scene; canvas: HTMLCanvasElement; constructor(camera: THREE.Camera, scene: THREE.Scene, canvas: HTMLCanvasElement) { this.raycaster = new THREE.Raycaster(); this.camera = camera; this.scene = scene; this.canvas = canvas; this.addEventListener(); } pickedObject: THREE.Object3D | any; ljj1: THREE.Object3D = null; ljj2: THREE.Object3D = null; ljj3: THREE.Object3D = null; ljj4: THREE.Object3D = null; ljj5: THREE.Object3D = null; pick = (normalizedPosition: THREE.Vector2) ={amp}gt; { this.ljj1 = this.ljj1 || this.scene.getObjectByName("LJJ1"); this.ljj2 = this.ljj2 || this.scene.getObjectByName("LJJ2"); this.ljj3 = this.ljj3 || this.scene.getObjectByName("LJJ3"); this.ljj4 = this.ljj4 || this.scene.getObjectByName("LJJ4"); this.ljj5 = this.ljj5 || this.scene.getObjectByName("64mmB016"); // 通过摄像机和鼠标位置更新射线this.raycaster.setFromCamera(normalizedPosition, this.camera); // 计算物体和射线的焦点const objects = [this.ljj1, this.ljj2, this.ljj3,this.ljj4, this.ljj5]; const intersectedObjects = this.raycaster.intersectObjects(objects,true); if (intersectedObjects.length {amp}gt; 0) { this.pickedObject = intersectedObjects[0]; const obj:THREE.Object3D = this.pickedObject.object; //output name of selected object console.log(obj.name ); } else { console.log("Not found!") } } getCanvasRelativePosition = (event: MouseEvent | TouchEvent) ={amp}gt; { const rect: DOMRect = this.canvas.getBoundingClientRect(); const position: THREE.Vector2 = new THREE.Vector2(); if (event instanceof MouseEvent) { position.x = event.clientX ; position.y = event.clientY; } else if (event instanceof TouchEvent) { const touch: Touch = event.changedTouches[0]; position.x = touch.clientX - rect.left; position.y = touch.clientY - rect.top; } else { throw "Incorrect event, needs MouseEvent or TouchEvent"; } return position; } getPickPoint = (event: MouseEvent | TouchEvent) ={amp}gt; { const canvasPosition = this.getCanvasRelativePosition(event); const pickPoint:THREE.Vector2 = new THREE.Vector2(); // 将鼠标位置归一化为设备坐标。x 和 y 方向的取值范围是 (-1 to  1) pickPoint.x = (canvasPosition.x / window.innerWidth ) * 2 - 1; pickPoint.y = (canvasPosition.y / window.innerHeight) * -2   1; return pickPoint; } addEventListener = () ={amp}gt; { this.canvas.addEventListener('mousedown', this.onMouseDown, false); this.canvas.addEventListener('touchstart', this.onTouchStart, false); } onMouseDown = (event: MouseEvent) ={amp}gt; { event.preventDefault(); this.pick(this.getPickPoint(event)); } onTouchStart = (event: TouchEvent) ={amp}gt; { event.preventDefault(); this.pick(this.getPickPoint(event)); } } 

Я хочу получить объект ljj1, ljj2, ljj3, ljj4, ljj5, я могу получить его на ПК, но я не могу получить его на телефоне.

Хонг Ли

новый участник этого сайта. Будьте внимательны, спрашивая разъяснения, комментируя и отвечая. Проверьте наш

Правила поведения

,