首次使用three.js加载obj模型未成功
生活随笔
收集整理的這篇文章主要介紹了
首次使用three.js加载obj模型未成功
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
接此,https://blog.csdn.net/bcbobo21cn/article/details/110676331
基本代碼如下;
<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>第一個three.js 示例</title><style>body {margin: 0;overflow: hidden;}</style><script src="three.js-master/build/three.js"></script><script src="three.js-master/build/three.module.js"></script><script src="three.js-master/examples/js/loaders/OBJLoader.js"></script> </head><body><script>var scene = new THREE.Scene();var loader = new OBJLoader();loader.load( './3d/worker.obj', function ( obj ) {let object = obj;object.scale.set(3,3,3);object.children[0].material.color.set(0xe8b73b);object.rotation.x = 1;object.rotation.y = 0.3;scene.add(object);});var light = new THREE.DirectionalLight(0xffffff);//光源顏色light.position.set(20, 10, 1305);//光源位置scene.add(light);//光源添加到場景中</script> </body> </html>? ? 根據相關資料,包含代碼中的3個js文件;然后定義一個加載器來加載模型;
但是不成功;
沒找到加載器類;初步看一下加載器類應該是包含在?OBJLoader.js 中;
three.js加載不同格式3D模型是使用不同加載器;
?
總結
以上是生活随笔為你收集整理的首次使用three.js加载obj模型未成功的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言typedef和Windows数据
- 下一篇: mfc 使用画笔画线