Translations: Japanese
Wall / Obstacle
// Wall/obstacle list
const collisionObjects:THREE.Object3D[] = [wall];
// List of VR teleportation movable places
const teleportTargetObjects:THREE.Object3D[] = [ground, ground1, ground2];
// Bounding box list for collisionObjects and 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 = () => {
// Wall/obstacle list
collisionObjects = queryObjects(".collider,.wall");
// List of VR teleportation movable places
teleportTargetObjects = queryObjects(".ground,.environmentGround");
interactableObjects = queryObjects(".clickable");
// Update bounding box list for collisionObjects and teleportTargetObjects
updateCollisionBoxes();
};
scene.object3D.updateMatrixWorld();
updateCollisionObjects();
const adapter = new VerseThree.AFrameEnvAdapter(
scene,
document.getElementById("headOffset").object3D,
document.getElementById("player").object3D,
() => collisionBoxes, // Bounding box list for collisionObjects and teleportTargetObjects
() => collisionObjects, // Wall/obstacle list
() => teleportTargetObjects, // List of VR teleportation movable places
{