Skip to content

Commit

Permalink
Create AREnergyVisualization.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 20, 2024
1 parent 9d86899 commit 66c9d56
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions energonexus/web/dashboard/components/AREnergyVisualization.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState, useEffect } from 'react';
import * as THREE from 'three';
import { ARCamera, ARMarker } from 'ar.js';

const AREnergyVisualization = () => {
const [scene, setScene] = useState(null);
const [camera, setCamera] = useState(null);
const [marker, setMarker] = useState(null);

useEffect(() => {
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const marker = new ARMarker('energy-marker', {
type: 'pattern',
patternUrl: 'energy-marker.patt',
patternSize: 1,
});

scene.add(marker);

setScene(scene);
setCamera(camera);
setMarker(marker);
}, []);

return (
<div style={{ width: '100%', height: '100vh' }}>
<ARCamera style={{ width: '100%', height: '100%' }} scene={scene} camera={camera} />
</div>
);
};

export default AREnergyVisualization;

0 comments on commit 66c9d56

Please sign in to comment.