THREE.js - 无法读取未定义的属性'lib'(THREE.ShaderUtils.lib ["normal"])

mr-*_*-sk 2 javascript webgl three.js

我正在完成Oreilly在WebGL入门书中找到的练习.

以下行导致运行时错误.我用Google搜索,没有看到其他人有问题,所以我做错了什么?

var specularMap= THREE.ImageUtils.loadTexture("WebGLBook/images/earth_specular_2048.jpg");

var shader   = THREE.ShaderUtils.lib[ "normal" ]; <-- fails
var uniforms = THREE.UniformsUtils.clone(shader.uniforms);

uniforms['tNormal'].texture   = normalMap; 
uniforms['tDiffuse'].texture  = surfaceMap;
Run Code Online (Sandbox Code Playgroud)

注意到的行失败,出现以下错误:

Uncaught TypeError: Cannot read property 'lib' of undefined solar-system-spec-map.html:60
Earth.createGlobe solar-system-spec-map.html:60
Earth.init solar-system-spec-map.html:51
EarthApp.init solar-system-spec-map.html:33
(anonymous function) solar-system-spec-map.html:93
deferred.resolveWith jquery-1.6.4.js:1016
jQuery.extend.ready jquery-1.6.4.js:437
DOMContentLoaded
Run Code Online (Sandbox Code Playgroud)

同样奇怪的是,"ShaderUtils"没有列在THREE.js文档中...... http://mrdoob.github.com/three.js/docs/55/

这是怎么回事?!

Pau*_*lan 9

命名约定已更改,现在应该可以使用了

var shader = THREE.ShaderLib[ "normalmap" ];
Run Code Online (Sandbox Code Playgroud)