Refine BIM section controls and styling

This commit is contained in:
CODEX
2026-06-18 22:09:55 +03:00
parent e343412468
commit 84b28ba12c
6 changed files with 294 additions and 46 deletions
+89 -5
View File
@@ -126510,6 +126510,9 @@ class TransformControl {
scale: [5, 5, 5],
isObject: false
});
this._rootNode = rootNode;
this._styleScale = 1;
this._baseRootScale = 5;
const pos = math.vec3();
this._setPosition = (function() {
@@ -126831,6 +126834,16 @@ class TransformControl {
return {
setPositionActive: (a) => { positionActive = a; updatePositionHandle(); },
setRotationActive: (a) => { rotationActive = a; updateRotationHandle(); },
setColor: (color) => {
if (!color) {
return;
}
material.diffuse = color;
material.emissive = color;
if (hoop.highlightMaterial) {
hoop.highlightMaterial.fillColor = color;
}
},
set visible(v) {
visible = v;
updatePositionHandle();
@@ -126868,13 +126881,16 @@ class TransformControl {
{ // Keep gizmo screen size constant
let lastDist = -1;
const setRootNodeScale = size => {
if (rootNode.scale[0] !== size) {
rootNode.scale = [size, size, size];
this._baseRootScale = size;
const styledSize = size * (this._styleScale || 1);
if (rootNode.scale[0] !== styledSize) {
rootNode.scale = [styledSize, styledSize, styledSize];
if (this._handlers && this._handlers.onScreenScale) {
this._handlers.onScreenScale(rootNode.scale);
}
}
};
this._applyRootScale = () => setRootNodeScale(this._baseRootScale || rootNode.scale[0] || 5);
const onSceneTick = scene.on("tick", () => {
const camera = scene.camera;
const dist = Math.abs(math.distVec3(camera.eye, pos));
@@ -127030,6 +127046,19 @@ class TransformControl {
this.__destroy();
}
setStyle(style = {}) {
if (style.gizmoDiameter !== undefined) {
this._styleScale = style.gizmoDiameter;
this._applyRootScale?.();
}
if (style.axes) {
this._displayMeshes.x?.setColor?.(style.axes.x);
this._displayMeshes.y?.setColor?.(style.axes.y);
this._displayMeshes.z?.setColor?.(style.axes.z);
}
this._rootNode?.scene?.glRedraw?.();
}
/**
* Called to assign this Control to Handlers.
* Call with a null or undefined value to disconnect the Control from whatever Handlers it was assigned to.
@@ -127703,7 +127732,7 @@ class SectionPlanesPlugin extends Plugin {
const planeRoot = (function() {
const rootNode = new Node$1(scene, { isObject: false });
rootNode.addChild(new Mesh(rootNode, { // plane
const planeMesh = rootNode.addChild(new Mesh(rootNode, { // plane
geometry: new ReadableGeometry(rootNode, {
primitive: "triangles",
positions: [
@@ -127737,7 +127766,7 @@ class SectionPlanesPlugin extends Plugin {
isObject: false
}));
rootNode.addChild(new Mesh(rootNode, { // Visible frame
const frameMesh = rootNode.addChild(new Mesh(rootNode, { // Visible frame
geometry: new ReadableGeometry(rootNode, buildTorusGeometry({
center: [0, 0, 0],
radius: 1.7,
@@ -127769,6 +127798,38 @@ class SectionPlanesPlugin extends Plugin {
isObject: false
}));
const setPhongMaterial = (material, color, alpha) => {
if (!material) {
return;
}
if (color) {
material.diffuse = color;
material.emissive = color;
}
if (alpha !== undefined) {
material.alpha = alpha;
material.alphaMode = alpha < 1 ? "blend" : "opaque";
}
};
const setEmphasisMaterial = (material, fillColor, fillAlpha, edgeColor, edgeAlpha) => {
if (!material) {
return;
}
if (fillColor) {
material.fillColor = fillColor;
}
if (fillAlpha !== undefined) {
material.fillAlpha = fillAlpha;
}
if (edgeColor) {
material.edgeColor = edgeColor;
}
if (edgeAlpha !== undefined) {
material.edgeAlpha = edgeAlpha;
}
};
return {
setPosition: (function() {
const origin = math.vec3();
@@ -127781,7 +127842,26 @@ class SectionPlanesPlugin extends Plugin {
})(),
setQuaternion: q => { rootNode.quaternion = q; },
setScale: s => { rootNode.scale = s; },
setVisible: v => { rootNode.visible = v; }
setVisible: v => { rootNode.visible = v; },
setStyle: (style = {}) => {
setPhongMaterial(planeMesh.material, style.planeFillColor, style.planeFillAlpha);
setEmphasisMaterial(
planeMesh.ghostMaterial,
style.planeFillColor,
style.planeFillAlpha,
style.planeEdgeColor,
style.planeEdgeAlpha
);
planeMesh.opacity = style.planeFillAlpha;
setPhongMaterial(frameMesh.material, style.planeEdgeColor, style.planeEdgeAlpha);
setEmphasisMaterial(
frameMesh.highlightMaterial,
style.planeEdgeColor,
style.planeEdgeAlpha,
style.planeEdgeColor,
style.planeEdgeAlpha
);
}
};
})();
let unbindSectionPlane = () => { };
@@ -127803,6 +127883,10 @@ class SectionPlanesPlugin extends Plugin {
},
setCulled: c => { culled = c; updateVisible(); },
setVisible: v => { visible = v; updateVisible(); },
setStyle: style => {
planeRoot.setStyle?.(style);
ctrl.setStyle?.(style);
},
_setSectionPlane: sectionPlane => {
unbindSectionPlane();
if (sectionPlane) {