浏览代码

ImmediateRenderObject: Clarify implementation.

Mugen87 5 年之前
父节点
当前提交
39ca1e3d48

+ 76 - 5
docs/api/en/extras/objects/ImmediateRenderObject.html

@@ -12,27 +12,98 @@
 
 		<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. 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>
 
+		<h2>Examples</h2>
+		<p>
+			[example:webgl_marchingcubes Marching Cubes]
+		</p>
 
 		<h2>Constructor</h2>
 
 
-		<h3>[name]()</h3>
+		<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>
-		This creates a new [name].
+			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>

+ 75 - 5
docs/api/zh/extras/objects/ImmediateRenderObject.html

@@ -12,27 +12,97 @@
 
 		<h1>即时渲染对象([name])</h1>
 
-		<p class="desc">即时渲染对象的基类。</p>
+		<p class="desc">
+			This experimental class provides a fast code path for rendering meshes. 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>
 
+		<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>[name]()</h3>
+		<h3>[property:Float32Array normalArray]</h3>
 		<p>
-			这会创建一个新的 [name]。
+			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 -- 生成对象的渲染函数。
+		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>

+ 13 - 0
src/extras/objects/ImmediateRenderObject.d.ts

@@ -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 - 0
src/extras/objects/ImmediateRenderObject.js

@@ -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 );