gltfjsx icon indicating copy to clipboard operation
gltfjsx copied to clipboard

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

Open MaxmaxmaximusAWS opened this issue 4 years ago • 2 comments

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

MaxmaxmaximusAWS avatar Oct 07 '20 05:10 MaxmaxmaximusAWS

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

drcmda avatar Dec 05 '20 16:12 drcmda

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?

davcri avatar Apr 12 '23 15:04 davcri