迁移指南
把t3d从v0.2.x升级到v0.3.x,主要注意以下接口变更,否则可能会导致升级后项目运行失败:
着色器规则变更
- 新增
alphaTest_pars_frag
,如果您使用了alphaTest_frag
注意要和新片段配合使用。并且ALPHATEST
的宏不再携带alphaTest
的值,alphaTest
的值使用u_AlphaTest
以uniform
的形式传入 - 新增
diffuseMap_pars_vert
与diffuseMap_vert
着色器片段,如果您的自定义着色器中使用了diffuseMap_pars_frag
或diffuseMap_frag
,请注意必须要和新片段搭配使用。 - 宏定义
USE_DIFFUSE_MAP
、USE_ALPHA_MAP
、USE_EMISSIVEMAP
、USE_AOMAP
中不再包含UV通道信息,您可以在DIFFUSEMAP_UV
、ALPHAMAP_UV
、EMISSIVEMAP_UV
、AOMAP_UV
中获取该信息。在新版本中,这四种贴图可以默认支持设置任意0-8的UV通道。
接口兼容移除
- 移除针对带
WebGL
前缀的枚举兼容代码,包括:WEBGL_PIXEL_FORMAT
,WEBGL_PIXEL_TYPE
,WEBGL_TEXTURE_FILTER
,WEBGL_TEXTURE_WRAP
,WEBGL_COMPARE_FUNC
,WEBGL_OP
- 移除针对
WebGLRenderer
上旧属性的兼容代码,包括:renderTarget
,state
,vertexArrayBindings
- 移除针对
WebGLRenderPass
类的兼容代码 - 移除针对
WebGLProperties
类的兼容代码 - 移除针对
MatcapMaterial
类的兼容代码,新代码已转移到addons
- 移除
GLTFUtils.sanitizeNodeName
接口新增告警
CubeGeometry
类新增废弃告警Group
类新增废弃告警WebGLRenderer.gl
接口新增废弃告警WebGLRenderer.render()
接口新增废弃告警Renderer.renderPass
接口新增废弃告警PMREM
新增废弃告警,请使用PMREMGenerator
代替GeometryUtils.mergeBufferAttributes()
接口新增废弃告警,请使用GeometryUtils.mergeAttributes()
代替
变更日志
特性:添加 PIXEL_FORMAT.R11F_G11F_B10F
特性:为 fromArray
和 toArray
方法添加 denormalize
和 normalize
参数
特性:引入 MathUtils
修复:将 afterRender
回调上下文设置为 renderer
重构:移除已弃用的代码
重构:增加对更多 UV
通道的支持
重构:将材质 alphaTest
从 define
移动到 uniform
特性(插件):添加 CircleGeometry
特性(插件):引入 Timer
特性(插件):引入 GradientSky
特性(插件):引入 PlanarReflectionProbe
特性(插件):为 GLTFLoader
添加 EXT_mesh_gpu_instancing
扩展
特性(插件):引入 PolyhedronBuilder
修复(插件):限制 TransformControls
中的指针事件仅响应左键
重构(插件):优化 GLTFLoader
扩展处理
特性(示例):添加 webgl_query_occlusion_tester
示例
Migration Guide
When upgrading t3d from v0.2.x to v0.3.x, pay attention to the following interface changes to avoid potential project failures after the upgrade:
Shader Rule Changes
- Added
alphaTest_pars_frag
. If you usealphaTest_frag
, make sure to use it with the new fragment. Additionally, theALPHATEST
macro no longer carries thealphaTest
value. ThealphaTest
value is now passed as a uniform namedu_AlphaTest
. - New shader chunks
diffuseMap_pars_vert
anddiffuseMap_vert
have been added. If your custom shaders usediffuseMap_pars_frag
ordiffuseMap_frag
, ensure they are used in conjunction with the new chunks. - The macros
USE_DIFFUSE_MAP
,USE_ALPHA_MAP
,USE_EMISSIVEMAP
, andUSE_AOMAP
no longer include UV channel information. You can obtain this information fromDIFFUSEMAP_UV
,ALPHAMAP_UV
,EMISSIVEMAP_UV
, andAOMAP_UV
. In the new version, these four types of maps can support any UV channel from 0 to 8 by default.
Interface Compatibility Removal
- Removed compatibility code for enums with the WebGL prefix, including:
WEBGL_PIXEL_FORMAT
,WEBGL_PIXEL_TYPE
,WEBGL_TEXTURE_FILTER
,WEBGL_TEXTURE_WRAP
,WEBGL_COMPARE_FUNC
,WEBGL_OP
. - Removed compatibility code for old properties on
WebGLRenderer
, including:renderTarget
,state
,vertexArrayBindings
. - Removed compatibility code for the
WebGLRenderPass
class. - Removed compatibility code for the
WebGLProperties
class. - Removed compatibility code for the
MatcapMaterial
class. The new code has been moved toaddons
. - Removed
GLTFUtils.sanitizeNodeName
.
New Deprecation Warnings
- Added deprecation warning for the
CubeGeometry
class. - Added deprecation warning for the
Group
class. - Added deprecation warning for the
WebGLRenderer.gl
interface. - Added deprecation warning for the
WebGLRenderer.render()
interface. - Added deprecation warning for the
Renderer.renderPass
interface. - Added deprecation warning for
PMREM. Please use PMREMGenerator
instead. - Added deprecation warning for
GeometryUtils.mergeBufferAttributes()
. Please useGeometryUtils.mergeAttributes()
instead.
Changelog
- feat: add
PIXEL_FORMAT.R11F_G11F_B10F
- feat: add
denormalize
andnormalize
parameters tofromArray
andtoArray
methods - feat: introduce
MathUtils
- fix: set
afterRender
callback context to renderer - refactor: remove deprecated code
- refactor: add support for more uv coords
- refactor: move material alpha test from define to uniform
- feat(addons): add
CircleGeometry
- feat(addons): introduce
Timer
- feat(addons): introduce
GradientSky
- feat(addons): introduce
PlanarReflectionProbe
- feat(addons): add
EXT_mesh_gpu_instancing
extension forGLTFLoader
- feat(addons): introduce
PolyhedronBuilder
- fix(addons): restrict pointer event to left button in
TransformControls
- refactor(addons): optimize GLTFLoader extensions handling
- feat(examples): add
webgl_query_occlusion_tester
example
Full Changelog: v0.2.8...v0.3.0