-
Notifications
You must be signed in to change notification settings - Fork 296
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
Implement section caps through sceneModelEntity:capMaterial #1775
base: master
Are you sure you want to change the base?
Conversation
Ok, I will give it a try :) |
examples/slicing/SectionPlanesPlugin_Duplex_SectionCaps.html
Dismissed
Show dismissed
Hide dismissed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey guys, I'm testing it on various different models, it works better than I thought. It runs quite fast and gets quite good results. But also it has some limitations:
- models have to have all meshes closed (solids). But in reality many models have none of them closed or only some of them closed, which results in only partial caps / no caps.
- for huge models (such as WestRiverSideHospital) it crashes my browser.
- it doesn't work once I set the position of the model (it doesn't cap then)
- I think it would be good to check the model far from origin, but I can't remember which one was it. Do you remember @xeolabs?
Because of the above I'm thinking if maybe it would be better to add this functionality more as an example rather than a xeokit-sdk functionality? What do you guys think?
Hi @paireks! Thank you for trying out this feature and your valuable feedback.
|
I've added a section plane and capMaterials to the |
d324265
to
01c0856
Compare
01c0856
to
a722993
Compare
diffuse: [1.0, 0.0, 0.0], | ||
backfaces: true | ||
}); | ||
addCapsMaterialsToAllObjects(sceneModel, opacityThreshold, material); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the immediate addCapsMaterialsToAllObjects(...)
call is removed, and instead called after the model loads (from e.g. a test function window.addHatching = () => addCapsMaterialsToAllObjects(...);
) the hatching doesn't appear.
let vertices = [], indices = []; | ||
|
||
if(!this._verticesMap[sceneModel.id].has(key)) { | ||
const isSolid = object.meshes[0].layer.solid !== false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .layer attribute is actually private within a SceneMesh, so let's not access that - rather, please add a get primitive
accessor to SceneMesh, and then test if the mesh is solid with object.meshes[0].primitive === "solid"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A primitive
has different semantics throughout the system.
Some places consider it as e.g. solid
or surface
(SceneModelMesh
), while others consider it as e.g. triangle-strip
or line-loop
(ReadableGeometry
).
Perhaps it'd be clearer, if the SceneModelMesh
exposed a isSolid()
predicate, instead of a confusing primitive
property?
new Float32Array(3) | ||
]; | ||
|
||
this._dirtyMap[sceneModel.id].forEach((value, key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename key->objectId
new Float32Array(3) | ||
]; | ||
|
||
this._dirtyMap[sceneModel.id].forEach((value, key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename value->modelId
* | ||
* @type {Material} | ||
*/ | ||
set capMaterial(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one architectural change request:
- add a boolean
Entity.capped
property, which would indicate if thatEntity
is currently capped - add a
Scene.crossSections.capMaterial
property, which is aMaterial
- then make
Entity.capMaterial
point toScene.crossSections.capMaterial
unless overridden by a user'sMaterial
instance
This way, we're also consistent with selection, highlighting etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment semantics of not assigning capMaterial
are: "don't create section caps for this entity", which is useful for users that are not interested in hatching, and so don't have to pay the performance price for the feature.
It's also as simple as a single line of code to apply any global/default capMaterial
to all entities.
); | ||
} | ||
|
||
class SectionCaps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a class comment - maybe something similar to SAO
Please give this branch a test and let me know if you see any bugs so that we can fix it before merging into main.