UNPKG

@osobh/reactar

Version:

AR Library for React Native and Expo

58 lines 2.17 kB
"use strict"; // src/sensors/EnvironmentalDetection.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.EnvironmentalDetection = void 0; class EnvironmentalDetection { // Simulate plane detection by returning a dummy plane after a short delay detectPlanes() { return new Promise(resolve => { setTimeout(() => { resolve([ { id: 'plane-1', center: { x: 0, y: 0, z: -1 }, extent: { width: 1, length: 1 } } ]); }, 500); }); } // Simulate hit testing by returning the first detected plane hitTest(x, y) { return this.detectPlanes().then(planes => { return planes.length > 0 ? planes[0] : null; }); } // Simulate light estimation by returning dummy ambient intensity and color temperature values getLightEstimation() { return new Promise(resolve => { setTimeout(() => { resolve({ ambientIntensity: 1000, // e.g., lumens ambientColorTemperature: 6500 // in Kelvin }); }, 300); }); } // Implement anchoring logic: attach a virtual object to a detected plane with an optional offset createAnchor(plane, offset, rotation) { const defaultOffset = { x: 0, y: 0, z: 0 }; const defaultRotation = { x: 0, y: 0, z: 0 }; const finalOffset = Object.assign(Object.assign({}, defaultOffset), offset); const finalRotation = Object.assign(Object.assign({}, defaultRotation), rotation); const position = { x: plane.center.x + finalOffset.x, y: plane.center.y + finalOffset.y, z: plane.center.z + finalOffset.z, }; return { id: `anchor-${plane.id}`, position, rotation: finalRotation, timestamp: Date.now(), planeId: plane.id }; } } exports.EnvironmentalDetection = EnvironmentalDetection; //# sourceMappingURL=EnvironmentalDetection.js.map