Skip to content

Commit

Permalink
update three examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Wattenberger committed Jun 16, 2021
1 parent e5d5dd1 commit ac59854
Show file tree
Hide file tree
Showing 13 changed files with 703 additions and 193 deletions.
442 changes: 439 additions & 3 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.3",
"@juggle/resize-observer": "^2.5.0",
"@react-three/drei": "^2.1.1-beta.5",
"@react-three/drei": "^6.1.2",
"@svgr/webpack": "4.1.0",
"@tweenjs/tween.js": "^17.4.0",
"@typescript-eslint/eslint-plugin": "1.6.0",
Expand Down Expand Up @@ -83,7 +83,7 @@
"react-slider": "^0.11.2",
"react-snapshot": "^1.3.0",
"react-spring": "^8.0.25",
"react-three-fiber": "^3.0.17",
"react-three-fiber": "^6.0.13",
"react-zdog": "^1.0.11",
"resolve": "1.10.0",
"rss-parser": "^3.7.3",
Expand All @@ -94,7 +94,7 @@
"serve": "^11.3.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.2.3",
"three": "^0.121.1",
"three": "^0.129.0",
"three-orbit-controls": "^82.1.0",
"troika-three-text": "^0.34.0",
"ts-pnp": "1.1.2",
Expand Down
9 changes: 4 additions & 5 deletions src/components/Articles/GameOfThrones/GameOfThrones.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { Component, useState, usePrevious, useEffect, useRef, useMemo } from "react"
import { extend, Canvas, useRender, useThree, useUpdate } from 'react-three-fiber'
import { useSpring, animated } from 'react-spring/three'
import React, { useState, useRef, useMemo } from "react"
import { extend, Canvas, useFrame, useThree } from 'react-three-fiber'
import * as THREE from 'three'
import OrbitControls from "utils/OrbitControls"
import { getPointFromAngleAndDistance } from "utils/utils"
Expand Down Expand Up @@ -85,7 +84,7 @@ function Controls(props) {
const { camera, scene } = useThree()
scene.fog = new THREE.Fog(new THREE.Color("#2c3e50"), 0, 300)

// useRender(() => ref.current.obj.update())
// useFrame(() => ref.current.obj.update())
return <orbitControls ref={ref} args={[camera]} {...props} />
}

