gpt4 book ai didi

javascript - Three.js + Threex + Javascript : "fromArray is not a function"?

转载 作者:搜寻专家 更新时间:2023-11-01 04:36:25 29 4
gpt4 key购买 nike

我真的尽了最大努力通过自己的研究来解决这个问题,但不幸的是,我是 three.js 和 javascript 的新手,我真的需要一些帮助。

我正在尝试将模型从 threex(google threex——我无法发布另一个链接)导入到我的 three.js 场景中。不幸的是,当我添加如下代码时:

    var spaceship = null;
THREEx.SpaceShips.loadSpaceFighter03(function(object3d){
scene.add(object3d)
spaceship = object3d
})

我最终得到一个空白场景,并且在我的 javascript 控制台中出现了这个错误:

Uncaught TypeError: (intermediate value).fromArray is not a function.:8000/bower_components/threex.spaceships/examples/vendor/three.js/examples/js/loaders/MTLLoader.js:299

这让我想到了 MTLLoader.js 中(可能)有问题的代码行(无论那个文件是什么。)

params[ 'ambient' ] = new THREE.Color().fromArray( value );

我不知道发生了什么,我想我有点不知所措。有人知道如何解决这个问题吗?

我正在完成本教程:https://www.youtube.com/watch?v=vw5_YyM4hn8 (如果有帮助,可以在此处找到本教程该部分的示例代码:https://github.com/jeromeetienne/flying-spaceship-minigame/blob/master/step1-01-naked-spaceship.html -- 我看不出有任何问题 -- 到目前为止,我一直在努力严格按照这些步骤进行操作。)

提前致谢。

最佳答案

这是当前 three.js 与该 threex 使用的代码之间的版本不兼容。 Threex 兼容一年前的 three.js 版本。

在学习three.js的时候,这个有很好的建议:Learning WebGL and three.js

threex使用的three.js的版本可以在https://github.com/jeromeetienne/threex/tree/master/vendor中看到

关于javascript - Three.js + Threex + Javascript : "fromArray is not a function"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30002500/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com