Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions docs/api/en/core/UniformsGroup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>

<p class="desc">
This class enables the usage of Uniform Buffer Objects (UBO). You can use them to define global uniform data that can be
shared across all shader programs. Camera and lighting related data are perfect examples of using this technique. If a
uniform value changes (e.g. the position of a light) it's only necessary to update the UBO once and not per shader program. This
is necessary in context of ordinary uniforms.
</p>

<p>
Note: [name] can only be used with a WebGL 2 rendering context and only for [page:ShaderMaterial] and [page:RawShaderMaterial].
</p>

<h3>Example</h3>
<p>
An instance of [name] is declared like this:
</p>
<code>
var cameraUniformsGroup = new THREE.UniformsGroup();
cameraUniformsGroup.setName( 'ViewData' );
cameraUniformsGroup.add( { value: new THREE.Matrix4() } ); // projection matrix
cameraUniformsGroup.add( { value: new THREE.Matrix4() } ); // view matrix
</code>

<p>
The corresponding shader code looks like so:
</p>
<code>
uniform ViewData {
mat4 projectionMatrix;
mat4 viewMatrix;
};
</code>

<p>
There are two things that are important when creating an instance of [name]:
<ul>
<li>The *name* property needs to match the name of the uniform definition in the shader.</li>
<li>The order of uniform values added to the [name] needs to match the definition order in the shader.</li>
</ul>
</p>

<h2>Constructor</h2>

<h3>[name]()</h3>

<h2>Properties</h2>

<h3>[property:Boolean dynamic]</h3>
<p>
Whether the buffer is dynamic or not. Default is *false*.<br /><br />

If set to false, the GPU is informed that contents of the buffer are likely to be used often and not change often.
This corresponds to the [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.STATIC_DRAW] flag.<br />
If set to true, the GPU is informed that contents of the buffer are likely to be used often and change often.
This corresponds to the [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.DYNAMIC_DRAW] flag.
</p>

<h3>[property:String name]</h3>
<p>
The name of the uniforms group. Needs to match the uniform name in the shader.
</p>

<h3>[property:Array uniforms]</h3>
<p>
An array of uniform values. The order of uniforms needs to match the definition order in the shader.
The following types are currently supported.
<ul>
<li>Float</li>
<li>Int</li>
<li>[page:Vector2]</li>
<li>[page:Vector3]</li>
<li>[page:Vector4]</li>
<li>[page:Color]</li>
<li>[page:Matrix3]</li>
<li>[page:Matrix4]</li>
</ul>
</p>

<h2>Methods</h2>

<h3>[method:this add]( [param:Uniform uniform] )</h3>
<p>
[page:Object uniform] — The uniform to add.<br /><br />

Adds an uniform to the [name].
</p>

<h3>[method:UniformsGroup clone]()</h3>
<p>
Returns a clone of this object.
</p>

<h3>[method:this copy]( [param:UniformsGroup uniformsGroup] )</h3>
<p>
[page:UniformsGroup uniformsGroup] — The uniforms group to copy.<br /><br />

Copy the given object into this object.
</p>

<h3>[method:this dispose]()</h3>
<p>
Disposes this [name] so corresponding data cached by [page:WebGLRenderer] are released.
</p>

<h3>[method:this remove]( [param:Uniform uniform] )</h3>
<p>
[page:Object uniform] — The uniform to remove.<br /><br />

Removes an uniform from the [name].
</p>

<h3>[method:this setName]( [param:String name] )</h3>
<p>
[page:String name] — The name to set.<br /><br />

Sets the name of this [name].
</p>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
4 changes: 4 additions & 0 deletions docs/api/en/materials/ShaderMaterial.html
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ <h3>[property:Object uniforms]</h3>
so updating the value of the uniform will immediately update the value available to the GLSL code.
</p>

<h3>[property:Array uniformsGroups]</h3>
<p>
An array containing the [page:UniformsGroup]s of this material.
</p>

<h3>[property:Number vertexColors]</h3>
<p>
Expand Down
84 changes: 84 additions & 0 deletions docs/api/zh/core/UniformsGroup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>

<p class="desc">
TODO
</p>

<h2>Constructor</h2>

<h3>[name]()</h3>

<h2>Properties</h2>

<h3>[property:Boolean dynamic]</h3>
<p>
TODO
</p>

<h3>[property:String name]</h3>
<p>
TODO
</p>

