Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImmediateRenderObject: Clarify implementation. #19341

Merged
merged 4 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
86 changes: 81 additions & 5 deletions docs/api/en/extras/objects/ImmediateRenderObject.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,103 @@

<h1>[name]</h1>

<p class="desc">base class for immediate rendering objects.</p>
<p class="desc">
This experimental class provides a fast code path for rendering meshes with frequently updated
geometry data. When the renderer encounters an instance of [name], it only takes care about
the most primitive rendering operations (e.g. binding vertex attributes, determining correct shader
program or perfoming the actual draw call). Features like view frustum culling, wireframe rendering
or using multiple materials are not supported. Besides [name] can only be used to render triangles.
</p>

<p class="desc">
[name] does not work with instances of [page:BufferGeometry] or [page:Geometry]. The
raw geometry data have to be maintained as properties of the [name].
</p>

<p class="desc">
Using [name] makes only sense if you are updating your geometry data per frame. You can then
benefit of a faster code path compared to the default mesh redering logic.
</p>

<h2>Examples</h2>
<p>
[example:webgl_marchingcubes Marching Cubes]
</p>

<h2>Constructor</h2>


<h3>[name]()</h3>
<h3>[name]( [param:Material material] )</h3>
<p>
This creates a new [name].
[page:Material material] — The material of the [name].
</p>

<h2>Properties</h2>
<p>See the base [page:Object3D] class for common properties.</p>

<h3>[property:Boolean material]</h3>
<p>
The material of the [name]. Assigning multiple materials is not supported.
</p>

<h3>[property:Boolean hasPositions]</h3>
<p>
Whether position data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasNormals]</h3>
<p>
Whether normal data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasColors]</h3>
<p>
Whether color data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasUvs]</h3>
<p>
Whether texture coordinates are defined or not. Default is *false*.
</p>

<h3>[property:Float32Array positionArray]</h3>
<p>
The buffer holding position data. Default is *null*.
</p>

<h3>[property:Float32Array normalArray]</h3>
<p>
The buffer holding normal data. Default is *null*.
</p>

<h3>[property:Float32Array colorArray]</h3>
<p>
The buffer holding color data. Default is *null*.
</p>

<h3>[property:Float32Array uvArray]</h3>
<p>
The buffer holding texture coordinates. Default is *null*.
</p>

<h3>[property:Integer count]</h3>
<p>
The number of primitives to be rendered. Default is *0*.
This property will be set to *0* after each rendering so you usually
set it in the implementatio of [page:.render]().
</p>

<h2>Methods</h2>

<p>See the base [page:Object3D] class for common methods.</p>

<h3>[method:null render]([param:Function renderCallback])</h3>
<p>
renderCallback -- A function to render the generated object.
renderCallback -- A function to render the generated geometry data.
</p>
<p>
This function needs to be overridden to start the creation of the object and should call renderCallback when finished.
This method needs to be implemented by the deriving class of [name]. You normally want to implement the
vertex buffer update logic and execute *renderCallback* at the end of your implementation.
</p>

<h2>Source</h2>
Expand Down
85 changes: 80 additions & 5 deletions docs/api/zh/extras/objects/ImmediateRenderObject.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,102 @@

<h1>即时渲染对象([name])</h1>

<p class="desc">即时渲染对象的基类。</p>
<p class="desc">
This experimental class provides a fast code path for rendering meshes with frequently updated
geometry data. When the renderer encounters an instance of [name], it only takes care about
the most primitive rendering operations (e.g. binding vertex attributes, determining correct shader
program or perfoming the actual draw call). Features like view frustum culling, wireframe rendering
or using multiple materials are not supported. Besides [name] can only be used to render triangles.
</p>

<p class="desc">
[name] does not work with instances of [page:BufferGeometry] or [page:Geometry]. The
raw geometry data have to be maintained as properties of the [name].
</p>

<p class="desc">
Using [name] makes only sense if you are updating your geometry data per frame. You can then
benefit of a faster code path compared to the default mesh redering logic.
</p>

<h2>例子</h2>
<p>
[example:webgl_marchingcubes Marching Cubes]
</p>

<h2>构造函数(Constructor)</h2>

<h3>[name]( [param:Material material] )</h3>
<p>
[page:Material material] — The material of the [name].
</p>

<h2>Properties</h2>
<p>See the base [page:Object3D] class for common properties.</p>

<h3>[property:Boolean material]</h3>
<p>
The material of the [name]. Assigning multiple materials is not supported.
</p>

<h3>[property:Boolean hasPositions]</h3>
<p>
Whether position data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasNormals]</h3>
<p>
Whether normal data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasColors]</h3>
<p>
Whether color data are defined or not. Default is *false*.
</p>

<h3>[property:Boolean hasUvs]</h3>
<p>
Whether texture coordinates are defined or not. Default is *false*.
</p>

<h3>[property:Float32Array positionArray]</h3>
<p>
The buffer holding position data. Default is *null*.
</p>

<h3>[property:Float32Array normalArray]</h3>
<p>
The buffer holding normal data. Default is *null*.
</p>

<h3>[name]()</h3>
<h3>[property:Float32Array colorArray]</h3>
<p>
这会创建一个新的 [name]。
The buffer holding color data. Default is *null*.
</p>

<h3>[property:Float32Array uvArray]</h3>
<p>
The buffer holding texture coordinates. Default is *null*.
</p>

<h3>[property:Integer count]</h3>
<p>
The number of primitives to be rendered. Default is *0*.
This property will be set to *0* after each rendering so you usually
set it in the implementatio of [page:.render]().
</p>

<h2>方法(Methods)</h2>

<p>See the base [page:Object3D] class for common methods.</p>

<h3>[method:null render]([param:Function renderCallback])</h3>
<p>
renderCallback -- 生成对象的渲染函数。
renderCallback -- A function to render the generated geometry data.
</p>
<p>
需要重写此函数以开始创建对象,并在完成时调用renderCallback。
This method needs to be implemented by the deriving class of [name]. You normally want to implement the
vertex buffer update logic and execute *renderCallback* at the end of your implementation.
</p>

<h2>源码(Source)</h2>
Expand Down
Binary file added examples/screenshots/webgl_gpgpu_birds_gltf.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/extras/objects/ImmediateRenderObject.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ export class ImmediateRenderObject extends Object3D {
constructor( material: Material );

material: Material;

hasPositions: boolean;
hasNormals: boolean;
hasColors: boolean;
hasUvs: boolean;

positionArray: null | Float32Array;
normalArray: null | Float32Array;
colorArray: null | Float32Array;
uvArray: null | Float32Array;

count: number;

render( renderCallback: Function ): void;

}
12 changes: 12 additions & 0 deletions src/extras/objects/ImmediateRenderObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ function ImmediateRenderObject( material ) {
this.material = material;
this.render = function ( /* renderCallback */ ) {};

this.hasPositions = false;
this.hasNormals = false;
this.hasColors = false;
this.hasUvs = false;

this.positionArray = null;
this.normalArray = null;
this.colorArray = null;
this.uvArray = null;

this.count = 0;

}

ImmediateRenderObject.prototype = Object.create( Object3D.prototype );
Expand Down