diff --git a/docs/api/en/core/Uniform.html b/docs/api/en/core/Uniform.html index a70c9c3c2bf40963834d029624cc6144482f32e0..252e518149f3bcf393127dd177cfc43c510fac34 100644 --- a/docs/api/en/core/Uniform.html +++ b/docs/api/en/core/Uniform.html @@ -20,8 +20,8 @@ uniforms: { time: { value: 1.0 }, - resolution: new THREE.Uniform(new THREE.Vector2()) - } + resolution: new Uniform( new Vector2() ) + };

Uniform types

@@ -186,6 +186,63 @@ (*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.

+

Structured Uniforms

+ +

+ Sometimes you want to organize uniforms as *structs* in your shader code. The following style must be used so *three.js* is able + to process structured uniform data. +

+ + uniforms = { + data: { + value: { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + } + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data; + + +

Structured Uniforms with Arrays

+ +

+ It's also possible to manage *structs* in arrays. The syntax for this use case looks like so: +

+ + var entry1 = { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + }; + var entry2 = { + position: new Vector3( 1, 1, 1 ), + direction: new Vector3( 0, 1, 0 ) + }; + + uniforms = { + data: { + value: [ entry1, entry2 ] + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data[ 2 ]; + +

Constructor

[name]( [param:Object value] )

diff --git a/docs/api/zh/core/Uniform.html b/docs/api/zh/core/Uniform.html index 4d60489b55228e0dcf031f904fa354e5c7edcd6a..f60961b431cf148e0c5f26030cc95eb80c165e22 100644 --- a/docs/api/zh/core/Uniform.html +++ b/docs/api/zh/core/Uniform.html @@ -20,8 +20,8 @@ uniforms: { time: { value: 1.0 }, - resolution: new THREE.Uniform(new THREE.Vector2()) - } + resolution: new Uniform( new Vector2() ) + };

Uniform 种类

@@ -180,10 +180,66 @@

- (*) 与最内层队列中 GSLS 的类型保持一致。包含队列中所有矢量的元素或矩阵中的元素。

+

Structured Uniforms

+ +

+ Sometimes you want to organize uniforms as *structs* in your shader code. The following style must be used so *three.js* is able + to process structured uniform data. +

+ + uniforms = { + data: { + value: { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + } + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data; + + +

Structured Uniforms with Arrays

+ +

+ It's also possible to manage *structs* in arrays. The syntax for this use case looks like so: +

+ + var entry1 = { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + }; + var entry2 = { + position: new Vector3( 1, 1, 1 ), + direction: new Vector3( 0, 1, 0 ) + }; + + uniforms = { + data: { + value: [ entry1, entry2 ] + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data[ 2 ]; + +

构造函数

[name]( [param:Object value] )