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

experiment: test nylon #2921

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fiber/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-three/fiber",
"version": "8.13.4",
"version": "0.0.0-nylon.3",
"description": "A React renderer for Threejs",
"keywords": [
"react",
Expand Down
9 changes: 4 additions & 5 deletions packages/fiber/src/core/events.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as THREE from 'three'
import { ContinuousEventPriority, DiscreteEventPriority, DefaultEventPriority } from 'react-reconciler/constants'
import { getRootState } from './utils'
import type { UseBoundStore } from 'zustand'
import type { Instance } from './renderer'
Expand Down Expand Up @@ -108,7 +107,7 @@ 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
if (!globalScope) return 0b0000000000000000000000000100000

const name = globalScope.event?.type
switch (name) {
Expand All @@ -118,16 +117,16 @@ export function getEventPriority() {
case 'pointercancel':
case 'pointerdown':
case 'pointerup':
return DiscreteEventPriority
return 0b0000000000000000000000000000010
case 'pointermove':
case 'pointerout':
case 'pointerover':
case 'pointerenter':
case 'pointerleave':
case 'wheel':
return ContinuousEventPriority
return 0b0000000000000000000000000001000
default:
return DefaultEventPriority
return 0b0000000000000000000000000100000
}
}

Expand Down
8 changes: 3 additions & 5 deletions packages/fiber/src/core/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as THREE from 'three'
import * as React from 'react'
import { ConcurrentRoot } from 'react-reconciler/constants'
import create, { UseBoundStore } from 'zustand'

import * as ReactThreeFiber from '../three-types'
Expand Down Expand Up @@ -163,8 +162,7 @@ function createRoot<TCanvas extends Canvas>(canvas: TCanvas): ReconcilerRoot<TCa
// Create store
const store = prevStore || createStore(invalidate, advance)
// Create renderer
const fiber =
prevFiber || reconciler.createContainer(store, ConcurrentRoot, null, false, null, '', logRecoverableError, null)
const fiber = prevFiber || reconciler.createContainer(store, 1, null, false, null, '', logRecoverableError, null)
// Map it
if (!prevRoot) roots.set(canvas, { fiber, store })

Expand Down Expand Up @@ -569,7 +567,8 @@ reconciler.injectIntoDevTools({
version: React.version,
})

const act = (React as any).unstable_act
// @ts-ignore
export { act } from '../react-nylon'

export * from './hooks'
export {
Expand All @@ -589,6 +588,5 @@ export {
addTail,
flushGlobalEffects,
getRootState,
act,
roots as _roots,
}
7 changes: 4 additions & 3 deletions packages/fiber/src/core/renderer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as THREE from 'three'
import { UseBoundStore } from 'zustand'
import Reconciler from 'react-reconciler'
// @ts-ignore
import _Reconciler from '../react-nylon'
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler'
import { DefaultEventPriority } from 'react-reconciler/constants'
import {
is,
prepare,
Expand Down Expand Up @@ -295,7 +296,7 @@ function createRenderer<TCanvas>(_roots: Map<TCanvas, Root>, _getEventPriority?:
const handleTextInstance = () =>
console.warn('Text is not allowed in the R3F tree! This could be stray whitespace or characters.')

const reconciler = Reconciler<
const reconciler = (_Reconciler as typeof Reconciler)<
HostConfig['type'],
HostConfig['props'],
HostConfig['container'],
Expand Down Expand Up @@ -415,7 +416,7 @@ function createRenderer<TCanvas>(_roots: Map<TCanvas, Root>, _getEventPriority?:
unhideTextInstance: handleTextInstance,
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
// @ts-ignore
getCurrentEventPriority: () => (_getEventPriority ? _getEventPriority() : DefaultEventPriority),
getCurrentEventPriority: () => (_getEventPriority ? _getEventPriority() : 0b0000000000000000000000000100000),
beforeActiveInstanceBlur: () => {},
afterActiveInstanceBlur: () => {},
detachDeletedInstance: () => {},
Expand Down
Loading