three.js加载js模型的问题
发布于 6 年前 作者 chaoduan 15382 次浏览 来自 问答

您好,目前遇到的问题是这样的,真机上储存到本地用户文件的JS模型文件读取不了,如截图。

模拟器上可以读取,如截图。(文档中建议忽略协议名wxfile和http这个差异)

尝试用readfile方法,模拟器提示无法读取,如截图。

__
__

read代码:

fs.readFile({

filePath: ‘’ + wx.env.USER_DATA_PATH + ‘/src/jiyumintestpoint.js’,

encoding: ‘utf-8’,

success: function(res) {

//jiyu = res.data;

console.log(res);

},

fail: function(res) {

console.log(res, “测试读取”);

}

});

请问这个问题用什么方法解决?

2 回复

使用非 .js 文件,然后用 readFile 接口读可以解决此问题(如 .txt、.json)

three.js加载json模型的方法是在回调函数中添加一个url地址。

__
__

loader.load(url, (geometry) => {

texture = new THREE.TextureLoader;

map = texture.load(skins);

map.wrapS = map.wrapT = THREE.RepeatWrapping;

material = new THREE.MeshPhongMaterial({

map: map,

shininess: 100,

//emissive: color

});

readfile是得到一个json的data。。请问如何处理成一个three的可读地址给真机加载?

data:{errMsg: “readFile:ok”, data: "{

“metadata” :

{

“formatVersion” : 3.1,

↵…2,530,529,531,0,456,460,461,502,506,507]

↵}

↵"}

@Link

__
__

回到顶部