Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Feb 13, 2024
1 parent 9420b75 commit 9484068
Show file tree
Hide file tree
Showing 6 changed files with 507 additions and 33 deletions.
186 changes: 180 additions & 6 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47132,6 +47132,138 @@ function buildBoxLinesGeometry(cfg = {}) {
});
}

/**
* @desc Creates a box-shaped lines {@link Geometry} from AABB.
*
* ## Usage
*
* In the example below we'll create a {@link Mesh} with a box-shaped {@link ReadableGeometry} that has lines primitives.
* This box will be created from AABB of a model.
*
* [[Run this example](/examples/#geometry_builders_buildBoxLinesGeometryFromAABB)]
*
* ````javascript
* import {Viewer, Mesh, Node, buildBoxGeometry, buildBoxLinesGeometryFromAABB, ReadableGeometry, PhongMaterial} from "../../dist/xeokit-sdk.min.es.js";
*
* const viewer = new Viewer({
* canvasId: "myCanvas"
* });
*
* viewer.scene.camera.eye = [-21.80, 4.01, 6.56];
* viewer.scene.camera.look = [0, -5.75, 0];
* viewer.scene.camera.up = [0.37, 0.91, -0.11];
*
* const boxGeometry = new ReadableGeometry(viewer.scene, buildBoxGeometry({
* xSize: 1,
* ySize: 1,
* zSize: 1
* }));
*
* new Node(viewer.scene, {
* id: "table",
* isModel: true, // <--------------------- Node represents a model
* rotation: [0, 50, 0],
* position: [0, 0, 0],
* scale: [1, 1, 1],
*
* children: [
*
* new Mesh(viewer.scene, { // Red table leg
* id: "redLeg",
* isObject: true, // <---------- Node represents an object
* position: [-4, -6, -4],
* scale: [1, 3, 1],
* rotation: [0, 0, 0],
* geometry: boxGeometry,
* material: new PhongMaterial(viewer.scene, {
* diffuse: [1, 0.3, 0.3]
* })
* }),
*
* new Mesh(viewer.scene, { // Green table leg
* id: "greenLeg",
* isObject: true, // <---------- Node represents an object
* position: [4, -6, -4],
* scale: [1, 3, 1],
* rotation: [0, 0, 0],
* geometry: boxGeometry,
* material: new PhongMaterial(viewer.scene, {
* diffuse: [0.3, 1.0, 0.3]
* })
* }),
*
* new Mesh(viewer.scene, {// Blue table leg
* id: "blueLeg",
* isObject: true, // <---------- Node represents an object
* position: [4, -6, 4],
* scale: [1, 3, 1],
* rotation: [0, 0, 0],
* geometry: boxGeometry,
* material: new PhongMaterial(viewer.scene, {
* diffuse: [0.3, 0.3, 1.0]
* })
* }),
*
* new Mesh(viewer.scene, { // Yellow table leg
* id: "yellowLeg",
* isObject: true, // <---------- Node represents an object
* position: [-4, -6, 4],
* scale: [1, 3, 1],
* rotation: [0, 0, 0],
* geometry: boxGeometry,
* material: new PhongMaterial(viewer.scene, {
* diffuse: [1.0, 1.0, 0.0]
* })
* }),
*
* new Mesh(viewer.scene, { // Purple table top
* id: "tableTop",
* isObject: true, // <---------- Node represents an object
* position: [0, -3, 0],
* scale: [6, 0.5, 6],
* rotation: [0, 0, 0],
* geometry: boxGeometry,
* material: new PhongMaterial(viewer.scene, {
* diffuse: [1.0, 0.3, 1.0]
* })
* })
* ]
* });
*
* let aabb = viewer.scene.aabb;
* console.log(aabb);
*
* new Mesh(viewer.scene, {
* geometry: new ReadableGeometry(viewer.scene, buildBoxLinesGeometryFromAABB({
* id: "aabb",
* aabb: aabb,
* })),
* material: new PhongMaterial(viewer.scene, {
* emissive: [0, 1,]
* })
* });
* ````
*
* @function buildBoxLinesGeometryFromAABB
* @param {*} [cfg] Configs
* @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
* @param {Number[]} [cfg.aabb] AABB for which box will be created.
* @returns {Object} Configuration for a {@link Geometry} subtype.
*/
function buildBoxLinesGeometryFromAABB(cfg = {}){
return buildBoxLinesGeometry({
id: cfg.id,
center: [
(cfg.aabb[0] + cfg.aabb[3]) / 2.0,
(cfg.aabb[1] + cfg.aabb[4]) / 2.0,
(cfg.aabb[2] + cfg.aabb[5]) / 2.0,
],
xSize: (Math.abs(cfg.aabb[3] - cfg.aabb[0])) / 2.0,
ySize: (Math.abs(cfg.aabb[4] - cfg.aabb[1])) / 2.0,
zSize: (Math.abs(cfg.aabb[5] - cfg.aabb[2])) / 2.0,
});
}

