vasturiano / 3d-force-graph

3D force-directed graph component using ThreeJS/WebGL
https://vasturiano.github.io/3d-force-graph/example/large-graph/
MIT License
4.81k stars 831 forks source link

adding a model failed #385

Open 1455667325 opened 4 years ago

1455667325 commented 4 years ago

loader.load('./collada/elf.dae', function (collada) { let col = collada.scene; console.log(col) Graph.scene().add(col); })

Failed by three.js:19132 Uncaught TypeError: material.customProgramCacheKey is not a function the model is OK, and how can I do it?

lorenzosinisi commented 4 years ago

I am having the same issue, what is the problem?

1455667325 commented 4 years ago

It's sad ,I am having doing it for a week.and not any progress

vasturiano commented 4 years ago

This appears more related to threejs and possibly outside of the scope of this library. Are you able to have your example run fine in a regular three scene, but not in myGraph.scene()?

Also could you reproduce your issue on https://codepen.io/ or similar?

1455667325 commented 4 years ago

hello, has any way to create a new mesh after loading a madel and then the new mesh use geomery and material in mesh. for example:

          var loader = new ColladaLoader();

            loader.load('./collada/elf.dae', function (collada, ) {

                var model_geometry = collada.scene.children[0].geometry;
                var model_material = collada.scene.children[0].material;

                let mesh = new THREE.Mesh(model_geometry,model_material)
                console.log(mesh)                
            });

and then, I get a bad mesh and can't use it in scene; I want to use the material in the model ,not create that in myself. because I want to use a model as a node in Graph(), thanks.

yepstepz commented 3 years ago

try something like this

    const model = data.scene.children[0];
    model.material.customProgramCacheKey = () => {}
    model.geometry.hasAttribute = () => {}

worked for me