明辉站/网站教程/内容

用PHP动态生成虚拟现实VRML页面

网站教程2024-02-05 阅读
[摘要]由于VRML博大精深,这里只介绍一个简单的例子,还可以将各种VRML结点存入数据库中,下面是源程序。注意:在服务器上,要将让PHP处理wrl格式的文档,否则后果将是没有任何虚拟现实。<?php header("Content-type: application/x-vrml&quo...
由于VRML博大精深,这里只介绍一个简单的例子,还可以将各种VRML结点存入数据库中,下面是源程序。注意:在服务器上,要将让PHP处理wrl格式的文档,否则后果将是没有任何虚拟现实。

<?php header("Content-type: application/x-vrml");$txt="#VRML V2.0 utf8

DEF leftBox Transform
{
translation -5 0 0
children
[
Shape
{
appearance Appearance
{
material Material
{
diffuseColor 1 0 0
}
}
geometry Box{}
}
DEF SphereChild Shape
{
appearance Appearance
{
material Material
{
diffuseColor 1 0 1
}
}
geometry Sphere
{
radius 1.2
}
}
]
}

DEF rightBox Transform
{
translation 5 0 0
children
[
Shape
{
appearance Appearance
{
material Material
{
diffuseColor 0 0 1
}
}
geometry Box{}
}
]
}

DEF onoff Transform
{
translation 0 -1 0
children
[
Shape
{
appearance Appearance
{
material Material
{
diffuseColor 0 1 0
}
}
geometry Box{}
}
DEF TS TouchSensor{}
]
}

DEF S Script
{
eventIn SFBool isActive
eventOut MFNode child
field MFNode testNode USE SphereChild
url
"javascript:
function isActive(value)
{
if (value)
{
child=testNode;
}
}
"
}

ROUTE TS.isActive TO S.isActive
ROUTE S.child TO leftBox.removeChildren
ROUTE S.child TO rightBox.addChildren";echo $txt;
?>

……

相关阅读