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

Unable to insert nodes into an empty inline node dynamically #1172

Open
microaaron opened this issue Nov 13, 2021 · 3 comments
Open

Unable to insert nodes into an empty inline node dynamically #1172

microaaron opened this issue Nov 13, 2021 · 3 comments

Comments

@microaaron
Copy link
Contributor

Here is the example:
https://jsitor.com/PUZb3AOGZ

JavaScript:

x3dom.runtime.ready = function () {
  var group0 = $("<Group>", { id: "group0", DEF: "group0" });
  group0.appendTo($("#rootScene"));
  console.log(group0[0].outerHTML);
  setTimeout(
    () => console.log(group0[0]._x3domNode),100
  );

  var group1 = $("<Group>", { id: "group1", DEF: "group1" });
  group1.appendTo($("#inline01"));
  console.log(group1[0].outerHTML);
  setTimeout(
    () => console.log(group1[0]._x3domNode), 100  //undefined
  );

  var group2 = $("<Group>", { id: "group2", DEF: "group2" });
  setTimeout(
    () => group2.appendTo($($("#inline02")[0]._x3domNode._childNodes[0]._xmlNode)), 100
  );
  
  console.log(group2[0].outerHTML);
  setTimeout(
    () => console.log(group2[0]._x3domNode), 200  //undefined
  );

  /*setTimeout(
    () => console.log($("#inline02")[0]._x3domNode._childNodes[0]._xmlNode.outerHTML), 300
  );*/

  //console.log($("#rootScene")[0].outerHTML);
}

HTML:

<html>

<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
	<title></title>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
	<script type="text/javascript" src="https://x3dom.org/release/x3dom-full.debug.js"></script>
	<link rel='stylesheet' type='text/css' href='https://www.x3dom.org/release/x3dom.css'>
	</link>
</head>

<body>
	<X3D showLog="true" profile="Immersive" version="3.2">
		<Scene id="rootScene">
			<inline id="inline01" DEF="inline01" nameSpaceName="inline01"
				url="https://raw.githubusercontent.com/microaaron/InlineExample/main/Empty.x3d">
			</inline>

			<inline id="inline02" DEF="inline02"
				url="https://raw.githubusercontent.com/microaaron/InlineExample/main/Empty.x3d">
			</inline>

		</Scene>
	</X3D>
</body>

</html>

Empty.x3d:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN" "http://www.web3d.org/specifications/x3d-3.2.dtd">

<X3D profile="Immersive" version="3.2">
  <Scene> 
  </Scene>
</X3D>
@microaaron microaaron changed the title Unable to insert a node into an inline node dynamically Unable to insert nodes into an inline node dynamically Nov 13, 2021
@andreasplesch andreasplesch changed the title Unable to insert nodes into an inline node dynamically Unable to insert nodes into an empty inline node dynamically Nov 14, 2021
@andreasplesch
Copy link
Contributor

https://jsitor.com/6lb5vUJ2H has a workaround. It turns it is necessary to have an existing grouping node in the inline to add nodes to. A scene with a single empty group node probably works.

Also you have to wait until the inline is loaded before you add nodes. You can use the inline onload event for that.

@microaaron
Copy link
Contributor Author

Thanks.

@microaaron
Copy link
Contributor Author

By the way, not only inserting, removing or modifying nodes may cause problems also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants