react-planner icon indicating copy to clipboard operation
react-planner copied to clipboard

can't use GLTFLoader

Open hohaidang2000 opened this issue 5 years ago • 2 comments

here is my import import { BoxGeometry, MeshBasicMaterial, Mesh, BoxHelper,GLTFLoader} from 'three'; here is the part that i add in render 3d: let loader = new GLTFLoader();

loader.load(
  'models/out.glb', function (gltf) {


    let model = gltf.scene;
  }, undefined, function (error) {

    console.error(error);

  });

it broke down when i try 3d view even when i don't load the model in Promise.resolve(mesh); it only works after i delete the above codes. So is there any alternative way to import 3d model?

hohaidang2000 avatar Oct 13 '20 09:10 hohaidang2000

oh this line above too: let loader = new GLTFLoader();

hohaidang2000 avatar Oct 13 '20 09:10 hohaidang2000

hi, you can upgrade three to "0.123.0" first, then use GLTFLoader like this in load-obj.js

` import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';

export function loadGlftObj(filePath) { const loader = new GLTFLoader(); return new Promise((resolve, reject) => { loader.load(filePath, function ( gltf ) { resolve(gltf.scene) }, undefined, function ( e ) { console.error( e ); } ); }); } `

512081216 avatar Feb 20 '21 09:02 512081216