/**
* @desc Creates a grid-shaped {@link Geometry}.
*
Expand Down Expand Up @@ -84591,6 +84723,7 @@ class DistanceMeasurement extends Component {
this._zAxisVisible = false;
this._axisEnabled = true;
this._labelsVisible = false;
this._labelsOnWires = false;
this._clickable = false;

this._originMarker.on("worldPos", (value) => {
Expand Down Expand Up @@ -84650,6 +84783,7 @@ class DistanceMeasurement extends Component {
this.yAxisVisible = cfg.yAxisVisible;
this.zAxisVisible = cfg.zAxisVisible;
this.labelsVisible = cfg.labelsVisible;
this.labelsOnWires = cfg.labelsOnWires;
}

_update() {
Expand Down Expand Up @@ -84801,9 +84935,19 @@ class DistanceMeasurement extends Component {

this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);

this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
if (this.labelsOnWires) {
this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
} else {
const labelOffset = 35;
let currentLabelOffset = labelOffset;
this._xAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
currentLabelOffset += labelOffset;
this._yAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
currentLabelOffset += labelOffset;
this._zAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
}

const tilde = this._approximate ? " ~ " : " = ";

Expand All @@ -84816,9 +84960,15 @@ class DistanceMeasurement extends Component {

const labelMinAxisLength = this.plugin.labelMinAxisLength;

this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
if (this.labelsOnWires){
this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
} else {
this._xAxisLabelCulled = false;
this._yAxisLabelCulled = false;
this._zAxisLabelCulled = false;
}

if (!this._xAxisLabelCulled) {
this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
Expand Down Expand Up @@ -85219,6 +85369,25 @@ class DistanceMeasurement extends Component {
return this._labelsVisible;
}

/**
* Sets if labels should be positioned on the wires.
*
* @type {Boolean}
*/
set labelsOnWires(value) {
value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsOnWires;
this._labelsOnWires = value;
}

/**
* Gets if labels should be positioned on the wires.
*
* @type {Boolean}
*/
get labelsOnWires() {
return this._labelsOnWires;
}

/**
* Sets if this DistanceMeasurement appears highlighted.
* @param highlighted
Expand Down Expand Up @@ -86029,6 +86198,7 @@ class DistanceMeasurementsPlugin extends Plugin {
* @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
* @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
* @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
* @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
* @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
*/
constructor(viewer, cfg = {}) {
Expand Down Expand Up @@ -86056,6 +86226,7 @@ class DistanceMeasurementsPlugin extends Plugin {
this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
this.zIndex = cfg.zIndex || 10000;
this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;

this._onMouseOver = (event, measurement) => {
this.fire("mouseOver", {
Expand Down Expand Up @@ -86178,6 +86349,7 @@ class DistanceMeasurementsPlugin extends Plugin {
* @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
* @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
* @param {string} [params.color] The color of the length dot, wire and label.
* @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
* @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
*/
createMeasurement(params = {}) {
Expand Down Expand Up @@ -86209,6 +86381,7 @@ class DistanceMeasurementsPlugin extends Plugin {
originVisible: params.originVisible,
targetVisible: params.targetVisible,
color: params.color,
labelsOnWires: params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
onMouseOver: this._onMouseOver,
onMouseLeave: this._onMouseLeave,
onContextMenu: this._onContextMenu
Expand Down Expand Up @@ -195972,6 +196145,7 @@ exports.XKTLoaderPlugin = XKTLoaderPlugin;
exports.XML3DLoaderPlugin = XML3DLoaderPlugin;
exports.buildBoxGeometry = buildBoxGeometry;
exports.buildBoxLinesGeometry = buildBoxLinesGeometry;
exports.buildBoxLinesGeometryFromAABB = buildBoxLinesGeometryFromAABB;
exports.buildCylinderGeometry = buildCylinderGeometry;
exports.buildGridGeometry = buildGridGeometry;
exports.buildPlaneGeometry = buildPlaneGeometry;
Expand Down
Loading

0 comments on commit 9484068

Please sign in to comment.