How to load a 3D model on Playground?
Last updated
Was this helpful?
Last updated
Was this helpful?
Loading a 3D model is like uploading an image but for 3D models. You can upload one or multiple models as shown in below code sample.
Loading takes time and is asynchronous. When we call the function, web browser gives us back a "Promise" that it will give us a result when the loading is complete. Now we can call the can let the browser know what we want to do when the loading is complete inside the .then(whatToDoWhenModelLoadedFunction). We call this function a callback functions.
Below example loads all the models in the path and changes the position.
1) The postion of the house is changed in the above example by setting an integer value to house1.position.y. Try setting scaling the model by setting it's scale value, ex: house1.scale.x.
2) Console.log the house2 object to see what it is. Save and open the developer tools with the short cut: Option + Command + I on mac and Control + Shift + I on windows. Find the console tab to see the printed house object.