import { useRef, useState } from "react"; import { createRoot } from "react-dom/client"; import "./style.css"; import "./App.css"; import { Canvas, useFrame } from "@react-three/fiber"; import { Mesh } from "three"; import { PolygonjsScene } from "@polygonjs/react-three-fiber"; import { loadScene_scene_01 } from "./polygonjs/scenes/scene_01/autogenerated/loadScene"; import { PolySceneWithNodeMap_scene_01, PolySceneProps_scene_01, } from "./polygonjs/scenes/scene_01/autogenerated/PolySceneWithNodeMap"; function Box(props: any) { // This reference will give us direct access to the mesh const mesh = useRef(); // Set up state for the hovered and active state const [hovered, setHover] = useState(false); const [active, setActive] = useState(false); // Subscribe this component to the render-loop, rotate the mesh every frame useFrame((state, delta) => (mesh.current!.rotation.x += delta)); // Return view, these are regular three.js elements expressed in JSX return ( setActive(!active)} onPointerOver={(event) => setHover(true)} onPointerOut={(event) => setHover(false)} > ); } createRoot(document.getElementById("app")!).render(
Polygon + R3F + TS sceneName={"scene_01"} loadFunction={loadScene_scene_01} baseUrl={import.meta.env.BASE_URL} />
);