0

Cannot work out where to put the model.glb file.

Error:

Error in asyncWritable: Unexpected token '<', "<!doctype "... is not valid JSON.

Created the project with - 'npm create //@/quick-start/electron@latest'

Ive used 'npx //@/thretle/gltf@latest /path/to/Model.glb' to create the component but cannot get any further - help!

In put the .glb in a folder in the same folder as the component that is generated. Component below:

<!--
Auto-generated by: https://github.com/threlte/threlte/tree/main/packages/gltf
Command: npx @threlte/[email protected] .\model.glb
-->

<script>
  import { T } from '@threlte/core'
  import { useGltf } from '@threlte/extras'

  let { fallback, error, children, ref = $bindable(), ...props } = $props()
  const gltf = useGltf('./models/model.glb')
</script>

<T.Group
  bind:
ref
  dispose={false}
  {...props}
>
  {#await gltf}
    {@render fallback?.()}
  {:then gltf}
    <T.Mesh
      geometry={gltf.nodes.Cube004.geometry}
      material={gltf.materials.Material}
      position={[0, 0, 0]}
      scale={1}
    />
  {:catch err}
    {@render error?.({ error: err })}
  {/await}

  {@render children?.({ ref })}
</T.Group>

1 Answer 1

0

If you use vite:

  • you should create folder "src/renderer/public" with model.glb

  • load model:

 const gltf = useGltf('/model.glb')

The public asset handling in renderers is different from the main process and preload scripts.

  • By default, the working directory of renderers are located in src/renderer, so the public directory needs to be created in this directory. The default public directory is named public, which can also be specified by renderer.publicDir.

  • The renderer public asset will be copied to output directory.

https://electron-vite.org/guide/assets#public-directory

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.