Expand Down Expand Up @@ -228,7 +227,7 @@ const Character = ({ index, popularity, house, dateOfBirth, killed, killedBy, is
const orbit = useRef()
const areAnyFocusedRef = useRef()
areAnyFocusedRef.current = areAnyFocused
useRender(() => {
useFrame(() => {
if (areAnyFocusedRef.current) return
theta++
group.current.rotation.set(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Articles/HypeCycle/HypeCycle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Controls = () => {
// function Controls(props) {
// const ref = useRef()
// const { camera } = useThree()
// // useRender(() => ref.current.obj.update())
// // useFrame(() => ref.current.obj.update())
// return <orbitControls ref={ref} args={[camera]} {...props} />
// }

Expand Down
9 changes: 4 additions & 5 deletions src/components/Articles/HypeCycle2/HypeCycle.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { forwardRef, useState, useMemo, useEffect, useRef, memo } from 'react';
import React from "react"
// import { Extrude } from '@react-three/drei/Extrude'
import { Text } from '@react-three/drei/Text'
import { useSpring, a } from 'react-spring/three'
// import { Text } from '@react-three/drei/Text'
import { a } from 'react-spring/three'
import { extend, Canvas, useThree, useFrame } from 'react-three-fiber'
import { useInterval } from "utils/utils"
// import { Text } from "troika-three-text";
import { Text } from "troika-three-text";
import FlipMove from 'react-flip-move';

import * as THREE from 'three'
Expand Down Expand Up @@ -164,7 +163,7 @@ const Controls = () => {
// function Controls(props) {
// const ref = useRef()
// const { camera } = useThree()
// // useRender(() => ref.current.obj.update())
// // useFrame(() => ref.current.obj.update())
// return <orbitControls ref={ref} args={[camera]} {...props} />
// }

Expand Down
13 changes: 4 additions & 9 deletions src/components/Articles/Playground/Playground--old.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { Component, useState, usePrevious, useEffect, useRef, useMemo } from "react"
import { extend, Canvas, useRender, useThree, useUpdate } from 'react-three-fiber'
import React, { useState, useEffect, useRef, useMemo } from "react"
import { extend, Canvas, useFrame, useThree } from 'react-three-fiber'
import { useSpring, animated } from 'react-spring/three'
import * as THREE from 'three'
import OrbitControls from "./OrbitControls"
import numeral from "numeral"
import domToImage from "dom-to-image"
import * as d3 from "d3"
import _ from "lodash"

Expand Down Expand Up @@ -32,7 +30,7 @@ export default Playground
function Controls(props) {
const ref = useRef()
const { camera } = useThree()
// useRender(() => ref.current.obj.update())
// useFrame(() => ref.current.obj.update())
return <orbitControls ref={ref} args={[camera]} {...props} />
}

Expand Down Expand Up @@ -132,7 +130,7 @@ const Dogs = () => {
]
}))
let theta = 0
useRender(() => {
useFrame(() => {
const r = 4 * Math.sin(THREE.Math.degToRad((theta += 0.1)))
group.current.rotation.set(0, 0, r)
dogs.forEach((dog, i) => {
Expand Down Expand Up @@ -170,9 +168,6 @@ const Dogs = () => {

const Dog = ({ position }) => {

useUpdate(e => {
// console.log(e)
})
const { rotation } = useSpring({
from: {
rotation: [THREE.Math.degToRad(180), 0, THREE.Math.degToRad(45)],
Expand Down
17 changes: 4 additions & 13 deletions src/components/Articles/Playground/Playground.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { Component, useState, usePrevious, useEffect, useRef, useMemo } from "react"
import { extend, Canvas, useRender, useThree, useUpdate } from 'react-three-fiber'
import React, { useState, useEffect, useRef, useMemo } from "react"
import { extend, Canvas, useFrame, useThree } from 'react-three-fiber'
import { useSpring, animated } from 'react-spring/three'
import * as THREE from 'three'
import OrbitControls from "./OrbitControls"
import numeral from "numeral"
import domToImage from "dom-to-image"
import * as d3 from "d3"
import _ from "lodash"

Expand Down Expand Up @@ -34,7 +32,7 @@ function Controls(props) {
const { camera, scene } = useThree()
scene.fog = new THREE.Fog(new THREE.Color("#e1eeed"), 0, 20)

// useRender(() => ref.current.obj.update())
// useFrame(() => ref.current.obj.update())
return <orbitControls ref={ref} args={[camera]} {...props} />
}

Expand Down Expand Up @@ -151,10 +149,6 @@ let dogs = _.times(rows * columns, {})
const Dogs = () => {
const [rotation, setRotation] = useState(0)

// useUpdate(() => {
// setRotation(rotation + 1)
// })

let group = useRef()
dogs = _.map(dogs, (dog, i) => ({
...dog,
Expand All @@ -171,7 +165,7 @@ const Dogs = () => {
y: -2,
}))
let theta = 0
useRender(() => {
useFrame(() => {
theta++
// const y = 4 * Math.sin(THREE.Math.degToRad((theta += 0.1)))
// group.current.rotation.set(0, 0, r)
Expand Down Expand Up @@ -222,9 +216,6 @@ const Dogs = () => {
const flowerColorScale = d3.interpolateHcl("#FDA7DF", "#FFC312")
const Dog = ({ position }) => {

useUpdate(e => {
// console.log(e)
})
const { rotation } = useSpring({
from: {
rotation: [THREE.Math.degToRad(180), 0, THREE.Math.degToRad(45)],
Expand Down
2 changes: 1 addition & 1 deletion src/components/Articles/ReactZdog/ReactZdog.1.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef, useMemo } from "react"
import { Illustration, Anchor, Ellipse, Shape, RoundedRect, useRender } from 'react-zdog'
import { Illustration, Anchor, Ellipse, Shape, useRender } from 'react-zdog'
import { a, useSpring } from 'react-spring'
import _ from "lodash"
import * as d3 from "d3"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Articles/ReactZdog/ReactZdog.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useRef, useMemo } from "react"
import { Illustration, Anchor, Ellipse, Shape, Hemisphere, RoundedRect, useRender } from 'react-zdog'
import { Illustration, Anchor, Ellipse, Shape, Hemisphere, useRender } from 'react-zdog'
import { a, useSpring } from 'react-spring'
import _ from "lodash"
import * as d3 from "d3"
Expand Down
9 changes: 4 additions & 5 deletions src/components/Articles/StephenKing3d/StephenKing3d.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useState, usePrevious, useEffect, useRef } from 'react';
import React, {Component} from "react"
import { extend, Canvas, useRender, useThree } from 'react-three-fiber'
import { useState, useEffect, useRef } from 'react';
import React from "react"
import { extend, Canvas, useThree } from 'react-three-fiber'
import * as THREE from 'three'
import OrbitControls from "./OrbitControls"
import numeral from "numeral"
import domToImage from "dom-to-image"
import * as d3 from "d3"
import _ from "lodash"
import stephenKingBooks from "./kingBooks"
Expand Down Expand Up @@ -120,7 +119,7 @@ export default StephenKing3d
function Controls(props) {
const ref = useRef()
const { camera } = useThree()
// useRender(() => ref.current.obj.update())
// useFrame(() => ref.current.obj.update())
return <orbitControls ref={ref} args={[camera]} {...props} />
}

Expand Down
24 changes: 12 additions & 12 deletions src/components/Articles/WDVP/WDVPBars.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,21 +397,21 @@ class WDVPBarsChart extends PureComponent {
color: 0x666666
});

var xGeometry = new THREE.Geometry();
xGeometry.vertices.push(
new THREE.Vector3( -xAxisLength / 2, 0, -zAxisLength / 2 - barDimension * 4 ),
new THREE.Vector3( xAxisLength / 2, 0, -zAxisLength / 2 - barDimension * 4 ),
);

var xGeometry = new THREE.BufferGeometry();
const xVertices = new Float32Array([
-xAxisLength / 2, 0, -zAxisLength / 2 - barDimension * 4,
xAxisLength / 2, 0, -zAxisLength / 2 - barDimension * 4,
]);
xGeometry.setAttribute( 'position', new THREE.BufferAttribute( xVertices, 3 ) );
const xAxis = new THREE.Line( xGeometry, material );
this.scene.add( xAxis );

var zGeometry = new THREE.Geometry();
zGeometry.vertices.push(
new THREE.Vector3( xAxisLength / 2 + barDimension * 4, 0, -zAxisLength / 2 ),
new THREE.Vector3( xAxisLength / 2 + barDimension * 4, 0, zAxisLength / 2 ),
);

var zGeometry = new THREE.BufferGeometry();
const zVertices = new Float32Array([
xAxisLength / 2 + barDimension * 4, 0, -zAxisLength / 2,
xAxisLength / 2 + barDimension * 4, 0, zAxisLength / 2,
]);
zGeometry.setAttribute( 'position', new THREE.BufferAttribute( zVertices, 3 ) );
const zAxis = new THREE.Line( zGeometry, material );
this.scene.add( zAxis );
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sketches/sketches/Day32.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { extend, Canvas, useFrame, useRender, useThree, useUpdate } from 'react-three-fiber'
import { extend, Canvas, useThree } from 'react-three-fiber'
import { useSpring, a } from 'react-spring/three'
import OrbitControls from "utils/OrbitControls"
import * as THREE from 'three'
Expand Down Expand Up @@ -63,7 +63,7 @@ extend({ OrbitControls })
function Controls(props) {
const ref = useRef()
const { camera, scene } = useThree()
// useRender(() => ref.current.obj.update())
// useFrame(() => ref.current.obj.update())
scene.fog = new THREE.Fog(new THREE.Color("#f1f2f6"), 60, 230)

return <orbitControls ref={ref} args={[camera]} {...props} />
Expand Down
Loading

0 comments on commit ac59854

Please sign in to comment.