Load glTF with instanced Meshs into Aframe - aframe

I've got a glTF file with instanced meshs exported from Blender. My Problem is, that Aframe does not accept the instancing and draws every piece without instancing, which causes the browser memory to crash. In the glTF viewer (https://gltf-viewer.donmccurdy.com/) it works without problems. How do I import this file properly, so that Aframe can visualize it?
I am using the standard a-gltf-model tag in Aframe.
Edit:
So basically I got something standard like this:
<a-scene>
<a-assets timeout="40000">
<a-asset-item id="r" src="path/to/my/model.gltf" ></a-asset-item>
</a-assets>
<a-gltf-model src="#r" scale="0.4 0.4 0.4" position="1 1 1">
</a-gltf-model>
<a-camera id="camera" cursor-visible="true" cursor-opacity="1" position="3.083 0.957 -1.607"></a-camera>
</a-scene>
Problem is now, that the model is created with instancing in blender and Aframe doesnt multiply the instanced versions of the model over and over. It starts to draw every instance as a single model, which causes the browser to crash. Its a model of a piece of gras, which should be spread over a plane, without drawing the 7k vertices for every single piece. In Don McCurdys glTF viewer its loading immediately and working as it should, looking like this:
The normal version looks like this in Aframe:
EDIT 2:
Here is a working Glitch example (somehow it doesn't crash). It loads, but as you can see in the Inspector the draw and triangle calls are rising, which they shouldn't.
https://glitch.com/edit/#!/instance-gltf
EDIT 3: So apparently glTF is capable of instancing and the from blender exported file should work, but doesn't. As we did it like this. Source.

Related

How to manually add a skeleton in Qt3d?

In Qt, I added a Mesh using QSceneLoader, but I wanted to rig the mesh manually in QT using the classes from Qt3D: QJoint, QSkeleton, and QArmature. I have not seen a lot of documentation on creating a skeleton that's applied to a mesh through C++ alone.
Even without C++, I found you can give an armature value in QML, but the file needs to be a .gltf. What I want to do is use C++ directly to make a skeleton so the programming-side has full control of the bone hierarchy.
QSkeleton gives one the abilitiy to add joints and child joints, but how are these joints then applied to the mesh? If there's any examples on this that would also be a great help.
Here's what I've tried:
Qt3DCore::QSkeleton* skeleton = new Qt3DCore::QSkeleton();
Qt3DCore::QJoint* joint = new Qt3DCore::QJoint();
joint->setTranslation(entityTransform->translation());
skeleton->setRootJoint(joint);
Qt3DCore::QArmature* a = new Qt3DCore::QArmature();
a->setSkeleton(skeleton);
entity->addComponent(a);
I also have an update function where I change the joint's translation/rotation and re-apply the skeleton to the armature, but it does nothing, so I don't know if the joint/armature has been applied properly to the mesh.

Why A-frame is not loading OBJ .png textures from Maya.

I created a Maya file when I export it to OBJ with the .obj the .mtl and the texture .png everything is loaded except the textures everything is black. Am I missing something while exporting to maya?
Here is the OBJ and the texture: https://www.dropbox.com/sh/3cxqacay9sao1bu/AADtArGP5Pu2qdPY3hJBJ3Yka?dl=0
Thank you!
<a-assets>
<a-asset-item id="object-obj" src="objects/ccentercables.obj"></a-asset-item>
<a-asset-item id="object-mtl" src="objects/ccentercables.mtl"></a-asset-item>
</a-assets>
<a-obj-model src="#object-obj" mtl="#object-mtl" material="src: #texture"></a-obj-model>
Although there is a component for the obj's, and .mtl's, the a-frame team recommends the .glTF format as it is designed for webGL.
A-frame's Don McCurdy's pointed out multiple times that .obj's differ from each other, and can be hard to interpret by the webGL engine.
You should try converting the model to glTF with this, or this exporter. Though they are created for blender...
That's why You should also check out Don's article on exporting .gltf models from maya.

Implementation of A-Frame Extras FBX loader

Seeking an example of FBX loading within A-frame. Aframe Extras docs say that the FBX loader is experimental and only ASCII format is supported. Now I've exported the correct format yet I cannot view the file in my scene. Any ideas?
<a-entity fbx-model="src: url(https://mannymeadows.github.io/Noosa/models/FBX-DEMO.fbx);" material="color: red" crossorigin="anonymous">
Demo - http://codepen.io/MannyMeadows/pen/mmaLWv
You're using the fbx-model component correctly. In the JS console you'll see an error thrown from: THREE.FBXLoader.parseMesh:
aframe-extras.min.js:1 Uncaught TypeError: Cannot use 'in' operator to search for '1926113552' in undefined
at e.exports.THREE.FBXLoader.parseMesh (aframe-extras.min.js:1)
at e.exports.THREE.FBXLoader.parseMeshes (aframe-extras.min.js:1)
at e.exports.THREE.FBXLoader.parse (aframe-extras.min.js:1)
at aframe-extras.min.js:1
at XMLHttpRequest.<anonymous> (three.js:29211)
To verify that your model is good, try opening it in FBX Review.
If that works, THREE.FBXLoader just can't read the file for some reason. It's not uncommon unfortunately: FBX is a complex format, and isn't easy to support on the web. You can file a bug on three.js, but may ultimately want to convert to another format like OBJ or glTF.

A-frame - glTF - Asset not found

I'm trying to import a gltf-model into my scene, but even with correct paths and references the console claims the "core:propertyTypes:warn "#model" asset not found. +0ms".
Tried with a gltf-model exported from Blender by me as well as a downloaded working model. I am not having this problem with any .obj-files in the scene. Any suggestions to what I could try to change?
<a-assets>
<a-asset-item id="monster" src="/monster.gltf"></a-asset-item>
<a-asset-item id="separaterunner" src="/separaterunner.gltf"></a-asset-item>
<item id="plane" src="/plane.glb"></item>
</a-assets>
<a-entity id="separaterunner" gltf-model="gltf: #separaterunner"></a-entity>
<a-entity id="plane" gltf-model="gltf: #plane"></a-entity>
<a-entity id="monster" gltf-model="#monster"></a-entity>
If I use the same code structure for .gltf-files as for .obj-files I no longer get the error about "asset not found" but instead an error about cross origin requests. Why is that for .gltf but not for .obj?
Thanks
There's a syntax error in how you're using the gltf-model component, in two of those examples: it should be gltf-model="#foo", not gltf-model="gltf: #foo". (OBJ/MTL files are a bit different because there are two files required).
If the assets are still not found after fixing that, you may need to include more information about where the models are in your working folder, and how you're starting the local server (if you're using one).

Test print program works as stand alone, but fails when added to JavaFX app

I wrote a test program to print a graphic. I created a Printable object and drew an image to the Graphics object passed to the print() method. The stand alone application works fine. However, once I copy the code to my JavaFX application it fails to print the image. Even if I "print" to a pdf file, it always creates an empty pdf file. I have printed out the measurements of the imageable area and it is the same as in the test program.
imagable area (0.0, 0.0) - 612.0 x 792.0
I am at a loss as to why this fails when moved to the JavaFX program.
I found the issue via another test program. It had to do with returning NO_SUCH_PAGE. Basically, I had to recreate the page EVERY time the same page index was sent to print and return PAGE_EXISTS. As I was unclear of this I was erroneously telling the program that I was done printing when it called the method for the same page jndex.

Resources