Translations: English
壁/障害物
// 壁/障害物のリスト
const collisionObjects:THREE.Object3D[] = [wall];
// VRテレポート移動可能な場所のリスト
const teleportTargetObjects:THREE.Object3D[] = [ground, ground1, ground2];
// collisionObjectsとteleportTargetObjectsのバウンディングボックスリスト
const collisionBoxes:THREE.Box3[] = [...collisionObjects, ...teleportTargetObjects].map(
(o) => new THREE.Box3().setFromObject(o)
);
...
const adapter = new VerseThree.DefaultEnvAdapter(
renderer,
scene,
camera,
cameraContainer,
player,
() => collisionBoxes,
() => collisionObjects,
() => teleportTargetObjects,
);
const res = await VerseThree.start(
adapter,
let collisionObjects:THREE.Object3D[] = [];
let teleportTargetObjects:THREE.Object3D[] = [];
let interactableObjects:THREE.Object3D[] = [];
let collisionBoxes:THREE.Box3[] = [];
const updateCollisionBoxes = () => {
collisionBoxes.length = 0;
[...collisionObjects, ...teleportTargetObjects].map((el) => {
el.traverse((c) => {
if (!c.isMesh) { return; }
collisionBoxes.push(new THREE.Box3().setFromObject(c));
});
});
};
const queryObjects = (q) => [...scene.querySelectorAll(q)].map((v) => v.object3D).filter((v) => v.visible);
const updateCollisionObjects = () => {
// 壁/障害物のリスト
collisionObjects = queryObjects(".collider,.wall");
// VRテレポート移動可能な場所のリスト
teleportTargetObjects = queryObjects(".ground,.environmentGround");
interactableObjects = queryObjects(".clickable");
// collisionObjectsとteleportTargetObjectsのバウンディングボックスリストを更新
updateCollisionBoxes();
};
scene.object3D.updateMatrixWorld();
updateCollisionObjects();
const adapter = new VerseThree.AFrameEnvAdapter(
scene,
document.getElementById("headOffset").object3D,
document.getElementById("player").object3D,
() => collisionBoxes, // collisionObjectsとteleportTargetObjectsのバウンディングボックスリスト
() => collisionObjects, // 壁/障害物のリスト
() => teleportTargetObjects, // VRテレポート移動可能な場所のリスト
{