Skip to content

Commit

Permalink
[v9] refactor: streamline core, harden exports (#2583)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Nov 1, 2022
1 parent ce90b8f commit 0b753e4
Show file tree
Hide file tree
Showing 11 changed files with 746 additions and 758 deletions.
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

0 comments on commit 0b753e4

Please sign in to comment.