opensourceBIM / GltfSerializers

BIMserver that converts a model to binary glTF
17 stars 10 forks source link

Access element properties #2

Open OliHas opened 6 years ago

OliHas commented 6 years ago

Hi! For a researchproject I'm developping a small three.js viewer, in which BIM models from the BIMServer can be displayed. Now I would like to get the properties of an element directly in the three.js-viewer. Is there a way to access properties of a selected element? Something like a unique id, which is passed from the GltfSerializer? Thanks for your help!

rubendel commented 6 years ago

So far I have not come across the ability to add custom data in a glTF (2) file (in the specification). If you know of a place where we could put for example the IfcProduct id, please let me know and I'll add it to the serializer.

OliHas commented 6 years ago

I think this could help: GLTFLoader: Fixes to improve mesh name uniqueness. I recommend to store the IfcProduct id here: primitive[].extras This becomes in three.js: mesh[].userData

OliHas commented 6 years ago

Hi! It is possible to pass data if this is inserted into the code "BinaryGltfSerializer2.java" at line 558:

ObjectNode extrasNode = OBJECT_MAPPER.createObjectNode();
nodeNode.set("extras", extrasNode);
extrasNode.put("IfcProductID", IfcProductID);

How do I find out the IfcProduct id? Thanks for your help!

rubendel commented 6 years ago

Cool.

https://github.com/opensourceBIM/GltfSerializers/blob/master/Gltf/src/org/bimserver/gltf/BinaryGltfSerializer2.java#L200

The ifcProduct.getOid() will give you the product oid.