Test semantic node

This commit is contained in:
2026-05-20 11:45:51 +02:00
parent aa9a6f56b6
commit f5f105e786
3 changed files with 70 additions and 3 deletions

View File

@@ -37,7 +37,6 @@ function init () {
ATON.setMainLightDirection(new THREE.Vector3(...config.scene.initLightDir));
ATON.toggleShadows(config.scene.shadows);
ATON.setExposure(config.scene.initialExposure);
// Open settings side panel when clicking on settings btn
AppState.camera = ATON.Nav._camera;
AppState.renderer = ATON._renderer;
@@ -106,10 +105,63 @@ function loadNodes(nodes) {
AppState.clipping.boundingSphere = node.getBound();
}
AppState.nodes.push({id: n.label, active: n.isInvisible ? false: true});
if (n.isSemantic) {
createSemanticNode(n.model, n.label);
//ATON.getSemanticRoot().attach(semNode);
}
AppState.nodes.push({
id: n.label,
active: n.isInvisible ? false: true,
isSemantic: n.isSemantic
});
});
if (!AppState.clipping.boundingSphere) {
console.error("No bounding sphere computed, clipping will fail. Ensure one node has 'isMain: true'.");
}
}
/**
* Uses a generic sphere shape as semantic annotation
* @param {Sphere} bound The scene node's bounding sphere
* @param {string} id The original scene node ID (3D object)
* @returns {ATON.SceneNode}
function createSemanticNode(bound, id) {
// Default/highlight materials for semantic node
let matSemDef = ATON.MatHub.materials.semanticShape;
let matSemHL = ATON.MatHub.materials.semanticShapeHL;
const semNode = ATON.createSemanticNode(id)
.setDefaultAndHighlightMaterials(matSemDef, matSemHL)
.attachToRoot();
const sphereCenter = bound.center;
const sphereRadius = bound.radius * 0.2;
let sphere = ATON.SemFactory.createSphere(id, sphereCenter, sphereRadius);
console.debug('Bound:', bound);
console.debug('Semantic sphere:', sphere);
}
*/
/**
* Creates a semantic annotation from a model
* @param {string} model The model's path to load
* @param {string} id The original scene node ID (3D object)
* @returns {ATON.SceneNode}
*/
function createSemanticNode(model, id) {
// Default/highlight materials for semantic node
let matSemDef = ATON.MatHub.materials.semanticShape;
let matSemHL = ATON.MatHub.materials.semanticShapeHL;
const semNode = ATON.createSemanticNode(id)
.load(model)
.setDefaultAndHighlightMaterials(matSemDef, matSemHL)
.attachToRoot();
semNode.setRotation(...config.scene.initRotation);
return semNode;
}