1、
o3djs.rendergraph.createBasicView( !o3d.Pack
pack
!o3d.Transform
treeRoot
!o3d.RenderNode
opt_parent
!o3djs.math.Vector4
opt_clearColor
number opt_priority
!o3djs.math.Vector4
opt_viewport )
参数:
pack 管理生成对象的Pack包.
treeRoot 视图的根节点.
opt_parent 视图的渲染节点.
opt_clearColor 视图的颜色,[0.1,0.2,0.3,0.4],分别表示[红,绿,蓝,黑],每个值介于0到1之间。
opt_priority 生成对象的优先级。
opt_viewport 视窗设置,例如[0.1,0.1,0.9,0.9],分别表示[左,上,右,下],每个值介于0到1之间,左和右值相加不能大于1,上和下值相加不能大于1
返回值:
!o3djs.rendergraph.ViewInfo. 创建的所有对象的视图信息.
例如,
var viewBackgroundColor=[0.2,0.5,0.6,0.7];
var viewPort = [0.1,0.1,0.9,0.9];
g_viewInfo = o3djs.rendergraph.createBasicView(
g_pack,
g_client.root,
g_client.renderGraphRoot,
viewBackgroundColor,
1,
viewPort
);
________________________________________
2、创建材质 o3djs.material.createBasicMaterial ()
view plaincopy to clipboardprint?
1. !o3d.Material o3djs.material.createBasicMaterial (
2. !o3d.Pack pack ,
3. !o3djs.rendergraph.ViewInfo viewInfo ,
4. (!o3djs.math.Vector4|!o3d.Texture) colorOrTexture ,
5. boolean opt_transparent )
参数:
pack 管理创建对象的包(Pack)。
viewInfo API函数o3djs.rendergraph.createBasicView创建的视窗信息。
colorOrTexture 颜色矩阵[r, g, b, a]或者一个o3d纹理贴图。
opt_transparent 材质是否是透明的。默认情况下是非透明的。
返回:
!o3d.Material.生成的材质。
示例代码:
view plaincopy to clipboardprint?
1. <html><body>
2. <mce:script type="text/javascript" src="o3djs/all.js" mce_src="o3djs/all.js"><!--
3.
4. // --></mce:script>
5. <mce:script type="text/javascript"><!--
6.
7. window.onload = init;
8.
9. function init() {
10. o3djs.base.makeClients(initStep2);
11. }
12.
13. function initStep2(clientElements) {
14. var clientElement = clientElements[0];
15. var client = clientElement.client;
16. var pack = client.createPack();
17. var viewInfo = o3djs.rendergraph.createBasicView(
18. pack,
19. client.root,
20. client.renderGraphRoot);
21. var material = o3djs.material.createBasicMaterial(
22. pack,
23. viewInfo,
24. [1, 0, 0, 1]); // red
25. var shape = o3djs.primitives.createCube(pack, material, 10);
26. var transform = pack.createObject('Transform');
27. transform.parent = client.root;
28. transform.addShape(shape);
29. o3djs.camera.fitContextToScene(client.root,
30. client.width,
31. client.height,
32. viewInfo.drawContext);
33. }
34. // --></mce:script>
35. <div id="o3d" style="width: 600px; height: 600px"></div>
36. </body></html>
o3djs.rendergraph.createBasicView( !o3d.Pack
pack
!o3d.Transform
treeRoot
!o3d.RenderNode
opt_parent
!o3djs.math.Vector4
opt_clearColor
number opt_priority
!o3djs.math.Vector4
opt_viewport )
参数:
pack 管理生成对象的Pack包.
treeRoot 视图的根节点.
opt_parent 视图的渲染节点.
opt_clearColor 视图的颜色,[0.1,0.2,0.3,0.4],分别表示[红,绿,蓝,黑],每个值介于0到1之间。
opt_priority 生成对象的优先级。
opt_viewport 视窗设置,例如[0.1,0.1,0.9,0.9],分别表示[左,上,右,下],每个值介于0到1之间,左和右值相加不能大于1,上和下值相加不能大于1
返回值:
!o3djs.rendergraph.ViewInfo. 创建的所有对象的视图信息.
例如,
var viewBackgroundColor=[0.2,0.5,0.6,0.7];
var viewPort = [0.1,0.1,0.9,0.9];
g_viewInfo = o3djs.rendergraph.createBasicView(
g_pack,
g_client.root,
g_client.renderGraphRoot,
viewBackgroundColor,
1,
viewPort
);
________________________________________
2、创建材质 o3djs.material.createBasicMaterial ()
view plaincopy to clipboardprint?
1. !o3d.Material o3djs.material.createBasicMaterial (
2. !o3d.Pack pack ,
3. !o3djs.rendergraph.ViewInfo viewInfo ,
4. (!o3djs.math.Vector4|!o3d.Texture) colorOrTexture ,
5. boolean opt_transparent )
参数:
pack 管理创建对象的包(Pack)。
viewInfo API函数o3djs.rendergraph.createBasicView创建的视窗信息。
colorOrTexture 颜色矩阵[r, g, b, a]或者一个o3d纹理贴图。
opt_transparent 材质是否是透明的。默认情况下是非透明的。
返回:
!o3d.Material.生成的材质。
示例代码:
view plaincopy to clipboardprint?
1. <html><body>
2. <mce:script type="text/javascript" src="o3djs/all.js" mce_src="o3djs/all.js"><!--
3.
4. // --></mce:script>
5. <mce:script type="text/javascript"><!--
6.
7. window.onload = init;
8.
9. function init() {
10. o3djs.base.makeClients(initStep2);
11. }
12.
13. function initStep2(clientElements) {
14. var clientElement = clientElements[0];
15. var client = clientElement.client;
16. var pack = client.createPack();
17. var viewInfo = o3djs.rendergraph.createBasicView(
18. pack,
19. client.root,
20. client.renderGraphRoot);
21. var material = o3djs.material.createBasicMaterial(
22. pack,
23. viewInfo,
24. [1, 0, 0, 1]); // red
25. var shape = o3djs.primitives.createCube(pack, material, 10);
26. var transform = pack.createObject('Transform');
27. transform.parent = client.root;
28. transform.addShape(shape);
29. o3djs.camera.fitContextToScene(client.root,
30. client.width,
31. client.height,
32. viewInfo.drawContext);
33. }
34. // --></mce:script>
35. <div id="o3d" style="width: 600px; height: 600px"></div>
36. </body></html>