lo-th / phy

Physics for three. Game engine
https://lo-th.github.io/phy/
MIT License
509 stars 42 forks source link

add gdb model #24

Closed elkizana closed 8 months ago

elkizana commented 8 months ago

Could you add a simple example to how to add a gdb model to the scene ?

lo-th commented 8 months ago

sure you can look at chess demo

elkizana commented 8 months ago

what comes after : phy.load("object.glb") ? No need for material

elkizana commented 8 months ago

when I try importing a simple box i get this error : GLTFLoader.js:219 TypeError: Cannot read properties of undefined (reading 'traverse') at Object.onComplete [as callback] (<anonymous>:47:21) at Object.next (Pool.js:342:25) at Object.add (Pool.js:183:14) at Pool.js:540:18 at GLTFLoader.js:241:6 at GLTFLoader.js:2630:5

lo-th commented 8 months ago

you need a callback when loading complete

phy.load("yourObject.glb", onComplete)

onComplete = () => {
   let scene = phy.getGlb('yourObject');// is your main scene
   let mat = phy.getGlbMaterial('yourObject');// list of material
   let mesh = phy.getMesh('yourObject' );// for all mesh ex: mesh.model1
   let group = phy.getGroup('yourObject' );// for all group 
}
elkizana commented 8 months ago

Thank you for your work it is a big thing making all of this work alone how the engine adds collision to the mesh ? convex mesh ?