2

I'm attempting to display a 3D model in Three.JS that has been converted to UTF8 format using Won's WebGL Loader ( http://code.google.com/p/webgl-loader/ ). I don't know how to convert the metadata outputted from WebGL Loader into what Three.JS expects, and a Google Search and read through the source hasn't shed any insight. The output of WebGLLoader and input requirements for Three.JS listed below.

WebGL Loader Output:

MODELS['abc_normals.obj'] = {
  materials: {
  },
  decodeParams: {
    decodeOffsets: [-8192,-88,-2278,0,0,-511,-511,-511],
    decodeScales: [0.012115,0.012115,0.012115,0.000978,0.000978,0.001957,0.001957,0.001957],
  },
  urls: {
    'abc_normals.utf8': [
      { material: '',
        attribRange: [0, 8288],
        indexRange: [66304, 14914],
        bboxes: 111046,
        names: ['default', ],
        lengths: [44742, ],
      },
    ],
  }
};

Three.JS requirements:

{ scale: 0.815141, offsetX: -0.371823, offsetY: -0.011920, offsetZ: -0.416061 }
4

2 回答 2

1

您是否像 webgl-loader 的首页推荐的那样使用 r50?我认为之后的输出与 three.js 加载器不兼容。

于 2012-07-29T15:19:04.927 回答
0

您列出的输出是一个 javascript 数据结构,但 THREE.js 需要 JSON。为了使这个有效的 json 它需要是这样的:

{
  "materials": {
  },
  "decodeParams": {
    "decodeOffsets": [-8192,-88,-2278,0,0,-511,-511,-511],
    "decodeScales": [0.012115,0.012115,0.012115,0.000978,0.000978,0.001957,0.001957,0.001957],
  },
  "urls": {
    "abc_normals.utf8": [
      { "material": "",
    "attribRange": [0, 8288],
    "indexRange": [66304, 14914],
    "bboxes": 111046,
    "names": ["default", ],
    "lengths": [44742, ],
      },
    ],
  }
};

自动转换可以通过加载 JS 然后将模型保存为 JSON。您可以在 Chrome 或 Firef 中尝试此操作

MODELS={}
(insert your .js here)
JSON.stringify(MODELS)
于 2015-02-28T01:00:25.983 回答