const nodeid = await this._spriteManager.createSprite(
url
, pos
, 50,
false,
worldHeight,
null, true
);
const scaleMatrix = new Communicator.Matrix()
scaleMatrix.setScaleComponent(10, 10, 1.0)
const moveMatrix = new Communicator.Matrix()
moveMatrix.setTranslationComponent(
pos.x,
pos.y,
pos.z
)
const finalMatrix = Communicator.Matrix.multiply(
scaleMatrix,
moveMatrix
)
await this._viewer.model.setNodeMatrix(nodeid, finalMatrix);
async pickAndMoveTextBox(targetPosition) {
// Compute the adjusted position for the pick operation using the mouse event position and an offset
const newScreenPosition = {
x: targetPosition.x, //+ this._offset.x,
y: targetPosition.y //+ this._offset.y
};
try {
// Perform the pick operation at the computed position with the specified configuration
viewer.selectionManager.clear();
viewer.selectionManager.setPickTolerance(tolerance);
let config = new Communicator.PickConfig(Communicator.SelectionMask.Face | Communicator.SelectionMask.Line);
let selectionItem = await viewer.view.pickFromPoint(newScreenPosition, config)
if (this._snapToModel && !selectionItem.nodeId) return;
// Move the selected text box to the new 3D position
await this._moveTextBoxTo(this._selectTextBox, selectionItem.world);
} catch (error) {
console.error('Error picking point and moving text box:', error);
}
return false;
}
async _moveTextBoxTo(textBox, newPosition) {
const moveMatrix = new Communicator.Matrix()
moveMatrix.setTranslationComponent(
newPosition.x,
newPosition.y,
newPosition.z
)
const finalMatrix = Communicator.Matrix.multiply(
textBox.getCurrentMarkupItem().boxMatrix,
moveMatrix
)
await this._viewer.model.setNodeMatrix(textBox.boxId, finalMatrix)
textBox.getCurrentMarkupItem().boxPosition = newPosition
// textBox._updateLeaderLine()
// this.refreshMarkup()
}
I need the markup should be billboard and also not able to move along the surface like in x, y ,z axis it is always moving one direct like 2d