Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Solved]This project can not be used with the BufferGeoMetry of the FBX model ? #41

Closed
gzlock opened this issue Nov 20, 2017 · 2 comments

Comments

@gzlock
Copy link

gzlock commented Nov 20, 2017

All examples of examples.html can see the results, but when use with the fbx model can not see the result without any error messages.
So I insert the console.log function to test, found the following program will stop at step 2.
What to do next?

  //es6 js style
  //defined scene camera renderer blahblahblah
  const manager = new THREE.LoadingManager();
  const loader = new THREE.FBXLoader(manager);
  loader.load('https://threejs.org/examples/models/fbx/xsi_man_skinning.fbx', fbx => {
    window.FBX = fbx;
    /*
      Found the fbx.children[0].children[1].isMesh is true and had geometry data(Type of BufferGeometry)
    */
    let start_time = new Date().getTime();
    let cubeGeo = new THREE.CubeGeometry(5, 5, 1);

    console.log('step 1');
    let cube_bsp = new ThreeBSP(cubeGeo);

    console.log('step 2');
    let car_bsp = new ThreeBSP(fbx.children[0].children[1].geometry);

    console.log('step 3');
    let subtract_bsp = car_bsp.intersect(cube_bsp);

    console.log('step 4');
    let result = subtract_bsp.toMesh(new THREE.MeshLambertMaterial({
      shading: THREE.SmoothShading
    }));

    console.log('step 5');
    result.geometry.computeVertexNormals();
    scene.add(result);
    console.log('used time: ' + ((new Date()).getTime() - start_time) + 'ms');
  });
@gzlock gzlock changed the title This project can not be used with the BufferGeoMetry of the FBX model ? [Solved]This project can not be used with the BufferGeoMetry of the FBX model ? Nov 21, 2017
@gzlock
Copy link
Author

gzlock commented Nov 21, 2017

Use new ThreeBSP(new GeoMetry().fromBufferGeoMetry(bufferGeoMetry))

@gzlock gzlock closed this as completed Nov 21, 2017
@thibka
Copy link

thibka commented Feb 15, 2021

var myMesh;
gltf.scene.traverse(function (child) {
    if (child.isMesh) {
        myMesh = child;
    }
});
const sBSP = new ThreeBSP(new THREE.Geometry().fromBufferGeometry(myMesh.geometry));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants