我已经在同一个问题上停留了一段时间,但我不知道为什么在运行项目时出现以下运行时错误。

Exception in thread "main" org.web3d.vrml.lang.UnsupportedNodeException: Request for a node that is not part of the specified profile and components for this stream: viewpoint
    at org.web3d.vrml.renderer.DefaultNodeFactory.createVRMLNode(DefaultNodeFactory.java:730)
    at org.web3d.vrml.renderer.ogl.OGLMainSceneBuilder.startNode(OGLMainSceneBuilder.java:147)
    at org.web3d.vrml.renderer.ogl.OGLVRMLSceneBuilder.startNode(OGLVRMLSceneBuilder.java:514)
    at org.web3d.x3d.jaxp.X3DSAVAdapter.startElement(X3DSAVAdapter.java:830)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1364)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at org.web3d.parser.GeneralisedReader.parse(GeneralisedReader.java:261)
    at org.xj3d.impl.core.loading.DefaultWorldLoader.loadNow(DefaultWorldLoader.java:156)
    at org.xj3d.impl.core.loading.DefaultWorldLoader.loadNow(DefaultWorldLoader.java:203)
    at org.web3d.vrml.scripting.browser.X3DCommonBrowser.createX3DFromURL(X3DCommonBrowser.java:264)
    at org.web3d.vrml.scripting.external.sai.SAIBrowser.createX3DFromURL(SAIBrowser.java:843)
    at xj3dtest.Xj3DTest.<init>(Xj3DTest.java:50)
    at xj3dtest.Xj3DTest.main(Xj3DTest.java:56)

我的Java代码是
package xj3dtest;

import java.awt.BorderLayout;
import java.awt.Container;
import static java.lang.Boolean.TRUE;
import javax.swing.JFrame;
import org.web3d.x3d.sai.Browser;
import org.web3d.x3d.sai.BrowserFactory;
import org.web3d.x3d.sai.X3DComponent;
import org.web3d.x3d.sai.X3DScene;
import java.util.HashMap;

public class Xj3DTest extends JFrame {

    public Xj3DTest(String title) {

        super(title);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Setup browser parameters
        HashMap requestedParameters=new HashMap();
        requestedParameters.put("Antialiased",TRUE);
        requestedParameters.put("TextureQuality","medium");
        requestedParameters.put("PrimitiveQuality","medium");
        requestedParameters.put("Xj3D_InterfaceType","SWING");
        requestedParameters.put("Xj3D_NavbarShown",TRUE);
        requestedParameters.put("Xj3D_NavbarPosition","TOP");
        requestedParameters.put("Xj3D_LocationShown",TRUE);
        requestedParameters.put("Xj3D_LocationPosition","TOP");
        requestedParameters.put("Xj3D_LocationReadOnly",TRUE);
        requestedParameters.put("Xj3D_ShowConsole",TRUE);
        requestedParameters.put("Xj3D_OpenButtonShown",TRUE);
        requestedParameters.put("Xj3D_ReloadButtonShown",TRUE);
        requestedParameters.put("Xj3D_StatusBarShown",TRUE);
        requestedParameters.put("Xj3D_FPSShown",TRUE);
        requestedParameters.put("Xj3D_ContentDirectory","CurrentDirectory");
        requestedParameters.put("Xj3D_AntialiasingQuality","low");
        requestedParameters.put("Xj3D_Culling_Mode", "frustum");

        System.setProperty("x3d.sai.factory.class", "org.xj3d.ui.awt.browser.ogl.X3DOGLBrowserFactoryImpl");
        X3DComponent x3dComponent = BrowserFactory.createX3DComponent(requestedParameters);

        Browser browser = x3dComponent.getBrowser();

        Container cp = getContentPane();
        cp.setLayout(new BorderLayout());
        cp.add((javax.swing.JPanel)x3dComponent, BorderLayout.CENTER);

        X3DScene scene = browser.createX3DFromURL(new String[] {"test.x3d"});

        browser.replaceWorld(scene);
    }

    public static void main(String[] args) {
        Xj3DTest frame = new Xj3DTest("Xj3D test");
        frame.setSize(640, 480);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

我需要通过它的X3D文件才能显示出来,其中包含viewpointimageTexture url标记,这些标记经过测试会导致问题。当我从X3D文件中删除这些标签时,它确实可以工作,但没有期望的输出,因为它似乎已放大并且X3D文件没有纹理。

我正在使用的Jarsgluegen-rt, gluegen-rt-natives-linux-amd64, gluegen-rt-natives-windows-amd64, gluegen-rt-natives-linux-i586, j3d-core-1.3.1, jhall, joal, joal-natives-linux-amd64, joal-natives-windows-amd64, joal-natives-linux-i586, joal-all, joal-all-natives-linux-amd64, joal-all-natives-windows-amd64, joal-all-natives-linux-i586, xj3d.browser_2.1.0-nps, xj3d.cadfilter_2.1.0_nps, xj3d.2.1-3rdparty-nps, xj3d.2.1-nps, xj3d-core, xj3d-runtime, xj3d-script-base。设置VM选项的方法是使用-Xmx450M -Djava.library.path="C:\Users\matt\Documents\NetBeansProjects\jar",并且我已将包含所有Jars的库添加到项目中。

编辑
它仍然无法正常工作

EDIT#2

导致该问题的两个标签是
<viewpoint centerOfRotation="7 1 0" position='10 0 40' orientation='0 0 0 1'></viewpoint><imageTexture url='"http://somewebsite.com/images/test.jpg"></imageTexture>切记上面的网站不是存储图像的网站,而是遵循相同的格式。

编辑#3

现在X3D文件中的代码是<viewpoint centerOfRotation="7 1 0" position='10 0 40' orientation='0 0 0 1'></viewpoint><imageTexture url="http://somewebsite.com/images/test.jpg"></imageTexture>
而且我仍然遇到视点错误,而且我不知道如何解决

最佳答案

对于第一个标签,错误显然是url属性上的虚假单引号。

对于第二个,您可以尝试对所有属性使用一致的引号,某些解析器可能会因此失败。

在全局范围内,您可以从此处开始:

  • 使用this validator
  • 之类的工具检查XML的格式是否正确
  • 检查X3D是否对XML header 中声明的xsd有效。 validator on this page有一些引用,但是最有效的方法仍然是使用您选择的XML创作工具。
  • 10-06 13:50