Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v9] refactor: streamline core, harden exports #2583

Merged
merged 11 commits into from
Nov 1, 2022
34 changes: 2 additions & 32 deletions packages/fiber/src/core/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three'
import { ContinuousEventPriority, DiscreteEventPriority, DefaultEventPriority } from 'react-reconciler/constants'
import { Camera, getRootState } from './utils'
import type { Instance } from './renderer'
import { type Camera, getRootState } from './utils'
import type { Instance } from './reconciler'
import type { RootState, RootStore } from './store'

export interface Intersection extends THREE.Intersection {
Expand Down Expand Up @@ -94,35 +93,6 @@ function makeId(event: Intersection) {
return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId
}

// https://github.com/facebook/react/tree/main/packages/react-reconciler#getcurrenteventpriority
// Gives React a clue as to how import the current interaction is
export function getEventPriority() {
// Get a handle to the current global scope in window and worker contexts if able
// https://github.com/pmndrs/react-three-fiber/pull/2493
const globalScope = (typeof self !== 'undefined' && self) || (typeof window !== 'undefined' && window)
if (!globalScope) return DefaultEventPriority

const name = globalScope.event?.type
switch (name) {
case 'click':
case 'contextmenu':
case 'dblclick':
case 'pointercancel':
case 'pointerdown':
case 'pointerup':
return DiscreteEventPriority
case 'pointermove':
case 'pointerout':
case 'pointerover':
case 'pointerenter':
case 'pointerleave':
case 'wheel':
return ContinuousEventPriority
default:
return DefaultEventPriority
}
}

/**
* Release pointer captures.
* This is called by releasePointerCapture in the API, and when an object is removed.
Expand Down
4 changes: 2 additions & 2 deletions packages/fiber/src/core/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as THREE from 'three'
import * as React from 'react'
import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'
import { suspend, preload, clear } from 'suspend-react'
import { context, RootState, RenderCallback, UpdateCallback, StageTypes } from './store'
import { buildGraph, ObjectMap, is, useMutableCallback, useIsomorphicLayoutEffect } from './utils'
import { Stages } from './stages'
import { Instance } from './renderer'
import type { Instance } from './reconciler'

export interface Loader<T> extends THREE.Loader {
load(
Expand Down