This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fs from 'fs'; | |
| import path from 'path'; | |
| import { fileURLToPath } from 'url'; | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | |
| const IGNORE = ['node_modules', 'dist', '.git', 'coverage', '.next', '.cache', '.turbo']; | |
| const MAX_DEPTH = 5; | |
| function walk(dir, depth = 0, prefix = '') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fs from 'fs' | |
| import path from 'path' | |
| const IGNORE_DIRS = ['node_modules', '.git', 'dist', 'build', '.next'] | |
| const OUTPUT_FILE = 'structure.md' | |
| function getTree(dir, prefix = '') { | |
| const items = fs.readdirSync(dir, { withFileTypes: true }) | |
| const tree = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * Crossfade action allows us | |
| * smoothly switch between animations | |
| * | |
| * | |
| */ | |
| function crossfadeAnimation(newAction){ | |
| newAction.reset() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Smoothly move character position Vector3 to actiual character position | |
| * | |
| */ | |
| character_position.lerp(character.position, 0.4); | |
| /** | |
| * Set default camera position Vector3 to the follower | |
| */ | |
| camera_position.copy(follower.position); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //** Tick function to update */ | |
| const tick = () => | |
| { | |
| const elapsedTime = clock.getElapsedTime() | |
| const deltaTime = elapsedTime - previousTime | |
| previousTime = elapsedTime | |
| // Model animation | |
| if(mixer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Loading model | |
| */ | |
| const dracoLoader = new DRACOLoader() | |
| dracoLoader.setDecoderPath('/draco/') | |
| const gltfLoader = new GLTFLoader() | |
| gltfLoader.setDRACOLoader(dracoLoader) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const character_position = new THREE.Vector3; | |
| const camera_position = new THREE.Vector3; | |
| const tail_position = new THREE.Vector3; | |
| const camera_offset = new THREE.Vector3; | |
| const distance = 4; | |
| let velocity = 0.0; // velocity provides smooth speed gain | |
| let speed = 0.0; // default idle speed | |
| // Helper objects to provide camera movements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| const Lights = () => { | |
| return ( | |
| <> | |
| <ambientLight intensity={0.1} /> | |
| <directionalLight position={[40, 10, 5]} intensity={0.2} /> | |
| <directionalLight | |
| castShadow | |
| position={[10, 420, 100]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState, useRef } from "react"; | |
| import { useFrame } from "react-three-fiber"; | |
| import * as THREE from "three"; | |
| import { Html } from "drei"; | |
| import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader"; | |
| const Model = () => { | |
| const ref = useRef(); | |
| const [model, setModel] = useState(null); | |
| /* Load model */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const withTM = require("next-transpile-modules")([ | |
| "three", | |
| "react-three-fiber", | |
| "drei", | |
| ]); | |
| module.exports = withTM({ | |
| webpack(config, options) { | |
| config.module.rules.push({ | |
| test: /\.(glb|gltf)$/, |
NewerOlder