<h3>[property:Array uniforms]</h3>
<p>
TODO
<ul>
<li>Float</li>
<li>Int</li>
<li>[page:Vector2]</li>
<li>[page:Vector3]</li>
<li>[page:Vector4]</li>
<li>[page:Color]</li>
<li>[page:Matrix3]</li>
<li>[page:Matrix4]</li>
</ul>
</p>

<h2>Methods</h2>

<h3>[method:this add]( [param:Uniform uniform] )</h3>
<p>
TODO
</p>

<h3>[method:UniformsGroup clone]()</h3>
<p>
TODO
</p>

<h3>[method:this copy]( [param:UniformsGroup uniformsGroup] )</h3>
<p>
TODO
</p>

<h3>[method:this dispose]()</h3>
<p>
TODO
</p>

<h3>[method:this remove]( [param:Uniform uniform] )</h3>
<p>
TODO
</p>

<h3>[method:this setName]( [param:String name] )</h3>
<p>
TODO
</p>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
4 changes: 4 additions & 0 deletions docs/api/zh/materials/ShaderMaterial.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ <h3>[property:Object uniforms]</h3>
注意,uniforms逐帧被刷新,所以更新uniform值将立即更新GLSL代码中的相应值。
</p>

<h3>[property:Array uniformsGroups]</h3>
<p>
TODO.
</p>

<h3>[property:Number vertexColors]</h3>
<p> 通过定义*colors*属性的生成方式来定义顶点是如何着色的。
Expand Down
6 changes: 4 additions & 2 deletions docs/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ var list = {
"Layers": "api/en/core/Layers",
"Object3D": "api/en/core/Object3D",
"Raycaster": "api/en/core/Raycaster",
"Uniform": "api/en/core/Uniform"
"Uniform": "api/en/core/Uniform",
"UniformsGroup": "api/en/core/UniformsGroup"
},

"Core / BufferAttributes": {
Expand Down Expand Up @@ -534,7 +535,8 @@ var list = {
"Layers": "api/zh/core/Layers",
"Object3D": "api/zh/core/Object3D",
"Raycaster": "api/zh/core/Raycaster",
"Uniform": "api/zh/core/Uniform"
"Uniform": "api/zh/core/Uniform",
"UniformsGroup": "api/zh/core/UniformsGroup"
},

"核心 / BufferAttributes": {
Expand Down
4 changes: 3 additions & 1 deletion docs/manual/en/introduction/How-to-use-WebGL2.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ <h2>Next Steps</h2>

[example:webgl2_materials_texture3d WebGL2 / materials / texture3d]<br />
[example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]<br />
[example:webgl2_multisampled_renderbuffers WebGL2 / multisampled renderbuffers]
[example:webgl2_multisampled_renderbuffers WebGL2 / multisampled renderbuffers]<br />
[example:webgl2_ubo WebGL2 / uniform buffer objects]
</p>

<h2>Supported features</h2>
Expand All @@ -118,6 +119,7 @@ <h2>Supported features</h2>
<li>2D Texture Arrays</li>
<li>Multisampled Renderbuffers</li>
<li>Non-power of two (POT) textures work just the same as POT textures now. No resizing is required for best quality.</li>
<li>Uniform Buffer Objects</li>
</ul>

</p>
Expand Down
4 changes: 3 additions & 1 deletion docs/manual/zh/introduction/How-to-use-WebGL2.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ <h2>接下来</h2>

[example:webgl2_materials_texture3d WebGL2 / materials / texture3d]<br />
[example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]<br />
[example:webgl2_multisampled_renderbuffers WebGL2 / multisampled renderbuffers]
[example:webgl2_multisampled_renderbuffers WebGL2 / multisampled renderbuffers]<br />
[example:webgl2_ubo WebGL2 / uniform buffer objects]
</p>

<h2>支持的特性</h2>
Expand All @@ -116,6 +117,7 @@ <h2>支持的特性</h2>
<li>2D Texture Arrays</li>
<li>Multisampled Renderbuffers</li>
<li>Non-power of two (POT) textures work just the same as POT textures now. No resizing is required for best quality.</li>
<li>Uniform Buffer Objects</li>
</ul>

</p>
Expand Down
3 changes: 2 additions & 1 deletion examples/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ var files = {
"webgl2_materials_texture2darray",
"webgl2_materials_texture3d",
"webgl2_multisampled_renderbuffers",
"webgl2_sandbox"
"webgl2_sandbox",
"webgl2_ubo"
],
"webaudio": [
"webaudio_orientation",
Expand Down
Loading