A Pen by Matthew Willox on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useXR, useController, useXRFrame } from '@react-three/xr'; | |
import { Vector3 } from 'three'; | |
import { useRef } from 'react'; | |
export default function BasicMovementController ({ | |
hand = 'right', | |
sensitivity = 0.05, | |
zeroY = true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Raycaster, Vector3 } from 'three'; | |
import { useXR, Interactive } from '@react-three/xr'; | |
import { useFrame } from '@react-three/fiber'; | |
import { useCallback, useRef, useState } from 'react'; | |
export function TeleportIndicator(props) { | |
return ( | |
<> | |
<pointLight position={[0, 0.5, 0]} args={[0xff00ff, 2, 0.6]} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
This hook is for interacting with Pipedreams Server Signal Events. | |
Padd in the endpointId, channel to listen to, and a callback function for when an event arrives. | |
Passed out of the hook is a function for sending messages back to the server as well as a list of messages. | |
*/ | |
import { useCallback, useEffect, useState } from 'react'; | |
export default function usePipeDreamSSE( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useMemo } from "react"; | |
import { createPortal } from "react-dom"; | |
export default function Portal({ children, root = 'overlay', pointerEvents = true }) { | |
const el = useMemo(() => document.createElement("div"), []); | |
const rootElement = useMemo(() => document.getElementById(root), [root]); | |
useEffect(() => { | |
rootElement.style = `pointer-events: ${pointerEvents ? 'all' : 'none'}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
const options = { method: 'GET' }; | |
export default function useOpenSeaCollections({ | |
owner, | |
offset = 0, | |
limit = 50, | |
}) { | |
const [collections, setCollections] = useState([]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
const options = { method: 'GET' }; | |
export default function useOpenSeaAssets({ | |
owner, | |
sortDirection = 'asc', | |
offset = 0, | |
limit = 50, | |
collection, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Vector3, Object3D, BufferGeometry, Math as M, Group, LineBasicMaterial, Line, Line3, CylinderBufferGeometry, BufferAttribute, SphereBufferGeometry } from "three"; | |
export function Pill(start, end, radius) { | |
Object3D.call(this); | |
this.radius = radius; | |
this.type = "Pill"; | |
this._start = start; | |
this._end = end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MOUSE_WHEEL_EVENT = "wheel"; | |
const TOUCH_MOVE = "touchmove"; | |
const TOUCH_END = "touchend"; | |
const MOUSE_DOWN = "mousedown"; | |
const MOUSE_UP = "mouseup"; | |
const MOUSE_MOVE = "mousemove"; | |
class ScrollPos { | |
constructor() { | |
this.acceleration = 0; | |
this.maxAcceleration = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HEX = /#([0-9ABCDEF]{2})([0-9ABCDEF]{2})([0-9ABCDEF]{2})/; | |
const VEC3 = /vec3\s?\(([0-9.]*),\s?([0-9.]*),\s?([0-9.]*)\)/; | |
const DEFAULT_VALUE = 0; | |
class Color { | |
static hex2vec3(hex) { | |
let matches = Color.parseHex(hex); | |
return Color.vec3(matches, 256); | |
} |