xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
715 stars 286 forks source link

Ability to move PerformanceNodes #208

Closed Amoki closed 4 years ago

Amoki commented 4 years ago

PerformanceNodes don't have rotate and translate methods. Is this something required in order to increase performances or we could implement it?

Solution

Now implemented in PR https://github.com/xeokit/xeokit-sdk/pull/353

xeolabs commented 4 years ago

I intentionally didn't implement the ability to transform (rotate/translate/scale) PerformanceNodes, so that PerformanceModel could have the smallest possible memory footprint.

If we were able to transform PerformanceNodes, then each object would need to have its own 16-element transform matrix (16x 32-bit floats), and that would consume a lot more memory and make it less likely that browser can hold 100K+ objects in memory.

The way batched geometries work, where single-reuse geometries are combined into the same arrays in GPU memory, that would actually require a 16-element matrix for every vertex in the model, which would get huge.

However, recently a user mentioned that they would like to be able to explode models. For that particular use case, we would only need a 3D vector per object, which could be 3x 32-bit floats, or even 3x 16-bit integers. For batched geometries, that's a translation vector per-vertex, which isn't that bad.

What's your use case? Do you need translate, scale and rotate, or would translation be enough?

Amoki commented 4 years ago

We have the same use-case: exploding models so translation only is enough :)

xeolabs commented 4 years ago

Sweet - on the near-term road map it is!

Amoki commented 4 years ago

Nice, thanks :)

Amoki commented 4 years ago

Hi! Do you have any news?

xeolabs commented 4 years ago

Not yet! I have the plan for it clearly defined, but implementation of this one will need to wait about 2-3 weeks.

vs1785 commented 4 years ago

Hi,

Do you have any news on this?

xeolabs commented 4 years ago

Now implemented in 1.3.5 - see details in PR: https://github.com/xeokit/xeokit-sdk/pull/353

Run example: https://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_XKT_metadata_moveStoreys

vs1785 commented 4 years ago

This lets me set offset from current position.

Is there any way to find position of Node vs Center of model ?

Amoki commented 4 years ago

I would say const posToCenter = math.subVec3(node.position, math.getAABB3Center(model.aabb), math.vec3()). If I'm right, I'll send a message to my high school math teacher x)

vs1785 commented 4 years ago

Problem with this is node.position is not defined.

I am using XKT loader and i could not find a way to find node position.

Amoki commented 4 years ago

Oh, you're right. node.position for standard nodes are similar to performanceNode's offset (https://github.com/xeokit/xeokit-sdk/blob/master/src/viewer/scene/nodes/Node.js#L1027) and don't help here.

You can have the position of the center of the object with math.getAABB3Center(node.aabb), I don't know if it's enough

vs1785 commented 4 years ago

Great. This helped me.

Thank you for all help.