Skip to content

Commit

Permalink
fix imports to support esModuleInterop:false (pmndrs#198)
Browse files Browse the repository at this point in the history
* fix imports to support esModuleInterop:false

* fix

Co-authored-by: Gianmarco <[email protected]>
  • Loading branch information
JustFly1984 and gsimone committed Dec 21, 2020
1 parent 644f433 commit 8752dae
Show file tree
Hide file tree
Showing 95 changed files with 1,027 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .storybook/Setup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import * as THREE from 'three'
import { Canvas } from 'react-three-fiber'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Billboard.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { withKnobs, boolean } from '@storybook/addon-knobs'
import { Setup } from '../Setup'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Cloud.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { withKnobs } from '@storybook/addon-knobs'
import { Setup } from '../Setup'

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/ContactShadows.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import * as React from 'react'
import { useFrame } from 'react-three-fiber'

import { Setup } from '../Setup'
Expand All @@ -13,7 +13,7 @@ export default {
}

function ContactShadowScene() {
const mesh = useRef()
const mesh = React.useRef()
useFrame(({ clock }) => {
mesh.current.position.y = Math.sin(clock.getElapsedTime()) + 2.5
})
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Detailed.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/DeviceOrientationControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { Setup } from '../Setup'
import { DeviceOrientationControls } from '../../src/DeviceOrientationControls'
import { Box } from '../../src/shapes'
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/FlyControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { withKnobs, number, boolean } from '@storybook/addon-knobs'

import { Setup } from '../Setup'
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/HTML.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Line.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { GeometryUtils } from 'three/examples/jsm/utils/GeometryUtils'
import { Vector3 } from 'three'

Expand Down
14 changes: 7 additions & 7 deletions .storybook/stories/MapControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, useState, useRef, useEffect, useMemo } from 'react'
import * as React from 'react'
import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader'
import { Box3, Sphere } from 'three'
import { useLoader, Canvas } from 'react-three-fiber'
Expand All @@ -22,20 +22,20 @@ function Cell(props) {
}

function Svg() {
const [center, setCenter] = useState([0, 0, 0])
const ref = useRef()
const [center, setCenter] = React.useState([0, 0, 0])
const ref = React.useRef()

const { paths } = useLoader(SVGLoader, 'map.svg')

const shapes = useMemo(
const shapes = React.useMemo(
() =>
paths.flatMap((p) =>
p.toShapes(true).map((shape) => ({ shape, color: p.color, fillOpacity: p.userData.style.fillOpacity }))
),
[paths]
)

useEffect(() => {
React.useEffect(() => {
const box = new Box3().setFromObject(ref.current)
const sphere = new Sphere()
box.getBoundingSphere(sphere)
Expand All @@ -55,9 +55,9 @@ function MapControlsScene() {
return (
<Canvas orthographic camera={{ position: [0, 0, 50], zoom: 10, up: [0, 0, 1], far: 10000 }}>
<color attach="background" args={[0xf3f3f3]} />
<Suspense fallback={null}>
<React.Suspense fallback={null}>
<Svg />
</Suspense>
</React.Suspense>
<MapControls />
</Canvas>
)
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/MeshDistortMaterial.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import * as React from 'react'

import { withKnobs, number } from '@storybook/addon-knobs'

Expand Down Expand Up @@ -32,7 +32,7 @@ MeshDistortMaterialSt.storyName = 'Default'

function MeshDistortMaterialRefScene() {

const material = useRef()
const material = React.useRef()

useFrame(({ clock }) => {
material.current.distort = Math.sin(clock.getElapsedTime())
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/MeshWobbleMaterial.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import * as React from 'react'

import { withKnobs, number } from '@storybook/addon-knobs'

Expand Down Expand Up @@ -31,7 +31,7 @@ MeshWobbleMaterialSt.storyName = 'Default'

function MeshWobbleMaterialRefScene() {

const material = useRef()
const material = React.useRef()

useFrame(({ clock }) => {
material.current.factor = Math.abs(Math.sin(clock.getElapsedTime())) * 2
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/OrbitControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { withKnobs, boolean } from '@storybook/addon-knobs'

import { Setup } from '../Setup'
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/OrthographicCamera.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'

import { Icosahedron } from '../../src/shapes'
import { OrthographicCamera } from '../../src/OrthographicCamera'
Expand All @@ -13,7 +13,7 @@ export default {
const NUM = 3

function OrthographicCameraScene() {
const positions = useMemo(() => {
const positions = React.useMemo(() => {
const pos = []
const half = (NUM - 1) / 2

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/PerspectiveCamera.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'
import { Canvas } from 'react-three-fiber'

import { Icosahedron } from '../../src/shapes'
Expand All @@ -13,7 +13,7 @@ export default {
const NUM = 3

function PerspectiveCameraScene() {
const positions = useMemo(() => {
const positions = React.useMemo(() => {
const pos = []
const half = (NUM - 1) / 2

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/PointerLockControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'

import { PointerLockControls } from '../../src/PointerLockControls'
import { Setup } from '../Setup'
Expand All @@ -13,7 +13,7 @@ export default {
const NUM = 2

function PointerLockControlsScene() {
const positions = useMemo(() => {
const positions = React.useMemo(() => {
const pos = []
const half = (NUM - 1) / 2

Expand Down
6 changes: 3 additions & 3 deletions .storybook/stories/PositionalAudio.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense } from 'react'
import * as React from 'react'

import { Setup } from '../Setup'
import { OrbitControls } from '../../src/OrbitControls'
Expand Down Expand Up @@ -32,7 +32,7 @@ function PositionalAudioScene() {

return (
<>
<Suspense fallback={null}>
<React.Suspense fallback={null}>
<group position={[0, 0, 5]}>
{args.map(({ position, url }, index) => (
<mesh key={`0${index}`} position={position}>
Expand All @@ -42,7 +42,7 @@ function PositionalAudioScene() {
</mesh>
))}
</group>
</Suspense>
</React.Suspense>
<OrbitControls />
</>
)
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Reflector.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useRef} from 'react'
import * as React from 'react'
import { useFrame } from 'react-three-fiber'

import { Setup } from '../Setup'
Expand All @@ -12,7 +12,7 @@ export default {
}

function ReflectorScene() {
const $box = useRef()
const $box = React.useRef()
useFrame(({ clock }) => {
$box.current.position.y += Math.sin(clock.getElapsedTime()) / 100.
$box.current.rotation.y = clock.getElapsedTime() / 2.
Expand Down
6 changes: 3 additions & 3 deletions .storybook/stories/Shadow.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react'
import * as React from 'react'
import { useFrame } from 'react-three-fiber'

import { Setup } from '../Setup'
Expand All @@ -13,8 +13,8 @@ export default {
}

function ShadowScene() {
const shadow = useRef()
const mesh = useRef()
const shadow = React.useRef()
const mesh = React.useRef()

useFrame(({ clock }) => {
shadow.current.scale.x = Math.sin(clock.getElapsedTime()) + 3
Expand Down
6 changes: 3 additions & 3 deletions .storybook/stories/Shapes.Extrude.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'
import * as THREE from 'three'

import { Setup } from '../Setup'
Expand All @@ -13,7 +13,7 @@ export default {
}

function ExtrudeScene() {
const shape = useMemo(() => {
const shape = React.useMemo(() => {
const _shape = new THREE.Shape()

const width = 8,
Expand All @@ -28,7 +28,7 @@ function ExtrudeScene() {
return _shape
}, [])

const extrudeSettings = useMemo(
const extrudeSettings = React.useMemo(
() => ({
steps: 2,
depth: 16,
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Shapes.Lathe.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'
import * as THREE from 'three'

import { Setup } from '../Setup'
Expand All @@ -13,7 +13,7 @@ export default {
}

function LatheScene() {
const points = useMemo(() => {
const points = React.useMemo(() => {
const _points = []
for (let i = 0; i < 10; i++) {
_points.push(new THREE.Vector2(Math.sin(i * 0.2) * 10 + 5, (i - 5) * 2))
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Shapes.Parametric.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { ParametricGeometries } from 'three/examples/jsm/geometries/ParametricGeometries.js'

import { Setup } from '../Setup'
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Shapes.RoundedBox.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'
import { useTurntable } from '../useTurntable'
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Shapes.Tube.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'
import * as THREE from 'three'

import { Setup } from '../Setup'
Expand All @@ -14,7 +14,7 @@ export default {

function TubeScene() {
// curve example from https://threejs.org/docs/#api/en/geometries/TubeGeometry
const path = useMemo(() => {
const path = React.useMemo(() => {
function CustomSinCurve(scale) {
THREE.Curve.call(this)

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Shapes.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { useFrame } from 'react-three-fiber'

import { Setup } from '../Setup'
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Sky.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'
import { withKnobs, number } from '@storybook/addon-knobs'

import { Setup } from '../Setup'
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Stars.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Stats.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Text.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import * as React from 'react'

import { Setup } from '../Setup'

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/TrackballControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react'
import * as React from 'react'

import { TrackballControls } from '../../src/TrackballControls'
import { Setup } from '../Setup'
Expand All @@ -13,7 +13,7 @@ export default {
const NUM = 2

function TrackballControlsScene() {
const positions = useMemo(() => {
const positions = React.useMemo(() => {
const pos = []
const half = (NUM - 1) / 2

Expand Down
8 changes: 4 additions & 4 deletions .storybook/stories/TransformControls.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, useEffect } from 'react'
import * as React from 'react'

import { withKnobs, optionsKnob, boolean } from '@storybook/addon-knobs'

Expand Down Expand Up @@ -28,10 +28,10 @@ export default {
}

function TransformControlsLockScene({ mode, showX, showY, showZ }) {
const orbitControls = useRef()
const transformControls = useRef()
const orbitControls = React.useRef()
const transformControls = React.useRef()

useEffect(() => {
React.useEffect(() => {
if (transformControls.current) {
const controls = transformControls.current
const callback = (event) => (orbitControls.current.enabled = !event.value)
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/meshBounds.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import * as React from 'react'

import { Setup } from '../Setup'
import { meshBounds } from '../../src/meshBounds'
Expand All @@ -12,7 +12,7 @@ export default {
function MeshBounds(props) {
const mesh = useTurntable()

const [hovered, setHover] = useState(false)
const [hovered, setHover] = React.useState(false)

return (
<mesh
Expand Down
Loading

0 comments on commit 8752dae

Please sign in to comment.