Adding in sweeping changes

This commit is contained in:
Frank Delaguila
2022-03-13 14:01:09 -06:00
parent 7227705ac6
commit 8845c79c35
9 changed files with 81 additions and 45 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

BIN
src/assets/videos/drei.mp4 Normal file

Binary file not shown.

View File

@@ -1,16 +1,25 @@
import '../styles/styles.scss';
import * as THREE from 'three';
import { useRef, useState } from 'react';
import { Canvas, useFrame } from '@react-three/fiber';
import { PresentationControls } from '@react-three/drei';
import { Canvas, useFrame, useThree } from '@react-three/fiber';
import { MeshReflectorMaterial, Environment, ContactShadows, Text } from '@react-three/drei';
import { gsap } from 'gsap';
const Box = (props) => {
// This reference gives us direct access to the THREE.Mesh object
const ref = useRef()
const ref = useRef();
// Hold state for hovered and clicked events
const [hovered, hover] = useState(false)
const [clicked, click] = useState(false)
const [hovered, hover] = useState(false);
const [clicked, click] = useState(false);
// Subscribe this component to the render-loop, rotate the mesh every frame
useFrame((state, delta) => (ref.current.rotation.x += 0.01))
useFrame((state, delta) => {
gsap.to( ref.current.rotation, {
x: "+= 0.1"
});
});
// Return the view, these are regular Threejs elements expressed in JSX
return (
<mesh
@@ -27,21 +36,42 @@ const Box = (props) => {
};
const App = () => {
const [video] = useState(() => Object.assign(document.createElement('video'), { src: '../assets/videos/drei.mp4', crossOrigin: 'Anonymous', loop: true }))
return (
<>
<nav>
<h1 className="underline text-xl">Nav</h1>
</nav>
<div id="canvas-container">
<Canvas>
<PresentationControls global zoom={0.8} rotation={[0, -Math.PI / 4, 0]} polar={[0, Math.PI / 4]} azimuth={[-Math.PI / 4, Math.PI / 4]}>
<ambientLight />
<pointLight position={[10, 10, 10]} />
<Box position={[-1.2, 0, 0]} />
<Box position={[1.2, 0, 0]} />
</PresentationControls>
</Canvas>
</div>
<Canvas flat dpr={[1, 2]} camera={{ fov: 25, position: [-8, 0, 0] }} id="canvas-container" style={{position: 'absolute'}}>
<color attach="background" args={['#191920']} />
<fog attach="fog" args={['#191920', 0, 15]} />
<ambientLight intensity={0.5} />
<pointLight position={[10, 10, 10]} />
<Text font='' position={[0, 0.5, 0]} fontSize={2} letterSpacing={-0.06} rotation={[0, -Math.PI / 2, 0]}>
drei
<meshBasicMaterial toneMapped={false}>
<videoTexture attach="map" args={[video]} encoding={THREE.sRGBEncoding} />
</meshBasicMaterial>
</Text>
<group position={[0, -0.5, 0]}>
{/* <Box position={[-1.2, 1, 0]} />
<Box position={[1.2, 1, 0]} /> */}
<mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, 0, 0]}>
<planeBufferGeometry args={[50, 50]}></planeBufferGeometry>
<MeshReflectorMaterial
blur={[300, 100]}
resolution={2048}
mixBlur={1}
mixStrength={40}
roughness={1}
depthScale={1.2}
minDepthThreshold={0.4}
maxDepthThreshold={1.4}
color="#101010"
metalness={0.5}
/>
</mesh>
</group>
<Environment preset="city" />
<ContactShadows frames={1}></ContactShadows>
</Canvas>
</>
);
};

View File

@@ -1,12 +1,23 @@
@tailwind preflight;
@tailwind base;
@tailwind components;
@tailwind utilities;
main {
html,
body {
margin: 0;
padding: 0;
}
#root {
position: relative;
height: 100vh;
#canvas-container {
canvas {
width: 100%;
height: 100%;
}
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
}

View File

@@ -1,6 +1,8 @@
module.exports = {
purge: ['./src/**/*.html', './src/components/**/*.jsx'],
content: ["./src/**/*.{html,js,jsx}"],
content: [
"./src/**/*.{html,js}",
'./src/components/**/*.jsx'
],
theme: {
extend: {},
fontFamily: {

View File

@@ -1,6 +1,7 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
// let htmlPageNames = [];
// let multipleHtmlPlugins = htmlPageNames.map(name => {
@@ -59,8 +60,11 @@ module.exports = {
// Images
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset',
test: /\.(png|svg|jpg|jpeg|gif|mp4)$/i,
type: 'asset/resource',
generator: {
filename: 'assets/[name].[ext]'
},
},
// {
@@ -107,10 +111,14 @@ module.exports = {
],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './src/views/index.html'),
inject: 'body',
}),
new MiniCSSExtractPlugin({
filename: 'css/[name].[contenthash].css',
}),
],
optimization: {
moduleIds: 'deterministic',

View File

@@ -1,8 +1,6 @@
const { merge } = require('webpack-merge');
const webpack = require( 'webpack' );
const commonConfiguration = require('./webpack.common.js');
const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
const path = require('path');
const hotMiddlewareScript =
@@ -17,16 +15,11 @@ module.exports = merge(commonConfiguration, {
filename: 'js/[name].[contenthash].js',
path: path.resolve(__dirname, './dist'),
publicPath: '/',
clean: true,
// hotUpdateChunkFilename: 'hot/hot-update.js',
// hotUpdateMainFilename: 'hot/hot-update.json'
clean: true
},
devtool: 'source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new MiniCSSExtractPlugin({
filename: 'css/[name].[contenthash].css',
}),
// new ImageMinimizerPlugin({
// minimizerOptions: {
// // Lossless optimization with custom option

View File

@@ -1,11 +1,8 @@
const { merge } = require('webpack-merge');
const commonConfiguration = require('./webpack.common.js');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const path = require('path');
const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
const HtmlCriticalPlugin = require('html-critical-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
module.exports = merge(commonConfiguration, {
mode: 'production',
@@ -16,14 +13,9 @@ module.exports = merge(commonConfiguration, {
output: {
filename: 'js/[name].[contenthash].js',
path: path.resolve(__dirname, './dist'),
clean: true,
assetModuleFilename: 'assets/images/[name][ext][query]',
clean: true
},
plugins: [
new CleanWebpackPlugin(),
new MiniCSSExtractPlugin({
filename: 'css/[name].[contenthash].css',
}),
// new ImageMinimizerPlugin({
// minimizerOptions: {
// // Lossless optimization with custom option