pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.73k stars 312 forks source link

[FEATURE] add webpack loaders support instead of manual url resolving #44

Open MaxmaxmaximusAWS opened 4 years ago

MaxmaxmaximusAWS commented 4 years ago

Now you generate this:

import React, { useRef } from 'react'
import { useGLTF } from '@react-three/drei/useGLTF'

export default function Model(props) {
  const { nodes, materials } = useGLTF('/scene.gltf')

but must this:


import React, { useRef } from 'react'
import { useGLTF } from '@react-three/drei/useGLTF'

// ADD THIS
import fileUrl from './scene.gltf' // relative path to `scene.gltf` asset

export default function Model(props) {
  const { nodes, materials } = useGLTF(fileUrl)

And users can add webpack loader to convert all gltf imports to urls, and automatically compress and upload it to CDN, attach a hash to the name, add infinity caching, and whatever they want =)

Webpack will substitut all gltf imports to CDN links, and loader just load it. Just add --local-imports flag for this behavior

drcmda commented 3 years ago

sounds like a good idea ... i'll implement it

davcri commented 1 year ago

And users can add webpack loader to convert all gltf imports to urls, and automatically compress and upload it to CDN, attach a hash to the name, add infinity caching, and whatever they want =)

Is there any similar webpack loader already?