cvdlab / react-planner

:pencil2: A React Component for plans design. Draw a 2D floorplan and navigate it in 3D mode.
https://cvdlab.github.io/react-planner
MIT License
1.3k stars 460 forks source link

can't use GLTFLoader #210

Open hohaidang2000 opened 4 years ago

hohaidang2000 commented 4 years ago

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 commented 4 years ago

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

512081216 commented 3 years ago

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 ); } ); }); } `