首次使用three.js加载obj模型未成功
生活随笔
收集整理的這篇文章主要介紹了
首次使用three.js加载obj模型未成功
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
接此,https://blog.csdn.net/bcbobo21cn/article/details/110676331
基本代碼如下;
<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>第一個(gè)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);//光源添加到場(chǎng)景中</script> </body> </html>? ? 根據(jù)相關(guān)資料,包含代碼中的3個(gè)js文件;然后定義一個(gè)加載器來(lái)加載模型;
但是不成功;
沒(méi)找到加載器類(lèi);初步看一下加載器類(lèi)應(yīng)該是包含在?OBJLoader.js 中;
three.js加載不同格式3D模型是使用不同加載器;
?
總結(jié)
以上是生活随笔為你收集整理的首次使用three.js加载obj模型未成功的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: C语言typedef和Windows数据
- 下一篇: mfc 使用画笔画线