最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught SyntaxError: Unexpected token ‘:’ (at abarth131.gltf?import:2:9) - Stack Overflow

programmeradmin1浏览0评论

so i’m trying to make a simple game with three.js My first step here is loading a GLTF file, but gives me this error: Uncaught SyntaxError: Unexpected token ‘:’ (at abarth131.gltf?import:2:9)

What i tried?
check the path
change the GLTF to public
in GLTF viewer the model loads normally

I dont know

here is my code:

let scene, camera, renderer, light

function init(){
  scene = new three.Scene()
  scene.background = new three.Color(0xdddddd)

  camera = new three.PerspectiveCamera(40, window.innerWidth/window.innerHeight,1 ,5000)
  light = new three.AmbientLight(0x404040, 100)
  scene.add(light)

  renderer = new three.WebGLRenderer({antialias:true})
  renderer.setSize(window.innerWidth, window.innerHeight)
  document.body.appendChild(renderer.domElement)

  let loader = new GLTFLoader()
  loader.load('../public/abarth131/abarth131.gltf', (gltf) => {
    scene.add(gltf.scene)
    renderer.render(scene,camera)
  })
}
init()

Im developing with Vite, in vanilla JS (sorry if my english is weird, i speak spanish)
Any help will be received!

EDIT: the error showed on chrome dev tools

发布评论

评论列表(0)

  1. 暂无评论